Raspberry Pi Mpeg 2 Crack

  воскресенье 26 апреля
      97

Raspberry Mpeg-2 License Keygen 16.

Summary

This article is both a tutorial and a proof of concept. The tutorial describes the hardware required and the steps involved to build your own Personal Video Recorder to record Over-The-Air TV shows available for free with a TV aerial. The proof of concept explores what is possible using low end hardware for a PVR.

The solution uses LibreELEC installed on a Raspberry Pi 3. The LibreELEC distro provides easy installation of the GNU/Linux operating system, Kodi media player, and Tvheadend PVR software. At completion of the steps you will be able to record up to 2 television stations simultaneously while also watching a recorded TV show.

This article was written in December 2017.

Brief History of Document Updates:

Update 2019-12-05: Updated instructions for LibreELEC 8.2.5.

Update 2019-03-31: Upgraded to LibreELEC 8.2.5 and added audio_pwm_mode=0 to /flash/config.txt to fix analog audio crackling problem with LibreELEC 8.2.4 and 8.2.5.

Update 2018-11-16: Added section 'L' instructions to improve ability to recover properly after a power outage so that TV programs can be recorded without manual intervention.

CAUTION: PVR is Unstable if Inadequately Cooled.
The PVR as originally built without heatsinks was not stable. Under load the RPi3 would hang due to overheating.
To address this issue I added aluminum heatsink cooling fins to the GPU/CPU and Ethernet chips.
A better solution is to seek out a passively cooled aluminum case that contacts the GPU/CPU to disperse heat (e.g., no noisy cooling fan). For example I ordered the following aluminum case. Overall this aluminum case reduced operating temperatures by more than 10 °C compared to the aluminum heatsink cooling fins I had used previously.

Contents

  • Hardware Selection
  • G. Enable OTA TV Show Subtitles
  • H. Install Tvheadend Add-ons
  • Watch and Record TV
  • Observations

Completed PVR

Following is a picture of the completed RPi3 PVR in operation.

Background

Since 2011 when my spouse and I cut the cord on cable TV and built a Mythbuntu PVR we have been extremely satisfied. That was 6 years ago, and that doesn't mean that I haven't been curious about potentially less expensive options. One System On a Chip (SOC) board that intrigues me is the Raspberry Pi (RPi).

Previously I built a frontend to our MythTV PVR using Kodi on a RPi2 and MythFrontend on a RPi2. From that experience I learned that Kodi appears to have been supported for a longer time on the RPi.

Because I have only read about others using a Raspberry Pi as either a MythTV frontend, or a MythTV backend, but not both at the same time, I figured I would investigate other options for building a combined frontend/backend RPi based PVR.

This investigation led me to discover Tvheadend, which is supported on the LibreELEC GNU/Linux distribution.

NOTE: Tutorial Assumes Access to Computer, microSD Card Reader, and TCP/IP Network
In addition to the Raspberry Pi 3 used in this tutorial as the base for the PVR, I also used a computer running GNU/Linux (kubuntu 16.04) to access a web browser, terminal window, and ssh command. You might instead use Windows and Putty for ssh.
You will also need a TCP/IP home network with two free Ethernet ports and access to the Internet.

Hardware Selection

When selecting the hardware it is a good idea to have some goals to help guide decisions. For this proof of concept PVR I desired the following features:

  • Must be quiet (PVR directly attached to TV)
  • Must be both backend (record) and frontend (play)
  • Must support recording at least 2 shows at once
  • Must be reasonably neat and tidy (reduce cable clutter)
  • Should keep costs as low as reasonably possible

With this proof of concept I wanted to explore the limits of what was possible using a Raspberry Pi 3 as a PVR. I wished to build a PVR for a low cost and which did not require an externally powered USB hub. I researched specifications and theoretical boundaries to come up with my choices of hardware components.

Specifications

First the dry reading. If you wish to skip over the specifications, feel free as you can refer back to these if necessary.

RPi3 specifications:

  • SoC: Broadcom BCM2837 (roughly 50% faster than the Pi 2)
  • CPU: 1.2 GHZ quad-core ARM Cortex A53 (ARMv8 Instruction Set)
  • GPU: Broadcom VideoCore IV @ 400 MHz.
  • Memory: 1 GB LPDDR2-900 SDRAM.
  • USB 2.0 ports: 4.
  • Network: 10/100 Mb/sec Ethernet, 802.11n Wireless LAN, Bluetooth 4.0.

RPi3 Power Supply/Requirements:

  • Recommended Power Supply: 5.1 Volts at 2.5 Amps.
  • Power Draw: 0.7 Amps to 1 Amp.
    If you need to connect a USB device that will take the power requirements above 1 Amp, then you must connect it to an externally-powered USB hub.

USB 2.0 specifications:

  • Bandwidth: 480 Mbits/sec

North American ATSC digital Television standard specifications:

  • Net bit rate up to 19.39 Mb/sec, which rounds up to 20 Mbits/sec.

Theoretical Boundaries

A single hour of recording an ATSC MPEG-2 TV show can be up to 9 GB in size.

With a single ATSC TV stream of 20 Mb/s it is theoretically possible (but less likely in real word situations) to have a maximum of:

  • 5 concurrent streams on a 100 Mb/s TCP/IP network.
  • 24 concurrent streams on a USB 2.0 bus.

Rationale for Hardware Choice

