kiall / android-tvheadend

Android + TV Headend + TV Input Framework
Apache License 2.0
194 stars 62 forks source link

Stuttering while audio track changes on the fly #149

Open xi784 opened 7 years ago

xi784 commented 7 years ago

Example: Change from commercials to movie from stereo 2.0 to ac3 5.1, video begins to stuttering, channel change helps.

kiall commented 7 years ago

Could you record a piece of video that does this?

I've not seen this happen on any of my channels, but a few folks have reported it.

Details on how to record @ https://github.com/kiall/android-tvheadend/wiki/Muxdump

Does it recover on its own, or just continue stuttering?

xi784 commented 7 years ago

Just continue stuttering or gets totally freezed.

Will take a muxdump on the next break.

xi784 commented 7 years ago

ok muxdump will be a problem because CA in use.

kiall commented 7 years ago

Humm, my understanding is it'll be decrypted by the to e you record the muxdump? I think.

xi784 commented 7 years ago

If i try to record the mux directly, ca doesn´t get active. What makes sense, because TVHeadend doesn´t know the pid.

xi784 commented 7 years ago

Will take a dump via streamrecording, maybe that helps

kiall commented 7 years ago

Yea, try using the "pass" profile for DVR? It might work, I've not tried! Anything is better than nothing I'm sure though :)

Failing that, access to your TVHeadend server for a few hours if remote access can work? (With some pointers to content that does this. .)

xi784 commented 7 years ago

got it: https://drive.google.com/drive/folders/0BxP1VJf8kaXoNU1SQkFDbHFiZlE?usp=sharing On 1:00 +/- it changes from stereo to 5.1

xi784 commented 7 years ago

That would be not a problem, would have only to persuade my special "Telekom Hybrid Router" :) Tomorrow i will set this up, for future problems.

kiall commented 7 years ago

Okay, so I can see this sample definatly contains a layout switch:

# ffprobe -select_streams a -show_frames sample.ts 2>&1 | grep channel_layout | sort | uniq -c
   1126 channel_layout=5.1(side)
   1997 channel_layout=stereo

Both sides of the switch appear to play OK individually (convincing TVHeadend to pass through the right parts of this stream without editing the file was... challenging), however when played continuously across the boundary, it's clearly stuttering.

The app log little more than this:

03-11 17:56:00.143 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 83488000, got 83232011]
03-11 17:56:00.529 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 83616011, got 83360011]
03-11 17:56:00.911 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 83744011, got 83488011]
03-11 17:56:01.297 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 83872011, got 83616011]
03-11 17:56:01.674 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 84000011, got 83744011]
03-11 17:56:02.059 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 84128011, got 83872011]
03-11 17:56:02.446 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 84256011, got 84000011]
03-11 17:56:02.828 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 84384011, got 84128011]
03-11 17:56:03.214 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 84512011, got 84256011]
03-11 17:56:03.597 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 84640011, got 84384011]
03-11 17:56:03.982 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 84768011, got 84512011]
03-11 17:56:04.366 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 84896011, got 84640011]
03-11 17:56:04.752 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 85024011, got 84768011]
03-11 17:56:05.140 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 85152011, got 84896011]
03-11 17:56:05.517 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 85280011, got 85024011]
03-11 17:56:05.902 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 85408011, got 85152011]
03-11 17:56:06.287 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 85536011, got 85280011]
03-11 17:56:06.671 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 85664011, got 85408011]
03-11 17:56:07.057 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 85792011, got 85536011]
03-11 17:56:07.440 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 85920011, got 85664011]
03-11 17:56:07.818 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 86048011, got 85792011]
03-11 17:56:08.205 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 86176011, got 85920011]
03-11 17:56:08.589 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 86304011, got 86048011]
03-11 17:56:08.973 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 86432011, got 86176011]
03-11 17:56:09.362 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 86560011, got 86304011]
03-11 17:56:09.739 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 86688011, got 86432011]
03-11 17:56:10.125 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 86816011, got 86560011]
03-11 17:56:10.513 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 86944011, got 86688011]
03-11 17:56:10.900 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 87072011, got 86816011]
03-11 17:56:11.275 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 87200011, got 86944011]
03-11 17:56:11.658 3466-14014/ie.macinnes.tvheadend E/AudioTrack: Discontinuity detected [expected 87328011, got 87072011]
xi784 commented 7 years ago

