Overview
A semi-detailed guide on how to setup a DVR using Raspberry Pi 3 to watch and record free over the air HDTV.
These instructions will allow 2 simultaneous programme recording while watching another already recorder programme.
It aims at providing and addressing the following:
- ATSC Signal: Outdoor/indoor antenna
- Decoding of the signal: USB ATSC TV Tuner
- Channel guide: third party source from https://tvlistings.zap2it.com & download script
- Recordings management & scheduling: https://tvheadend.org/
- Recordings playing: Kodi + LibreELEC + Tvheadend HTSP Client
- Recordings storage: high capacity external USB hard drive
Bill of Material
- Raspberry Pi 3 kit
- 2 TB (or more) USB external hard drive
- ATSC USB Tuners:
- 2 Digital TV Tuner for Xbox One (1 is enough if dual recording is not a must)
- (alternate option) Hauppauge 1595 WinTV-DualHD
- Raspberry MPEG-2 License (to enable HW decoding of ATSC Streams when playing back)
- Coax cable splitter (not required if dual recording is not a must)
- MicroSD card
- MicroSD card USB reader
LibreELEC Install
Download from https://libreelec.tv/
The version that was causing less issue is 9.2.1 for my Raspberry Pi 3. http://archive.libreelec.tv/LibreELEC-RPi2.arm-9.2.1.img.gz
Extract downloaded file and unzip it.
Plug micro sd card in PC.
Check where mounted: lsblk
Unmount card partition (if mounted): sudo umount /dev/sdx#
Write to micro sd card:
sudo dd if=XXX.img of=/dev/sdx bs=4M conv=fsync status=progress
sync
- Plug sdcard on the PI
- Boot PI
- Wait for full initial setup, including partition resize
- Follow wizzard to setup Wifi, etc…
- Disable auto update:
- Settings
- LibreELEC
- Updates
- Change “Automatic Updates” to “manual”
- Set proper timezone:
- Settings
- Interface
- Regional
- Timezone country
MPEG-2 License
Need to buy a license from http://www.raspberrypi.com/mpeg-2-license-key/
For my PI, the license is: 0x16baa230
Enable the license by sshing on the PI:
ssh root@192.168.1.23
- The default password is
libreelec
.
- In the SSH session mount the /flash directory with read and write privileges:
mount -o remount,rw /flash
- Edit the /flash/config.txt file to add the MPEG-2 license key:
- nano /flash/config.txt
- Locate the
decode_MPG2
line, remove the # and space at the front, and add your MPEG-2 license key, ex: decode_MPG2=0x16baa230
External Hard-drive
- Make sure the USB hard-drive is plugged in the PI and properly mounted.
- Make a symlink to it in the storage folder:
**
cd /storage
** ln -s /media/BLUE_2TB/DVR
DVR
Tvheadend
Backend (tvheadend)
Install the Tvheadend Server add-on from the “Service” category in the add-ons repos.
Configure the addon to have a delayed startup of 20 seconds. This is to make sure that the externally mounted drive are available when tvheadend starts:
- My Addons
- Tvheadend Server
- Configure
- DVB section
- Delay Start of tvheadend: active
- Seconds delay: 20
The rest of the tvheadend configuration is done from its web interface: http://ip:9981
(mine is: http://192.168.1.23:9981)
Goto Configuration > General > Base:
- Set User interface level to Expert
- Picon section:
- Uncheck prefer picon
- Set channel icon path:
https://raw.githubusercontent.com/mathieugouin/rpiDvr/master/zap2xml/iconsMan/%C.png
- Channel icon name scheme: “All lower case”
DVR Setup
The following is done using tvheadend web interface.
Refer to http://docs.tvheadend.org/webui/config_dvr/
Goto Configuration > Recording > Digital Video Recorder Profiles:
- Select the <Default profile)
- In the Parameters right section:
- DVR file retention period: Forever
- Recording system path:
/storage/DVR/recordings
- Format string:
$t$-e_%F$n.$x
Channel setup
The following is done using tvheadend web interface.
Goto Configuration > DVB Input:
- Network tab: Add network
- type = ATSC-T
- Name = ATSC-T
- Predefined muxes: United States: us-ATSC-center-frequencies-8VSB-062009
- TV Adapters tab:
- Enable only the ATSC-T sub tuner
- Assign network to tuner for ATSC-T (for terrestial)
- Network tab: Select ATSC-T, then click Force scan
- Muxes tab:
- Check scan results.
- For frequency 575.028 (ICI Television), enable:
- Accept zero value for TSID
- EIT - skip TSID check
- Play it manually once using the play button. This should launch VLC player. Then, it will allow the service to be mapped to a channel.
- Services tab: map all selected, map all services.
Goto Configuration > Channel/EPG
- Channel Tags tab (optional): create the following tags to help when searching:
- French
- English
- Canada
- USA
- En-Can
- Channels tab:
- Adjust channel name & number, ex: CBC, 6.1
- Make sure user icon is set properly (use reset icon + save).
- Manually add channel and map to services if not all services were correctly mapped. Refer to the wiki pages below to find the corresponding frequency for each channel. Note that tvheadend reports mux frequency as 3.028 MHz + “Lower edge”. For example, wiki lists UHF channel 15 lower edge at 476 MHz, tvheadend displays 479.028 MHz and it corresponds to CKMI-DT-1 (Global).
Frontend (Kodi)
In Kodi TV interface:
- Install/Enable PVR addon: Tvheadend HTSP Client
Configure Kodi TV settings:
- Kodi Settings
- TV
- Enable: use channel number from backend
EPG Downloader
These steps explains how to install an addon that will download the updated EPG (Electronic Program Guide) every night and make it available for tvheadend.
Download the addon script.module.zap2epg from https://github.com/mathieugouin/script.module.zap2epg
Direct download link https://github.com/mathieugouin/script.module.zap2epg/releases/download/v1.3.3/script.module.zap2epg-1.3.3.zip
Setup:
- Copy the file on the PI.
- Install the addon.
- Run the addon and setup your lineup:
- Canada
- ZIP Code: J3B2X8
- Lineup: Local over the air broadcast
- Configure your channel list (add channels to be downloaded)
- You can run the program from the addon as a test - not necessary
Configure the Addon as follows:
- Option section:
- Nb days download: 14
- Nb days delete cache: 3
- Download extra details: OFF
- Append extra details: OFF
- Include Episode Thumbnail: None
- Include Episode Genres: Full
- Tvheadend section:
- Tvheadend Options Enbled: OFF
The following is done using tvheadend web interface.
Goto Configuration > Channel/EPG:
- EPG Grabber Modules tab: Enable only “Internal: XMLTV: tv_grab_zap2epg”
- EPG Grabber tab:
- General configuration:
- Periodically save EPG to disk (hours): 0 (to disable)
- Enable save to disk after import
- Internal grabber: Set EPG frequency (Expert mode) for Internal grabber
0 4 * * *
- EPG Grabber Channels tab: Assign channels to each EPG channel
Miscelaneous
Clear Icons Cache
When changing tvheadend channel icons, it is required to clear the cache to force Kodi to reload the new icons
rm $HOME/.kodi/userdata/Thumbnails/*/*.png
rm $HOME/.kodi/userdata/Database/Textures13.db
sudo reboot
Enable debug log
If required to help debugging an issue with kodi, activate debug logging without the annying onscreen debug overlay as follows:
- Connect through ssh on the PI:
ssh root@192.168.1.23
- If not already present, create the following text file:
/storage/.kodi/userdata/advancedsettings.xml
- Edit to contains:
<advancedsettings version="1.0">
<!-- That should enable debug logging but without that annoying overlay on the screen. -->
<loglevel>1</loglevel>
</advancedsettings>
References
SSH
Connect: ssh root@192.168.1.23
File copy from PI: scp root@192.168.1.23:/home/xbian/zap2xml.tar.gz .
File copy to PI: scp file.tar.gz root@192.168.1.23:/path/to/copy/file.tar.gz