The above specifications and theoretical boundaries led me to realize that if I were to encounter a bandwidth limitation, it would most likely be due to a network constraint and not a USB bus constraint.

Also because I did not wish to use an externally powered USB hub (extra cables / rats nest) and because there is limited power available via the RPi3 USB bus I had to make another choice. I figured that I could only connect one device to be powered by the RPi3 USB port: Either the TV tuner, Or the hard drive, But not both.

The two tuners I considered were:

The hard drive storage options I considered were:

This meant the potential combinations I could use for a maximum use scenario of watching one recording with two recordings in progress were:

  • Option A: Silicon Dust HDHomeRun Connect with 2 TB USB HDD
    • Cost: $260
    • Network Bandwidth:
      40 Mbits/sec = (20 * 2 incoming TV source streams to RPi3)
  • Option B: Hauppauge WinTV dualHD with 2 TB NAS
    • Cost: $295
    • Network Bandwidth:
      20 * 1 incoming TV recording from NAS to watch
      + 20 * 2 incoming TV source streams to RPi3
      + 20 * 2 outgoing TV streams to NAS to record
      --------------------------------------------------------------
      100 Mbits/sec (the theoretical maximum of 100 Mb/sec Ethernet)

I chose Option A not because it was less expensive by $35, but more importantly because Option A would add significantly less traffic to my home network.

Hardware Component List

Following is a list of components I assembled and their costs in November 2017.

CategoryComponentCost
ComputerRaspberry Pi 3 Model B (1.2GHz quad-core ARM CPU with 1 GB RAM)60
CaseClear Plastic Case
Even Better is this aluminum case with no heatsinks required
10
HeatsinkAluminum Heatsink Kit (added due to initial overheating issues)10
Power SupplyMicro USB Power Supply (2.4 Amp)15
StorageKingston 8 GB microSDHC Card (Class 10) with SD Adapter10
KeyboardiPazzPort Wireless Mini Keyboard20
MPEG-2 LicenseMPEG-2 License from Raspberry Pi Store5
Hard DriveSeagate Backup Plus Slim 2TB Portable External Hard Drive100
TV TunerSilicon Dust HDHomeRun Connect network dual tuner160
Grand Total$ 390

Note that you will also need a TV aerial, coax cable, Ethernet cable, and either an HDMI cable (New TV) or a 3.5mm to RCA composite audio/video cable (Old TV).

Note also that I opted for the above USB hard drive because it was reported to work when directly connected to the RPi3.

TIP: You can often save some cash by purchasing the top five orsix components in a Raspberry Pi 3 kit.

A. Download and Uncompress LibreELEC to MicroSD Card

Use the following instructions to download and write the LibreELECimage to the microSD card.

  1. Download LibreELEC disk image for RPi2/3:

    Visit LibreELEC - Downloads.

    I recommend installing LibreELEC-RPi2.arm-8.2.5.img.gz which includes Kod 17.6.
    Originally for this tutorial I had downloaded LibreELEC-RPi2.arm-8.2.1.img.gz.

  2. Insert the MicroSD card into your computer.

  3. Determine the which /dev/device it is.

    Example output:

    From above output the device is /dev/mmcblk1 (weignore the partition portion p2).

    WARNING: It is very important to identify the correct device. Use of the wrong device path can result in loss of data and/or the operating system.

  4. Ensure that the device is unmounted by checking the output fromdf to see if the device is in use.

    Example output:

    If the device is in use then unmount each mount point.

    Using the example above we unmount two locations from mmcblk1:

  5. Write the image to the microSD Card.

    Be sure to use the correctly identified device! In this examplethe device path is /dev/mmcblk1.

  6. Remove the microSD Card.

B. Insert MicroSD Card and Power on Raspberry Pi

At first power up the image will be resized to use the entire microSDcard, and then the RPi3 will reboot.

  1. At Welcome to LibreELEC screen choose Next.

  2. At Hostname prompt change or leave name LibreELEC and chooseNext.

  3. At Networking screen with Wired and Wireless networks listedchoose Next.

  4. At Sharing and Remote Access screen under Configure Servicesenable SSH and disable Samba. Choose Next.

    Enable Samba if you wish to access Windows network shares.

    Note that username is root and pasword is libreelec.

  5. At Thank you screen choose Next.

TIP: Recommend Disabling LibreElec Automatic Updates
New issues can be encountered if/when LibreElec automatically upgrades the system. For example I heard audio crackling when playing TV show recordings after LibreElec automatically updated to 8.2.4 and to 8.2.5.
To disable LibreElec automatic Upgrades:
Navigate to Gear icon (System) -> LibreElec -> Updates.
Change Automatic Updates to manual.
Reboot to stop any currently downloading system update in progress.

C. Enable MPEG-2 Hardware Video Decoding

If you have not already done so, purchase an MPEG-2 license key from theRaspberry Pi Store.Cost is ~2 British Pounds. The license key will be sent to the emailaddress you provide (can take up to 72 hours).

