SOLVED (ish): Pi3/MythLight/Stretch 1080i MPEG-2 OTA ATSC Playback Stutters
Posted: Sat Mar 30, 2019 8:50 pm
Hello everyone,
First a hat tip to Issac and the MythTV team. I realized I have been enjoying MythTV for at least 15 years now.
MY ISSUE: 1080i broadcast sources (stable, very few errors) do not play back smoothly on a Pi3 with MythLight.
PI HARDWARE:
pi@raspberrypi:~ $ awk '/^Revision/ {sub("^1000", "", $3); print $3}' /proc/cpuinfo
a02082
Which Google tells me is:
a02082 Q1 2016 3 Model B 1.2 1 GB (Mfg by Sony)
GPU MEMORY
I've tried 384, 320 and 256. It is now back at 256MB as none of it had any measurable affect.
From /boot/config.txt:
gpu_mem=256
BACKGROUND:
I recently moved and my .29 combined backend/frontend is no longer in the living room so I decided to set up a Raspberry Pi 3 frontend. It went surprisingly well and came together quickly using the MythLight packages referenced on the wiki/MythTV_Light
AUDIO IS PASS-THRU
I have my AC3 passing through to my soundbar over an optical SPDIF cable, and after a bit of tweaking all is well there. The Pi is connected over 100 Mbps Full Duplex ethernet to the closet where the backend is located.
MPEG-2 KEY IS INSTALLED AND CONFIRMED
I have purchased, installed and confirmed the MPEG-2 playback key.
pi@raspberrypi:~ $ !v
vcgencmd codec_enabled MPG2
MPG2=enabled
USING OPENMAX HIGH PROFILE
I have tried both OPENMAX Normal and OPENMAX High. It makes no difference on my system.
GENERAL OPERATION OF MENUS ETC IS OK - PLAYBACK STATS ARE NOT RIGHT
General operation and navigation of the system is fine, but playback is problematic. I only have OTA stations and one of them is 720p. Playback of 720p is generally smooth and occasionally it falls behind 60FPS but usually only to 58 and then immediately recoveres (using the Menu -> Playback -> Playback Stats option when watching a recording). I would say it is totally normal and acceptable.
1080i SOURCES DO NOT PLAY SMOOTHLY
All of my other source channels are in 1080i30 MPEG-2. Looking at the stats during playback, the FPS is NOT reaching 30 very often. Occasionally it meets or exceeds 30 but generally it is running in the 23-25 fps range and results in very jerky video due to the dropped frames.
RUNNING RASPBIAN STRETCH FROM STOCK NOOBS NETWORK INSTALL FROM LAST TWO WEEKS
I am running:
pi@raspberrypi:~ $ cat /etc/issue
Raspbian GNU/Linux 9 \n \l
From a stock Noobs network install.
pi@raspberrypi:~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 9.8 (stretch)
Release: 9.8
Codename: stretch
KERNEL IS UPDATED TO 4.19 VIA RPI-UPDATE
I have updated the firmware and kernel with rpi-update per the MythLight/MythTV on Pi wiki:
(I did also try it on a fresh install without using rpi-update and still had the same issue with the original kernel and firmware)
pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.19.30-v7+ #1209 SMP Tue Mar 26 13:14:20 GMT 2019 armv7l GNU/Linux
PERFORMANCE GOVERNOR IS SET
The performance governor is set:
pi@raspberrypi:~ $ for GOV in /sys/devices/system/cpu/cpu[0-9]*/cpufreq/scaling_governor; do cat $GOV; done
performance
performance
performance
performance
THE TV & CEC
The TV is a 2013 vintage Sony LCD and the output to the TV is 1080p. I have tried dropping the output resolution of the Pi to 720p60 but it makes no difference in the playback of 1080i content. The TV correctly reports the source as 720p but the dropped frames issue is identical.
I am using CEC and the stock Sony remote to control it (after programming a few of the oddly named Sony button press results in the Myth keybindings config). Works fine.
The soundbar is a Vizio 2.1 system connected over optical SPDIF and works fine with stereo or AC3 pass-through.
I HAVE TRIED VARIOUS ALSA SOUND CONFIGS AND NULL
I went back to stereo output via Also to the soundbar over optical. It made no difference in frame rate (wondering if some kind of audio processing delay was causing the video to fall behind).
I used the NULL sound device to see if removing audio would make a difference, there was no change, same 24-26 FPS performance on 1080i playback.
I have now re-enabled my AC3 pass-through. I do not believe audio is implicated due to the above tests.
KODI & SANDISK CARD
I have not installed Kodi to try it, but I have read of multiple other people reporting 1080i playback issues on Raspbian with Myth that can use a Kodi install and play the same source files without issue. I could do this but I do not believe this is a hardware issue. I am using a Canakit Pi3 with the case and heatsinks installed and a Sumsung Evo SD card and power supply they provided. All looks good. I did try a separate Sandisk high performance card when I did the clean install and it made no difference.
THE STATS DON'T LOOK RIGHT TO ME - POSSIBLY A FEW CLUES
Looking at the screen when the playback stats are up, they don't look right. I will try and take some photos on my phone and include them later today.
When watching 720p60 content the buffer size is 8MB and runs 50% full. 720p content is generally stable and smooth.
When watching 1080i30 content, the buffer size reports as 16MB and reports as being 99% free (if I am reading it correctly). Either that or it is 99% full, but I believe the wording indicates the buffer is free.
The storage to buffer throughput for 1080i30 reports as 45-50Mbps. The buffer to decoder throughput is in the 8-14 Mbps range. So the data appears to be arriving at the Pi just fine, with a few seconds in reserve, but the buffer to deoder throughput looks suspect to me as a video knowledgeable person (but not developer). I am in the Vancouver BC market and out OTA channels do not carry sub channels. I know the bit rates can run up to 17 Mbps for a single program on the video PID which makes me think the data isn't getting out of the buffer and in to the decoder fast enough. Just a hunch.
I am also aware that the 24-25 FPS playback rate range that I am seeing is very close to european broadcast frame rates (1080i25 being the norm IIRC). Being that the Pi comes from Europe I'm curious if someone has accidentally hard coded something in relation to 1080i25 or isn't properly detecting 1080i30 content. Just a shot in the dark, but it made me raise an eyebrow.
I am also aware people on earlier versions of Raspbian did not have this issue, which again makes me suspicious that something has changed (supported by the reports Kodi on OpenELEC and others can play the same recordings [but not yet shown by me, TBD]).
If anyone can provide any suggestions on where to go from here, I would greatly appreciate it.
I'll be prompt and as thorough as I can in answering background questions and trying things.
Thanks,
-Jeff
First a hat tip to Issac and the MythTV team. I realized I have been enjoying MythTV for at least 15 years now.
MY ISSUE: 1080i broadcast sources (stable, very few errors) do not play back smoothly on a Pi3 with MythLight.
PI HARDWARE:
pi@raspberrypi:~ $ awk '/^Revision/ {sub("^1000", "", $3); print $3}' /proc/cpuinfo
a02082
Which Google tells me is:
a02082 Q1 2016 3 Model B 1.2 1 GB (Mfg by Sony)
GPU MEMORY
I've tried 384, 320 and 256. It is now back at 256MB as none of it had any measurable affect.
From /boot/config.txt:
gpu_mem=256
BACKGROUND:
I recently moved and my .29 combined backend/frontend is no longer in the living room so I decided to set up a Raspberry Pi 3 frontend. It went surprisingly well and came together quickly using the MythLight packages referenced on the wiki/MythTV_Light
AUDIO IS PASS-THRU
I have my AC3 passing through to my soundbar over an optical SPDIF cable, and after a bit of tweaking all is well there. The Pi is connected over 100 Mbps Full Duplex ethernet to the closet where the backend is located.
MPEG-2 KEY IS INSTALLED AND CONFIRMED
I have purchased, installed and confirmed the MPEG-2 playback key.
pi@raspberrypi:~ $ !v
vcgencmd codec_enabled MPG2
MPG2=enabled
USING OPENMAX HIGH PROFILE
I have tried both OPENMAX Normal and OPENMAX High. It makes no difference on my system.
GENERAL OPERATION OF MENUS ETC IS OK - PLAYBACK STATS ARE NOT RIGHT
General operation and navigation of the system is fine, but playback is problematic. I only have OTA stations and one of them is 720p. Playback of 720p is generally smooth and occasionally it falls behind 60FPS but usually only to 58 and then immediately recoveres (using the Menu -> Playback -> Playback Stats option when watching a recording). I would say it is totally normal and acceptable.
1080i SOURCES DO NOT PLAY SMOOTHLY
All of my other source channels are in 1080i30 MPEG-2. Looking at the stats during playback, the FPS is NOT reaching 30 very often. Occasionally it meets or exceeds 30 but generally it is running in the 23-25 fps range and results in very jerky video due to the dropped frames.
RUNNING RASPBIAN STRETCH FROM STOCK NOOBS NETWORK INSTALL FROM LAST TWO WEEKS
I am running:
pi@raspberrypi:~ $ cat /etc/issue
Raspbian GNU/Linux 9 \n \l
From a stock Noobs network install.
pi@raspberrypi:~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 9.8 (stretch)
Release: 9.8
Codename: stretch
KERNEL IS UPDATED TO 4.19 VIA RPI-UPDATE
I have updated the firmware and kernel with rpi-update per the MythLight/MythTV on Pi wiki:
(I did also try it on a fresh install without using rpi-update and still had the same issue with the original kernel and firmware)
pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.19.30-v7+ #1209 SMP Tue Mar 26 13:14:20 GMT 2019 armv7l GNU/Linux
PERFORMANCE GOVERNOR IS SET
The performance governor is set:
pi@raspberrypi:~ $ for GOV in /sys/devices/system/cpu/cpu[0-9]*/cpufreq/scaling_governor; do cat $GOV; done
performance
performance
performance
performance
THE TV & CEC
The TV is a 2013 vintage Sony LCD and the output to the TV is 1080p. I have tried dropping the output resolution of the Pi to 720p60 but it makes no difference in the playback of 1080i content. The TV correctly reports the source as 720p but the dropped frames issue is identical.
I am using CEC and the stock Sony remote to control it (after programming a few of the oddly named Sony button press results in the Myth keybindings config). Works fine.
The soundbar is a Vizio 2.1 system connected over optical SPDIF and works fine with stereo or AC3 pass-through.
I HAVE TRIED VARIOUS ALSA SOUND CONFIGS AND NULL
I went back to stereo output via Also to the soundbar over optical. It made no difference in frame rate (wondering if some kind of audio processing delay was causing the video to fall behind).
I used the NULL sound device to see if removing audio would make a difference, there was no change, same 24-26 FPS performance on 1080i playback.
I have now re-enabled my AC3 pass-through. I do not believe audio is implicated due to the above tests.
KODI & SANDISK CARD
I have not installed Kodi to try it, but I have read of multiple other people reporting 1080i playback issues on Raspbian with Myth that can use a Kodi install and play the same source files without issue. I could do this but I do not believe this is a hardware issue. I am using a Canakit Pi3 with the case and heatsinks installed and a Sumsung Evo SD card and power supply they provided. All looks good. I did try a separate Sandisk high performance card when I did the clean install and it made no difference.
THE STATS DON'T LOOK RIGHT TO ME - POSSIBLY A FEW CLUES
Looking at the screen when the playback stats are up, they don't look right. I will try and take some photos on my phone and include them later today.
When watching 720p60 content the buffer size is 8MB and runs 50% full. 720p content is generally stable and smooth.
When watching 1080i30 content, the buffer size reports as 16MB and reports as being 99% free (if I am reading it correctly). Either that or it is 99% full, but I believe the wording indicates the buffer is free.
The storage to buffer throughput for 1080i30 reports as 45-50Mbps. The buffer to decoder throughput is in the 8-14 Mbps range. So the data appears to be arriving at the Pi just fine, with a few seconds in reserve, but the buffer to deoder throughput looks suspect to me as a video knowledgeable person (but not developer). I am in the Vancouver BC market and out OTA channels do not carry sub channels. I know the bit rates can run up to 17 Mbps for a single program on the video PID which makes me think the data isn't getting out of the buffer and in to the decoder fast enough. Just a hunch.
I am also aware that the 24-25 FPS playback rate range that I am seeing is very close to european broadcast frame rates (1080i25 being the norm IIRC). Being that the Pi comes from Europe I'm curious if someone has accidentally hard coded something in relation to 1080i25 or isn't properly detecting 1080i30 content. Just a shot in the dark, but it made me raise an eyebrow.
I am also aware people on earlier versions of Raspbian did not have this issue, which again makes me suspicious that something has changed (supported by the reports Kodi on OpenELEC and others can play the same recordings [but not yet shown by me, TBD]).
If anyone can provide any suggestions on where to go from here, I would greatly appreciate it.
I'll be prompt and as thorough as I can in answering background questions and trying things.
Thanks,
-Jeff