No one said it would be easy, but it had to be done.. :)

Vispen74 commented 7 years ago

I have this problem as well, using TVheadend Live Channels on a Sony Bravia XD8505 with Android-TV 6.01 as frontend. I´m loosing the HW acceleration every time commercial breaks movies. Channel change will bring it back. Using a Ubuntu server with Tvheadend 4.1-2405 as backend.

kiall commented 7 years ago

So, what devices are you two on? Shield? Nexus Player? etc

kiall commented 7 years ago

Also - Can you give this build a go? Once installed, re-run setup to get to the preferences, then disable the FFMpeg Audio Renderer, and see if that helps? It seems to have helped for me:

https://dl.dropboxusercontent.com/u/1400487/VID_20170311_183826.mp4

http://jenkins.macinnes.ie/job/android-tvheadend/job/master/52/ - download the "-release.apk", not the "-debug.apk"

Assuming it works for you too, and not just on the recorded sample I have, I can start digging into the issue...

Vispen74 commented 7 years ago

The TV is occupied by family this evening, will give the build ago tomorrow and report back.

xi784 commented 7 years ago

Have checked this, Nexus Player and shild as well.. ok Kiall, i will test it

xi784 commented 7 years ago

if you need access to my tvheadend, we need to pm .. e.g. skype, hangouts or something else.

Channel RTL2 is perfect for testing now.

kiall commented 7 years ago

I think I'm OK without access, the muxdump you provided reproduces the issue, just want to get a sanity check before spending more time chasing a possible red herring ;)

xi784 commented 7 years ago

hehe .. ok :)

kiall commented 7 years ago

Possibly related to #117

xi784 commented 7 years ago

Ok.. when disable the FFMpeg Audio Renderer: On Nexus Player only get Streaming by channels with stereo but without audio Channels with 5.1 dont start.

On Shield the same but streaming starts with "unsupported audio track" on 5.1 content.

kiall commented 7 years ago

Humm. Could you grab some logcat's from the devices as you change onto these channels? (annotated with what device and what the issue was!)

kiall commented 7 years ago

Or - If you know how IRC works, join #android-tvheadend on FreeNode and can PM me server details there to have a check myself - that said, I likely won't get to login + test today...

xi784 commented 7 years ago

ac3_new.zip Shield log - mediacodecinfo unsupported while ffmpeg disabled

Did some channel changes for more details

kiall commented 7 years ago

So, this appears to be an ExoPlayer (or FFMpeg?) bug, I've filed a bug with ExoPlayer google/ExoPlayer#2552.

For now, as a workaround, if your Android Box, TV itself, or audio receiver (if you have one) supports native AC3 decoding, then running through the app setup, disabling the FFMpeg extension in the settings, and rebooting for the changed setting to take effect should workaround the issue.

xi784 commented 7 years ago

and reproduces too on:

kiall commented 7 years ago

5e9e468052bfda71d886b8d05157600d1fbec9f2 re-orders things a little, if you're on a device with a native AC3 decoder, that will now be used instead of FFmpeg, and this issue should disappear.

However, very few devices actually ship an AC-3 decoder (even the more $$ ones, like the Shield)

xi784 commented 7 years ago

Think we have to reopen it, same issue on layout switch 2ch to 5.1 and back again. Picture gets stuttering and freeze.

Channel change helps and passthrough audio.

sample.ts approx sec 40~ https://drive.google.com/file/d/0BxP1VJf8kaXoSkpidGFpMURkMzg/view?usp=sharing

using develop build #.23