Note that a VC-1 license key is also available, but it is not neededto view North American Over-The-Air content which is in MPEG-2format.

  1. Lookup the IP Address in Kodi for the Raspberry Pi.

    Navigate to System (gear icon at top) and press Enter.

    Navigate to System information and press Enter.

    Make note of the IP address.

    In this example we will use 192.168.1.68.

    Press Escape twice to back out to the main screen.

  2. Open a terminal window on a different GNU/Linux computer and makea secure shell connection to the IP address of your Raspberry Pi.

    Be sure to use the IP address for your RPi3 on your network.

    The password is libreelec all lowercase.

  3. In the SSH session mount the /flash directory with read andwrite privileges.

  4. Edit the /flash/config.txt file to add the MPEG-2 licensekey.

    Locate the decode_MPG2 line, remove the # and space atthe front, and add your MPEG-2 license key.

    If you wish to share a microSD card image with multiple RPi3sthen you can string together a maximum of 8 licenses. Forexample:

  5. Fix analog audio crackling with LibreELEC 8.2.4 and 8.2.5 [Optional]

    If you experience analog audio crackling, such as when playing OTA MPEG2 1080i recordings, then add the following config.txt parameter.

  6. Potential fix for overscan issue [Optional]

    If the edges of the kodi display are not visible on the physical screen, then try adding or uncommenting the overscan_scale=1 config.txt parameter.

  7. Save and exit the editor with Ctrl+X.

  8. Return the /flash directory back to read only privileges.

  9. Reboot the Raspberry Pi. This will close the SSH session.

If you wish you can check if the MPEG-2 decoder is enabled via an SSHconnection with the following command:

The MPEG-2 hardware video decoder should now be enabled.

D. Enable 3.5mm Headphone Jack Audio [Optional]

  1. Navigate to System (gear icon at top) and press Enter.

  2. Navigate to System Settings and press Enter.

  3. Navigate to Audio and press Enter.

  4. Navigate right to Audio output device and press Enter.

  5. Navigate down to PI: HDMI and Analogue and press Enter.

  6. Press Escape twice to back out to main screen.

E. Set Time Zone Details

  1. Navigate to System (gear icon at top) and press Enter.

  2. Navigate to Interface settings and press Enter.

  3. Navigate to Regional.

  4. Navigate right to Language.

  5. Navigate down to Timezone country and press Enter.

    Set the following:

  6. Press Escape twice to back out to main kodi screen.

F. Disable Wireless Networks [Optional]

The reason for disabling wireless networks is to reduce the powerrequired by the RPi3 and hence have more power available for the harddisk drive. By default Bluetooth is already disabled.

  1. Navigate to System (gear icon at top) and press Enter.

  2. Navigate to LibreELEC and press Enter.

  3. Navigate to Network.

  4. Navigate right to Wireless Networks.

  5. With Active highlighted press Enter.

  6. Press Escape twice to back out to main kodi screen.

G. Enable OTA TV Show Subtitles

After spending a few days trying to figure out how to enable OTA TV show subtitles I had almost given up when I stumbled across this forum post for Kodi 17 Alpha 2 Video setting for Parse CC. Originally it appeared that the setting was not available from the Kodi 17 Krypton default Estuary skin, but was available in the previous Kodi default Confluence skin. Later on I learned that one must enable a higher settings level to view the closed caption setting. Following are the steps to enable closed captions / subtitles.

Enable Closed Captions

Here we enable the ability to parse for closed captions contained within the recorded ATSC TV shows.

  1. Navigate to System (gear icon at top) and press Enter.
  2. Navigate to Player settings and press Enter.
  3. Navigate to bottom of menu and change Settings level from Standard to Expert by using Enter key.
  4. Navigate to Language.
  5. Navigate right then down to Enable parsing for closed captions and press Enter to toggle to active.
  6. Navigate left then down to bottom of menu and optionally change Settings level back to Standard from Expert by using Enter key.
  7. Press Escape two times to back out to main menu.

Activate MCE Remote Subtitle Button [Optional]

These steps should enable the Subtitle, Teletext or Closed Caption button on an MCE remote control so you can easily toggle closed captions on and off without having to go through the menu.

  1. Open a terminal window on a different GNU/Linux computer and make a secure shell connection to the IP address of your Raspberry Pi.

    Be sure to use the IP address for your RPi3 on your network.

    The password is libreelec all lowercase.

  2. Change to the ~/.kodi/userdata/keymaps directory.

  3. Create/edit remote.xml file.

  4. Cut and paste the following content.

  5. Save the file with Ctrl+O and exit with Ctrl+X.

H. Install Tvheadend Add-ons

Tvheadend Server

From main Kodi menu:

  1. Navigate to Add-ons, right to Install from repository andpress Enter.

  2. Navigate to LibreELEC Add-ons and press Enter.

  3. Navigate to Services and press Enter.

  4. Navigate down to Tvheadend Server 4.2 and press Enter

  5. On Install press Enter.
    Wait for download to complete.

  6. Navigate up to . and press Enter.

At time of writing Tvheadend v4.2.3-20 was installed.

Tvheadend HTSP Client

  1. Navigate to PVR clients and press Enter.

  2. Navigate down to Tvheadend HTSP Client and press Enter.

  3. On Install press Enter.
    Wait for download to complete.

  4. Navigate to Configure and press Enter.

  5. Navigate down to Timer Settings and change:

    Default Lifetime: Forever (tvh 4.1+)

    Previously was 3 months.

  6. Navigate to OK and press Enter.

  7. Press Escape twice to back out to main kodi screen.

I. Attach USB Hard Drive (if not already connected)

  1. Exit Kodi and power down by navigating to the Power icon andpress Enter.

  2. Navigate to Power off system and press Enter.

  3. Disconnect Raspberry Pi 3 power supply from wall or switch offpower bar.

  4. Attach USB hard drive.

  5. Connect Raspberry Pi 3 power supply or switch on power bar.

  6. Kodi should now boot.

