jellyfin / jellyfin-androidtv

Android TV Client for Jellyfin
https://jellyfin.org
GNU General Public License v2.0
2.87k stars 489 forks source link

Android TV app on FireTV "Error streaming live tv" error #133

Closed jrbski closed 4 years ago

jrbski commented 5 years ago

Describe the bug

When trying to stream livetv from an HDhomerun using Jellyfin 10.3.7 to AndroidTV app v0.9 sideloaded on an Amazon FireTV, a number of channels fail to stream, and a message stating "Error streaming live tv..." appears, and the app repeatedly retries the stream.

In looking into log,and testing different channels, it appears that 16:9 streams have no issues, but 4:3 streams fail. All channels work properly using Chrome on a windows laptop, and an iPad using Safari.

To Reproduce

  1. Select a local channel streamed in 16:9
  2. Channel streams properly
  3. Select a SD cable channel in 4:3
  4. Stream attempts to open, See error. Stream retries - see error again

Expected behavior

All channels stream to FireTV

Logs

Successful channel logs:

[2019-07-27 10:37:59.996 -04:00] [INF] User policy for "Johnb". EnablePlaybackRemuxing: True EnableVideoPlaybackTranscoding: True EnableAudioPlaybackTranscoding: True
[2019-07-27 10:37:59.996 -04:00] [INF] Profile: "Android-Exo", Path: "http://192.168.11.125", isEligibleForDirectPlay: True, isEligibleForDirectStream: True
[2019-07-27 10:38:00.226 -04:00] [INF] Opening channel stream from "Emby", external channel Id: "hdhr_13"
[2019-07-27 10:38:00.226 -04:00] [INF] Streaming Channel hdhr_13
[2019-07-27 10:38:00.227 -04:00] [INF] GetChannelStream: channel id: "hdhr_13". stream id: "native_3984a7ce11683f727a4c0a1cd85f5930_20ad0206b0a3fa555d35c736b501852f" profile: "native"
[2019-07-27 10:38:00.227 -04:00] [INF] Opening SharedHttpStream Live stream from "http://192.168.11.125:5004/auto/v13"
[2019-07-27 10:38:00.658 -04:00] [INF] Beginning "SharedHttpStream" stream to "/var/lib/jellyfin/transcoding-temp/96178617a33a43c992eae9ae53ba0737.ts"
[2019-07-27 10:38:00.659 -04:00] [INF] Live stream opened after 431.5731ms
[2019-07-27 10:38:00.659 -04:00] [INF] Returning mediasource streamId "native_3984a7ce11683f727a4c0a1cd85f5930_20ad0206b0a3fa555d35c736b501852f", mediaSource.Id "native_3984a7ce11683f727a4c0a1cd85f5930_20ad0206b0a3fa555d35c736b501852f", mediaSource.LiveStreamId null
[2019-07-27 10:38:00.661 -04:00] [INF] Live tv media info probe took "0.0013652" seconds
[2019-07-27 10:38:00.661 -04:00] [INF] Live stream opened: {"Protocol":"Http","Id":"native_3984a7ce11683f727a4c0a1cd85f5930_20ad0206b0a3fa555d35c736b501852f","Path":"https://127.0.0.1:8920/LiveTv/LiveStreamFiles/96178617a33a43c992eae9ae53ba0737/stream.ts","Type":"Default","Container":"mpegts","IsRemote":false,"ReadAtNativeFramerate":false,"IgnoreDts":true,"IgnoreIndex":false,"GenPtsInput":false,"SupportsTranscoding":true,"SupportsDirectStream":true,"SupportsDirectPlay":false,"IsInfiniteStream":true,"RequiresOpening":true,"RequiresClosing":true,"LiveStreamId":"a17c75760a04e99b68cf766e11316e1c_09efa0d56b934a82adec00a87b837fb0_native_3984a7ce11683f727a4c0a1cd85f5930_20ad0206b0a3fa555d35c736b501852f","BufferMs":0,"RequiresLooping":false,"SupportsProbing":true,"MediaStreams":[{"Codec":"mpeg2video","TimeBase":"1/90000","CodecTimeBase":"1001/30000","VideoRange":"SDR","DisplayTitle":"480I MPEG2VIDEO","IsInterlaced":true,"BitRate":2000000,"RefFrames":1,"IsDefault":false,"IsForced":false,"Height":480,"Width":704,"AverageFrameRate":29.97003,"RealFrameRate":29.97003,"Profile":"Main","Type":"Video","AspectRatio":"16:9","Index":-1,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"PixelFormat":"yuv420p","Level":8,"IsAnamorphic":false},{"Codec":"ac3","CodecTag":"AC-3","TimeBase":"1/90000","CodecTimeBase":"1/48000","DisplayTitle":"Dolby Digital 5.1","IsInterlaced":false,"ChannelLayout":"5.1","BitRate":448000,"Channels":6,"SampleRate":48000,"IsDefault":false,"IsForced":false,"Type":"Audio","Index":-1,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Level":0}],"Formats":[],"Bitrate":2448000,"RequiredHttpHeaders":{},"AnalyzeDurationMs":3000}
[2019-07-27 10:38:00.662 -04:00] [INF] User policy for "Johnb". EnablePlaybackRemuxing: True EnableVideoPlaybackTranscoding: True EnableAudioPlaybackTranscoding: True
[2019-07-27 10:38:00.663 -04:00] [INF] Profile: "Android-Exo", Path: "https://127.0.0.1:8920/LiveTv/LiveStreamFiles/96178617a33a43c992eae9ae53ba0737/stream.ts", isEligibleForDirectPlay: True, isEligibleForDirectStream: True
[2019-07-27 10:38:00.663 -04:00] [INF] Profile: "Android-Exo", Path: "https://127.0.0.1:8920/LiveTv/LiveStreamFiles/96178617a33a43c992eae9ae53ba0737/stream.ts", isEligibleForDirectPlay: True, isEligibleForDirectStream: True

Failed Channel Logs:

[2019-07-27 10:37:47.707 -04:00] [INF] User policy for "Johnb". EnablePlaybackRemuxing: True EnableVideoPlaybackTranscoding: True EnableAudioPlaybackTranscoding: True
[2019-07-27 10:37:47.708 -04:00] [INF] Profile: "Android-Exo", Path: "http://192.168.11.125", isEligibleForDirectPlay: True, isEligibleForDirectStream: True
[2019-07-27 10:37:47.979 -04:00] [INF] Opening channel stream from "Emby", external channel Id: "hdhr_120"
[2019-07-27 10:37:47.979 -04:00] [INF] Streaming Channel hdhr_120
[2019-07-27 10:37:47.980 -04:00] [INF] GetChannelStream: channel id: "hdhr_120". stream id: "native_d71b1ffab83acc66badba188b6eeede2_20ad0206b0a3fa555d35c736b501852f" profile: "native"
[2019-07-27 10:37:47.981 -04:00] [INF] Opening SharedHttpStream Live stream from "http://192.168.11.125:5004/auto/v120"
[2019-07-27 10:37:48.412 -04:00] [INF] Beginning "SharedHttpStream" stream to "/var/lib/jellyfin/transcoding-temp/6e90cee319a848f0b5fd29d99173e354.ts"
[2019-07-27 10:37:48.413 -04:00] [INF] Live stream opened after 432.9629ms
[2019-07-27 10:37:48.414 -04:00] [INF] Returning mediasource streamId "native_d71b1ffab83acc66badba188b6eeede2_20ad0206b0a3fa555d35c736b501852f", mediaSource.Id "native_d71b1ffab83acc66badba188b6eeede2_20ad0206b0a3fa555d35c736b501852f", mediaSource.LiveStreamId null
[2019-07-27 10:37:48.416 -04:00] [INF] Live tv media info probe took "0.0015365" seconds
[2019-07-27 10:37:48.417 -04:00] [INF] Live stream opened: {"Protocol":"Http","Id":"native_d71b1ffab83acc66badba188b6eeede2_20ad0206b0a3fa555d35c736b501852f","Path":"https://127.0.0.1:8920/LiveTv/LiveStreamFiles/6e90cee319a848f0b5fd29d99173e354/stream.ts","Type":"Default","Container":"mpegts","IsRemote":false,"ReadAtNativeFramerate":false,"IgnoreDts":true,"IgnoreIndex":false,"GenPtsInput":false,"SupportsTranscoding":true,"SupportsDirectStream":true,"SupportsDirectPlay":false,"IsInfiniteStream":true,"RequiresOpening":true,"RequiresClosing":true,"LiveStreamId":"a17c75760a04e99b68cf766e11316e1c_09efa0d56b934a82adec00a87b837fb0_native_d71b1ffab83acc66badba188b6eeede2_20ad0206b0a3fa555d35c736b501852f","BufferMs":0,"RequiresLooping":false,"SupportsProbing":true,"MediaStreams":[{"Codec":"mpeg2video","TimeBase":"1/90000","CodecTimeBase":"1001/30000","VideoRange":"SDR","DisplayTitle":"480I MPEG2VIDEO","IsInterlaced":true,"RefFrames":1,"IsDefault":false,"IsForced":false,"Height":480,"Width":528,"AverageFrameRate":29.97003,"RealFrameRate":29.97003,"Profile":"Main","Type":"Video","AspectRatio":"4:3","Index":-1,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"PixelFormat":"yuv420p","Level":8,"IsAnamorphic":false},{"Codec":"ac3","CodecTag":"AC-3","TimeBase":"1/90000","CodecTimeBase":"1/48000","DisplayTitle":"Dolby Digital stereo","IsInterlaced":false,"ChannelLayout":"stereo","BitRate":192000,"Channels":2,"SampleRate":48000,"IsDefault":false,"IsForced":false,"Type":"Audio","Index":-1,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Level":0}],"Formats":[],"Bitrate":192000,"RequiredHttpHeaders":{},"AnalyzeDurationMs":3000}
[2019-07-27 10:37:48.418 -04:00] [INF] User policy for "Johnb". EnablePlaybackRemuxing: True EnableVideoPlaybackTranscoding: True EnableAudioPlaybackTranscoding: True
[2019-07-27 10:37:48.418 -04:00] [INF] Profile: "Android-Exo", Path: "https://127.0.0.1:8920/LiveTv/LiveStreamFiles/6e90cee319a848f0b5fd29d99173e354/stream.ts", isEligibleForDirectPlay: True, isEligibleForDirectStream: True
[2019-07-27 10:37:48.419 -04:00] [INF] Profile: "Android-Exo", Path: "https://127.0.0.1:8920/LiveTv/LiveStreamFiles/6e90cee319a848f0b5fd29d99173e354/stream.ts", isEligibleForDirectPlay: True, isEligibleForDirectStream: True
[2019-07-27 10:37:53.722 -04:00] [INF] Playback stopped reported by app "AndroidTV" "0.9.0a" playing "Discovery East". Stopped at "0" ms
[2019-07-27 10:37:53.723 -04:00] [INF] Live stream "native_d71b1ffab83acc66badba188b6eeede2_20ad0206b0a3fa555d35c736b501852f" consumer count is now 0
[2019-07-27 10:37:53.724 -04:00] [INF] Closing live stream "a17c75760a04e99b68cf766e11316e1c_09efa0d56b934a82adec00a87b837fb0_native_d71b1ffab83acc66badba188b6eeede2_20ad0206b0a3fa555d35c736b501852f"
[2019-07-27 10:37:53.724 -04:00] [INF] Closing SharedHttpStream

Screenshots

System (please complete the following information):

Additional context

I had also been testing Beta5 of the Android app, and did not see similar errors streaming HDhomerun channels in that version of the app.

anthonylavado commented 5 years ago

I think @thornbill said there’s good success if you try turning on VLC in the settings. I don’t remember if you have to have it installed as well, or if we bundle it.

jrbski commented 5 years ago

Enabling VLC in the AndroidTV app does allow the stream to work correctly. I did confirm that I do not have the VLC app installed on my FireTV, so it appears to be bundled in (at least in the v0.9 app).

Thanks for the suggestion @anthonylavado !

As a note, I have found I need to offset the sound by -200 or -300 for the sound to be sync'd to video using VLC. It looks like VLC may have been enabled by default in Beta5... Now that I enabled VLC, the controls are the same as I was using in Beta5.

Artiume commented 5 years ago

I'm experiencing the same issue on Android phone. Would a better fix be to have the server transcode the stream for the clients?

anthonylavado commented 4 years ago

I'm experiencing the same issue on Android phone. Would a better fix be to have the server transcode the stream for the clients?

@Artiume Android phone is structured differently, but there’s work going on there for a better player.

Artiume commented 4 years ago

Cool. I did some digging and found this. This was what I was thinking as a server side solution.

https://github.com/jellyfin/jellyfin/issues/1202

dragon2611 commented 4 years ago

This, #1202 and PR #2160 for the server look interesting to me.

With Android liveTV often throws an error about unsupported stream, casting to a chromecast often just results in a Black screen.

The same channel will often play in chrome on the same device if I go via the web-ui.

Artiume commented 4 years ago

Yeah I have the same issue and I did PR #2160 to try and fix it but transcoding live streams is broken for Android and AndroidTV so no channels work lol.

@anthonylavado The issue with ffmpeg, I compared the two logs and the failing ffmpeg build didn't pass any bitrate, the successful one used "BitRate":2000000 Would that fall on ffprobe or ffmpeg? I couldn't find anything else wrong.

thornbill commented 4 years ago

In the app settings for Android TV have you tried enabling VLC in the live tv section? That seems to do the trick for me. This was the default at one point. We should probably change that back.

Artiume commented 4 years ago

Hey Bill, testing VLC mode with PR #2160 enabled doesn't seem to work. I think it's because VLC should allow for directplay but the PR (if enabled for the user) will enforce transcoding and breaks the stream, even for VLC. I'm gonna post what I've found. This should probably go under its appropriate Android ticket and not this one, but I imagine the ffmpeg issue between Android and Android TV have the same root cause since they're both wrappers and it's easier for me to troubleshoot with my mobile device. Comparing the logs, Android w/ Chrome will maintain the stream as an m3u8 and continues to use .ts segments whereas the Android App attempts to create an mkv container.

Android with Chrome

http://domain.com/videos/32204-717d-a4a6-684a-75523db/live.m3u8?DeviceId=TW96a81LjAgKExpbnV4OyB2lkIDguMC4wOyBHOTMwUCkgQXBwbGVXZWJLaXQvNTM3LjM2IChLSNTCwgbGlrZSBHZWNrbQ2hyb21lLzc4LjAuMzkwNC4xMDggTW9iaWxlIFNhZmFyaS81MzcuMzZ8MTDU1NTgwNDQ3Mw11&MediaSourceId=2be21c2561862a97edf0be4db&VideoCodec=h264&AudioCodec=mp3,aac&AudioStreamIndex=-1&VideoBitrate=8000000&AudioBitrate=135750&PlaySessionId=464a9621b4254200befa7439121eaf76&LiveStreamId=a17c75760a04e99b68cf766e11316e1c_09efa0d56b934a82adec00a87b837fb0_2be21c256186162a936a407edf0be4db&TranscodingMaxAudioChannels=2&RequireAvc=false&SegmentContainer=ts&MinSegments=1&BreakOnNonKeyFrames=False&h264-profile=high,main,baseline,constrainedbaseline,high10&h264-level=51&TranscodeReasons=ContainerNotSupported,VideoCodecNotSupported,AudioCodecNotSupported&allowVideoStreamCopy=false&allowAudioStreamCopy=false

Android App

http://domain.com/videos/3212c717d-a4a6-684a-7505fe0523db/stream.mkv?DeviceId=60de542cb23644&MediaSourceId=2be21c25618936a407edf0be4db&VideoCodec=h264,vp8,vp9&AudioCodec=mp3,aac,opus,flac,vorbis&AudioStreamIndex=-1&VideoBitrate=8000000&AudioBitrate=135750&PlaySessionId=c07689192b4e4c98a61bb1f452972b88&LiveStreamId=a17c75760a04e99b68cf766e11316e1c_09efa0d56b934a82adec00a87b837fb0_2be21c256186162a936a407edf0be4db&TranscodingMaxAudioChannels=2&CopyTimestamps=true&RequireAvc=false&h264-profile=high,main,baseline,constrainedbaseline&h264-level=41&TranscodeReasons=ContainerBitrateExceedsLimit&allowVideoStreamCopy=false&allowAudioStreamCopy=false

Another part I found interesting is this is missing from the Android App. &TranscodeReasons=ContainerNotSupported,VideoCodecNotSupported,AudioCodecNotSupported& I'm used to this tag showing up in every Live Stream because of PR #2160.

This is another odd bit for the Android App stream. No Limit is set, so I'm not sure where this is cropping up from &TranscodeReasons=ContainerBitrateExceedsLimit Looking inside MediaBrowser.Model/Session/TranscodingInfo.cs, i've found this

    public enum TranscodeReason
    {
        ContainerNotSupported = 0,
        VideoCodecNotSupported = 1,
        AudioCodecNotSupported = 2,
        ContainerBitrateExceedsLimit = 3,

What if the transcode reason logic is summing their return values instead of properly segregating them? Only thing I can think of for the bitrate exceeding flag to be thrown like that.

Copy Timestamps is also inside the app stream only, but I'm not sure if it's an issue or not &CopyTimestamps=true&

If the Android app and TV app are truly different, I'll post only ATV results from now on :) .

Artiume commented 4 years ago

I can't test it until I have access to my fire stick but I was able to fix the live tv stream on android by substituting .ts for .mkv in the ffmpeg command. I'll start digging in the code in the stream builder to see what I can find

Edit: Comparing my issue to the original issue, I think I hijacked this thread.

stale[bot] commented 4 years ago

This issue has gone 120 days without comment. To avoid abandoned issues, it will be closed in 21 days if there are no new comments. If you're the original submitter of this issue, please comment confirming if this issue still affects you in the latest release or master branch, or close the issue if it has been fixed. If you're another user also affected by this bug, please comment confirming so. Either action will remove the stale label. This bot exists to prevent issues from becoming stale and forgotten. Jellyfin is always moving forward, and bugs are often fixed as side effects of other changes. We therefore ask that bug report authors remain vigilant about their issues to ensure they are closed if fixed, or re-confirmed - perhaps with fresh logs or reproduction examples - regularly. If you have any questions you can reach us on Matrix or Social Media.