Note that the default file system on the Seagate hard drive is NTFS. If you wish to be able to attach the drive to a Windows computer, then keep the NTFS file system. I did this just to see if it would work (it does). Otherwise I recommend reformatting the partition to the ext4 filesystem for its superior ability to keep fragmentation to a minimum.

J. Create Recordings Folder on Hard Drive

  1. Navigate to System (gear icon at top) and press Enter.

  2. Navigate to File manager and press Enter.

  3. Navigate to Seagate_Backup_Plus_Drive and press Enter.

  4. Press C to pop up a context menu.

  5. Navigate to Make new folder and press Enter.

  6. Type in recordings and press Enter.

    Note that by default the Seagate USB hard drive was automaticallymounted on /var/media/Seagate Backup Plus.

  7. Press Escape twice to back out to main kodi screen.

K. Configure Tvheadend from a Computer Web Browser

Find the IP address of your LibreELEC box. From main kodi menu:

Settings -> System Information.

Now on computer with a web browser visit http://**RPi3-IP-Address**:9981.
(e.g., http://192.168.1.68:9981)

  1. At Welcome - Tvheadend - your TV streaming server and videorecorder screen enter your language details.

    Click Save & Next.

  2. At the next Welcome - Tvheadend - your TV streaming server andvideo recorder screen I didn't change any settings.

    On this screen you could configure additional security settings.For this proof of concept I did not set any restrictions.

    If you do choose to set an admin user/password for the web interface then you will need to enter this in the Tvheadend HTSP Client settings on the LibreELEC box. These settings are available at Add-ons -> Install from repository -> LibreELEC Add-ons -> PVR clients -> Tvheadend HTSP Client -> Configure -> Connection settings: Username/Password.

    Click Save & Next.

  3. At the Network settings screen configure the TV tuners.

    In my case both HDHomeRun ATSC-T Tuners were automaticallydetected. I only had to set the Network type on each tuner toATSC-T Network.

    Click Save & Next.

  4. At the Assign predefined muxes to networks screen select theappropriate pre-defined mux.

    In my case in the drop down menu for Pre-defined muxes I chose Canada: ca-AB-Calgary.

    Click Save & Next.

  5. At the Scan status screen wait for the scan to complete.

    The scan should find TV channels available in your area. In mycase it found 6 channels which is all of the Over-The-Air TVchannels available in my area.

    Click Save & Next.

  6. At the Service mapping screen select Map all services.

    Click Save & Next.

  7. The Finished screen indicates that the guided setup iscomplete.

    Click Finish.

  8. The Tvheadend backend will next scan the TV stations for OTAElectronic Program Guide data.

    Note that you should not wait for the scan to complete.

    Out of curiousity I did wait over 30 minutes for the ElectronicProgram Guide scan to complete. I noticed that when one scancompleted it moved down to start the scanning the next TV showtitle. My guess is that this might run all the time especiallywith different TV shows starting on the half hour.

  9. Set the recordings directory.

    Click on Configuration tab then Recording tab.

    Under Recording file options set:

    Click Save.

    Note that the default location /storage/recordings is on theMicroSD card. MicroSD cards are slow and generally not largeenough to hold ATSC MPEG2 recordings which can be up to 9GB perhour of content.

  10. Close the Web Browser.

L. Improve Power Outage Recoverability

After power outages the Tvheadend service does not always restart properly. I suspect the issue is that it takes a while for the Internet modem, router, HDHomeRun tuner, and RPi3 to all acquire working Network IP addresses. If the RPi3 is up and running first, it might fail to contact the HDHomeRun tuner and hence not configure Tvheadend properly to record TV programs.

The following steps try to alleviate this issue of no upcoming recordings on TV screen / Tvheaded not properly started after a power outage.

Add a time delay to the startup of Tvheadend.

  1. Navigate to Add-ons -> My Add-ons -> Services -> Tvheadend Server 4.2 -> Configure.

  2. Select DVB on left-hand side.

  3. Enable Delay the start of Tvheadend.

  4. Set Seconds delay = 30.

  5. Select OK on right-hand side.

  6. Press Escape three times to back out to main kodi screen.

Make RPi3 wait for network before starting Kodi and Tvheaded.

  1. Navigate to Gear icon (System) -> LibreELEC.

  2. Select Network on the left-hand side.

  3. Navigate to Advanced Network Settings on right-hand side.

  4. Enable Wait for network before starting Kodi by pressing Enter.

  5. Navigate down to Maximum Wait Time (Sec.).

  6. Change from 10 (default) to 180 seconds.

  7. Select Done.

  8. Press Escape twice to back out to main kodi screen.
Raspberry pi 3

Watch and Record TV

At this point you should be able to watch live TV in Kodi and alsorecord and watch TV programs.

Screen shot of Kodi with active recording of two TV shows simultaneously.

Watch Live TV

  1. Navigate to TV -> Channels.

  2. Select a channel and press Enter.
    The TV show will be displayed with the menu overlayed.

  3. Press Enter to remove menu overlay.

  4. Press M to display lower menu control bar.

  5. Select square icon and press Enter to stop playing.

  6. Press Escape to return to TV menu.

Record TV - Manual VCR Style

To add a recording rule based on channel, start time, and endtime:

  1. Navigate to TV -> Timers and press Enter.

  2. Navigate to Add timer.. and press Enter.

  3. Choose details such as Channel, Start date/time, and End date/time.

  4. Navigate to OK and press Enter.

  5. Press Escape to return to TV menu.

Record TV - Electronic Program Guide

You can also record TV shows using EPG data:

  1. Navigate to TV -> Guide and press Enter.

  2. Select a TV show and press Enter.

  3. Choose a single or multiple recording:

    • To record a single instance of a show choose Record.
    • To create a rule to record multiple instances or episodes of a show choose Add timer.
  4. Adjust record/timer details if desired.

    I suggest changing the Lifetime from the default value of 3 months to forever.

  5. Navigate to OK and press Enter.

  6. Press Escape to return to TV menu.

Watch Recording

  1. Navigate to TV -> Recordings and press Enter.

  2. Select TV show title and press Enter.

  3. Select TV show episode and press Enter.

  4. Press M to display lower menu control bar.

  5. Select square icon and press Enter to stop playing.

  6. Press C to display context menu.

  7. [Optional] Navigate to Delete and press Enter if you wishto delete TV show episode.
    Navigate to Delete and press Enter.

  8. Press Escape to return to TV menu.

View Closed Captions

To display subtitles / closed captions while viewing Live TV or a recording:

  1. Press M to bring up menu.

  2. Navigate right to the Subtitles icon.

  3. Navigate up to Enabled and press Enter to toggle to active.

  4. Press Escape to dismiss the menu

Observations

Following are some of the observations I noted while working with this proof-of-concept PVR.

General

  • Creative x-fi mb2. Duration of testing was 10 days.

  • A total of 96 TV shows were recorded containing over 70 hours of content.

  • Tvheadend proved stable and reliable.

  • On one occasion after staging the PVR for pictures and then re-assembing again, the tvheadend service failed to start. To restart the Tvheadend service I navigated to Add-ons -> My add-ons -> Services -> Tvheadend Server 4.2 and clicked Disable, waited a short time, then clicked Enable.

  • Kodi would occasionally crash/restart when I wasn't actively using it, but this did not adversely affect recordings in progress.

  • Kodi crashed one time while I was trying to watch a channel that had poor reception. Once I re-positioned the aerial for better reception I never again experienced a crash while watching either Live TV or a recording.

  • Over-The-Air Electronic Program Guide data was sparse with only a handful of hours of data in advance. For example on Nov 30th:
    • Channels CICT-HD, CFCN, CityTV, OMNI had ~5 hours.
    • Channel Calgary CBRT-DT appeared to have none
      (correction: data existed for a few days in the future Dec4/5 collected on Nov 30th - weird).
    • Channel YesTV-H had ~16 hours.
      It might be worth investigating a $25 USD/year Schedules Direct subscription to gain access to up to 14 days of Electronic Program Guide data. A good starting point might be this forum post on Using Schedules Direct with TVH. The sd4tvh add-on can be found at GitHub: edit4ever/script.module.sd4tvh along with instructions to configure the Schedules Direct for Tvheadend addon. Note that I downloaded, configured, and used script.module.sd4tvh-0.2.1.zip with no issues.

RPi3 Temperature Under Load

After encountering RPi3 overheating issues under load, I added two aluminum heat sinks. I then used an SSH session to monitor the temperature every 10 seconds with the following command:

From some Internet research I learned that the RPi3 operating temperature range is ~0 to 80 deg C, and that the System-On-a-Chip (SOC) will throttle down at about 80 deg C.

Following are the temperatures under load that I observed in my house which is at 20 degrees Celsius:

RPi3 with
Aluminum
Heatsinks
(°C)
RPi3 with
Aluminum
Case
(°C)
Work Load
5949When not watching and not recording.
6150When not watching but 1 recording in progress.
6354When watching live TV with 0 recordings in progress.
6856When watching live TV with 1 recording in progress.
7159When not watching but 2 recordings in progress.
7663When watching recording with 2 recordings in progress.

From the above it appears that the RPi3 gets very close to the operating maximum of 80 °C when under full load of watching a recording concurrent with two recordings in progress, even with aluminum heatsinks installed.

With the aluminum case which provides passive cooling with parts of the case in contact with the CPU/GPU, RAM, and Ethernet chips, the temperatures are at least 10 °C cooler.

RPi3 Resource Usage Under Load

Following is a screen shot of resource usage when the RPi3 was underthe following load:

  • active recording of two TV shows at the same time
  • active viewing of another previous recording

Screen shot of top command under heavy load:

From the above screen shot we can see that much of the resources available on an RPi3 are being used. The four CPUs are working quite hard because the load average is 2.73. A quad core processor is considered 100% utilized at a load average value of 4.0. Also while there is only 162 MB of RAM shown as used, only 33 MB of RAM is shown as free for other processes. I suspect Kodi with 660 MB virtual memory uses a large internal cache.

These statistics indicate that under this load scenario the RPi3 is managing to keep up, but there is not much in the way of free resources available for additional tasks.

Pros

  • Low cost (less than half the cost of my x86-64 based MythTV PVR)

  • Low 17.5 watt maximum power requirement
    17.5 watts = ( (5 Volts * 2.5 Amp RPi3 power supply) + (5 Volts * 1 Amp HDHomeRun power supply) )Ariana grande - side to side.

  • Supports basic PVR functions of record, play, pause, fast forward, rewind

  • Supports watching one recording while actively recording two TV shows

  • Supports Kodi add-ons for additional Internet stream viewing options

Cons

  • Less stable (Kodi occasionally crashes and restarts, but this does not adversely affect recordings)

  • Limited upgrade options (most RPi3 resources in use under load so adding extra tuners not likely feasible)

  • Less options for skip forward / skip back and slower response compared to MythTV which is virtually instantaneous.

Conclusion

This proof-of concept has shown that these tutorial instructions are a viable way to build a functional PVR using a Raspberry Pi 3, a USB hard drive, and an HDHomeRun Connect network dual tuner.

The PVR as built was able to display a recording while also actively recording two TV shows simultaneously.

While this solution is tempting for its lower cost, my spouse and I have come to appreciate the flexibility, upgradability, and reliability of our Mythbuntu PVR with 4 TV tuners that also supports content streaming via Firefox and Kodi so we have the best of all worlds.

Thanks for reading. I hope you enjoyed this article.

References

While working on this article I found the following references useful:

Appendix A: Trials and Tribulations

Initially the system was not very stable and was prone to hang due to overheating. This was resolved by adding aluminum heatsink cooling fins. Following are descriptions of the events that occurred during my testing:

Date / Timestamp Description
2017-11-30 8:00pmRPi3 was hung after running ~3 hours. A dimmed Kodi TV Recording screen was still displayed. There was no response to keyboard or remote, and I was unable to SSH in. While I did not observe the cause of the hang an hour after it happened (based on still image with time in display) I suspect that the RPi3 overheated. I had to cycle the power get the system working again.
2017-12-01 9:53amKodi crashed and restarted by itself. At the time I was trying to tune in a channel with poor reception and fast forward in a pixelated recording.
2017-12-01 10:17amKodi crashed and restarted by itself. At the time I wasn't doing anything. This Kodi restart did not appear to affect the recordings in progress at the time.
2017-12-02 11:27amWhile viewing Modern Family recording, I tried to view OTA subtitles and couldn't find these (one recording was active at same time). Next I tried to Browse for subtitles. Shortly thereafter the RPi3 hung with a high temperature thermometer icon in the upper right corner of the screen (RPi3 was hot to touch). Uptime was ~25 hours. Had to power off and wait for RPi3 to cool down.
2017-12-02 11:51amOn power-up Kodi complained Tvheadend HTSP Client didn't respond properly. There was no data shown for TV Channels/Guide/Recordings, etc. Powered down again.
2017-12-02 11:53amOn power-up Kodi complained Tvheadend HTSP Client didn't respond properly. There was no data shown for TV Channels/Guide/Recordings, etc. Powered down again. Powered down again and will leave down for longer period.
2017-12-02 12:38pmOn power-up Kodi complained Tvheadend HTSP Client didn't respond properly. Powered down again and will leave for powered off while I contemplate options to reduce the chance of overheating. One theory is that the RPi3 got too hot from powering both RPi3 and USB hard drive. Another more likely theory is that the RPi3 got too hot from high GPU and CPU load.
2017-12-02 1:29pmAdded aluminum heatsink cooling fins to RPi3 GPU/CPU and Ethernet chip. On power-up Kodi complained Tvheadend HTSP Client didn't respond properly. I forced an update of the Tvheadend HTSP Client add-on, rebooted, and finally there was no complaint about Tvheadend HTSP Client.
2017-12-03 11:32amKodi displays same TV screen I left it on previously.
2017-12-04 10:04amI noticed that Kodi was not on the same TV screen I had left it on previously. Because uptime reports 10:04:54 up 1 day, 20:34, it appears that only kodi restarted and not the whole OS.
2017-12-04 11:30amKodi crashed and restarted by itself. At the time I wasn't doing anything. This Kodi restart did not appear to affect the recordings in progress at the time.
2017-12-04 7:13pmChange skin from Kodi Krypton default of Estuary to previous Kodi version default of Confluence. Finally I can enable parsing for closed captions / subtitles in OTA TV shows.
2017-12-05 9:45amKodi displays same TV screen I left it on previously. Uptime reports 09:45:33 up 2 days, 20:15.
2017-12-05 2:38pmKodi not on the TV screen I left it on previously. Because uptime reports 14:39:06 up 3 days, 1:08, it appears that only kodi restarted and not the whole OS.
2017-12-05 3:19pmChange skin back to Kodi Krypton default of Estuary.
2017-12-06 10:24amKodi not on the TV screen I left it on previously. Because uptime reports 10:24:59 up 3 days, 20:54, it appears that only kodi restarted and not the whole OS.
2017-12-06 2:09pmKodi not on the TV screen I left it on previously. Because uptime reports 14:09:21 up 4 days, 39 min, it appears that only kodi restarted and not the whole OS.
2017-12-06 3:51pmKodi displays same TV screen I left it on previously. Uptime reports 15:51:03 up 4 days, 2:20.
2017-12-07 9:43amKodi not on the TV screen I left it on previously. Because uptime reports 09:43:09 up 4 days, 20:12, it appears that only kodi restarted and not the whole OS.
2017-12-07 10:50amKodi crashed and restarted right before my eyes. I hadn't been doing anything on the system for the past hour or so.
2017-12-08 10:04amKodi not on the TV screen I left it on previously. Because uptime reports 10:04:22 up 5 days, 20:34, it appears that only kodi restarted and not the whole OS.
2017-12-08 1:56pmKodi displays same TV screen I left it on previously. Uptime reports 13:56:03 up 6 days, 25 min.
2017-12-08 8:01pmKodi displays same TV screen I left it on previously. Uptime reports 20:01:44 up 6 days, 6:31.
2017-12-09 11:33amKodi not on the TV screen I left it on previously. Because uptime reports 11:33:24 up 6 days, 22:03, it appears that only kodi restarted and not the whole OS.
2017-12-09 2:12pmRPi has now been running successfully for a week. Uptime reports 14:12:34 up 7 days, 42 min. Although Kodi crashes from time to time, it automatically restarts itself and does not adversely affect recordings in progress.
2017-12-10 11:15amAfter I staged the PVR components for pictures and then re-assembled it, the Tvheadend service did not start on boot (much content was missing from the TV menu like Recently played channels and Recent recordings). I tried rebooting the RPi3 but Tvheadend still failed to start.
To restart the Tvheadend service I navigated to Add-ons -> My add-ons -> Services -> Tvheadend Server 4.2 and clicked Disable, waited a short time, then clicked Enable. I'm not sure why the the Tvheadend service failed to start in the first place, but wanted to note how I worked around the issue in case this happens to someone else.
2017-12-22 1:25pmReceived aluminum case with passive cooling. Disassembled RPi3 from plastic case and removed aluminum heatsink cooling fins. Placed RPi3 in aluminum case (be sure to remove microSD card first to make more room for easier installation). After re-assembling all components, the Tvheadend service did not start on boot (much content was missing from the TV menu like Recently played channels and Recent recordings). I did notice that the RPi3 IP Address had changed.
To restart the Tvheadend service I navigated to Add-ons -> My add-ons -> Services -> Tvheadend Server 4.2 and clicked Disable, waited a short time, then clicked Enable.
Added temperatures for aluminum case to RPi3 Temperature Under Load table.
2018-06-10 11:35amNoticed overheat temperature symbol in upper right of display. Next recording on screen was for June 10th 10:30pm so I think it had not been overheated for long. Kodi was unresponsive to key presses. Aluminum case was hot to touch. We had just experienced hot exterior temperatures and I had noticed the interior was 25+ deg C, though this might not have been the cause. Powered off RPi3 to allow case to cool.
2018-06-10 1:00pmCase was now cool. Powered on RPi3. No upcoming recordings shown. Rebooted. Now have upcoming recordings on display.
2018-06-17 3:00am - 6:05amPower outage. On restoration of power the RPi3 PVR restarted, but no upcoming recordings shown on TV screen. I suspect that the HDHomeRun tuner or the Router were not operational when the RPi3 started. Restarting RPi3 fixed problem.
Perhaps a delay is needed on the start of Tvheadend?
2018-06-18 ~11:00amTry adding a 2 second delay to startup of Tvheadend.
Navigate to Add-ons -> My Add-ons -> Services -> Tvheadend Server 4.2 -> Configure. Select DVB on left-hand side. Enable Delay the start of Tvheadend. Set Seconds delay = 2, was 1. Click OK on right-hand side.
2018-06-22 ~11:50amPower outage (~4 minutes). On restoration of power the RPi3 PVR restarted but no upcoming recordings shown on TV screen. I suspect that the 2 second delay was insufficient because the router takes a while to go through it's power up checks before it acquires an IP address and begins dispensing DHCP IP addresses.
Set Seconds delay = 30.
2018-08-16 ~6:49pmPower outage (~2.4 hours). On restoration of power the RPi3 PVR restarted but no upcoming recordings shown on TV screen. It seems that the 30 second delay was not sufficient. After manually rebooting Tvheadend started properly.
2018-08-22 ~6:50pmInstruct RPi3 to wait for network before starting Kodi.
Navigate to Gear icon (System) -> LibreELEC. Select Network on the left-hand side. Navigate to Advanced Network Settings on right-hand side. Enable Wait for network before starting Kodi. Change Maximum Wait Time (Sec.) from 10 to 180. Rebooted to make sure system still works properly. Now need to wait to see what happens with the next power outage.
2018-11-16 ~8:50amWhile testing an Android app that scans the local network for hosts, I noticed that the RPi3 was not responding to a ping. The RPi3 was hot to touch, even though it is Winter here and the ambient temperature in the house is 20 deg C or less. The SiliconDust HDHomeRun was responding to pings.
Further investigation showed Kodi stuck on the TV screen with a time of 10:23pm and a notice that the next recording was for Nov. 14, 2018 at 7:00pm. Hence the RPi3 had been unresponsive for at least two days.
Fix by turning off power for a while and then turning power back on.
2018-11-22 ~7:42pmNoticed that the RPi3 was showing a black screen. I could ping the RPi3 but was unable to login via ssh as there was no service listening on the ssh port.
Fix by turning off power for a while and then turning power back on.
2018-11-29 ~10:07amKodi stuck on TV screen showing 2:14pm and next recording on 11/28/2018 7:00pm. RPi3 not responding to ping.
This problem could be fixed by cycling the power off and on.
At this time I bring to a close the test of using an RPi3 as a PVR.
2019-01-14 ~11:06amUpdate to LibreELEC 8.2.3 and begin testing RPi3 PVR again.
2019-03-31 ~10:15amUpdate to LibreELEC 8.2.5 and add audio_pwm_mode=0 to /flash/config.txt to fix analog audio crackling problem with LibreELEC 8.2.4 and 8.2.5.
2019-04-06 ~11:00amTried a Raspberry Pi 2 (RPi2). Performance was good; however, there was some occasional pixelation when watching a recording while two recordings were in progress. Noticed Closed Captioning (CC) only displayed the first sentence of recent Modern Family recordings, and did not follow along with the dialog.
Switched back to RPi3 from RPi2. Same issue with CC noticed.
Downgraded to LibreELEC 8.2.3 and problem with CC is still there. Tried with recent Kim's Convenience recordings and there was no problem with CC.
Upgraded to LibreELEC 8.2.5 and noticed CC problem with recent Modern Family recordings still exists. There was no problem with CC with recent Kim's Convenience recordings. Hence it appears that there is some issue with LibreELEC 8.2.x and CC and recent Modern Family recordings.
Decided to keep PVR setup as RPi3 with LibreELEC 8.2.5.
2019-04-13 11:45amIncrease recording file retention.
Navigate to Gear icon (System) -> PVR & Live TV settings -> Recording and change Default recording lifetime from default 99 days to maximum of 365 days.
2019-12-05 12:49pmThis PVR continues to run well going on two years now.

For reference I wrap up the trials and tribulations with a screen shot of the top command after running for 7 days:

Happy hobby computing with your Raspberry Pi.

Cueing up some videos to enjoy on my Raspberry Pi yesterday, I made a startling discovery – it wouldn’t play MPEG videos! Has this happened to you? Are you running a RaspBMC media centre How To Make Your Raspberry Pi Into a Home Theater SystemFour weeks on and I’ve been playing with my Raspberry Pi in various ways, from using it to browse the web and standard day-to-day computing tasks to playing around with the various configurations that are.. Read More on your Raspberry Pi computer, or enjoy viewing videos through the desktop? Have you noticed that certain video files cannot be played back?

If so, you’re not alone. Many people have run into trouble with the fact that while the Raspberry Pi will happily transcode high definition videos, it seemingly cannot playback MPEG-2 videos. The reason for this is not a hardware failure or even a software failure, however – rather, it is all down to licencing.

Many media players on Windows, Mac OS X and Linux distributions will allow you to enjoy MPEG-2 without any licencing issues, though – so what is going on? What makes the Raspberry Pi so different that it requires a licence to playback MPEG-2 videos, and how exactly does this license work?

MPEG-2 Licencing & The Raspberry Pi

Other operating systems include the cost of the various codecs within the price of the operating system. In the case of Linux distributions, free versions of media encoders and decoders are used instead. But hang on – the Raspberry Pi runs a Linux distribution, so why isn’t the MPEG-2 codec free?

The answer is simple. The Raspberry Pi is designed to be used for education, and while there are many who enjoy its multimedia capabilities, the developers decided to remove MPEG-2 in order to keep costs down. If you want to use MPEG-2, it is there for you to unlock for a small fee. Of course, you might not want to; after all, there are many uses for a Raspberry Pi The Top 5 Amazing Uses For Your Raspberry Pi ComputerI’ve recently received my Raspberry Pi after a long wait – and I’ve got quite a few plans for it. The problem is, I’m not totally sure which project I want to attempt first. While.. Read More beyond playing back videos.

How To Get The MPEG-2 Licence

In order to install the MPEG-2 licence on your Raspberry Pi, you will first need to find out your device’s serial number. This can be found in the documentation that you included when you first received the computer, but if you don’t have this to hand, don’t worry, you can interrogate the motherboard.

Boot the Pi and open a command prompt in Raspbian. Enter:

The serial number will be displayed last in the resulting text, so copy this down and visit www.raspberrypi.com/mpeg-2-license-key where you will see a short form field in which to enter the serial. Do so and click Add to cart to proceed.

To purchase the MPEG-2 licence you will need to spend $3.50 (or £2.40) – not exactly a fortune, and still pennies next to the $25 price of the computer!

Installing The MPEG-2 Licence On Your Raspberry Pi

With the order made, you will need to wait up to 72 hours for your licence to be received by email (if it doesn’t arrive, you should email the Raspberry Pi people, but the process is usually reliable and efficient).

When the licence key arrives you will find it in a text file as a single line, something similar to:

In order to use this on your Pi, you will need to edit the config.txt file, which can be found in /boot. Simply add the licence as a new line of text as shown above, then save and close.

If you have multiple SD cards for different OS versions – perhaps one for Raspbian Optimize The Power Of Your Raspberry Pi With RaspbianAs befits a man with too much tech on his hands, I’ve been playing with my Raspberry Pi recently, configuring the device so that it works to its fullest potential. It continues to run as.. Read More and one for RaspBMC – you will need to add the licence to each.

Reboot your Raspberry Pi to complete the procedure, and you will then be able to enjoy MPEG-2 videos.

Could I Try a Hacked Codec?

There are – apparently – hacked versions of the codec available online, but really when you consider what might be necessary (for instance, running software to spoof the device serial number) and the fact that the licence is so cheap, this really isn’t worth it.

After all, the Raspberry Pi is a low-cost piece of kit designed with lofty ambitions – to promote IT literacy. The sale of the codec raises money so that the non-profit Raspberry Pi Foundation can work towards its altruistic aims. So don’t go ripping off a codec that costs less than a bottle of beer – pay for it, and help change the world!