Bug #3379

No video (or crash) when playing HD content in TS (MPEG-TS) container with HW acceleration

Added by Dean Kasabow over 1 year ago. Updated 10 months ago.

Status:NewStart date:03/20/2018
Priority:NormalDue date:
Assignee:Andreas Smas% Done:

0%

Category:Video playback
Target version:-
Found in version:5.0.532 Platform:Android

Description

HW acceleration: OFF = No crashes, video plays (although CPU resources may be insufficient for smooth playback).

HW acceleration: ON = Only audio plays, and video frames are never sent to the decoder/screen.
Tested with video from HTTP stream, SMB and local storage - it doesn't matter.

If I remux the same video + audio into MKV container everything works fine, but it won't work in .ts/mpegts.

Original video: (doesn't work)
http://esp.deanbg.com/pub/APHD-test.ts

Same video, but remuxed to MKV: (works fine)
http://esp.deanbg.com/pub/APHD-test.mkv

I believe this is the only issue left for the android build. There is no problem playing these streams on the PS3 or with NACL version.

History

#1 Updated by Dean Kasabow over 1 year ago

I must correct my conclusion: the problem is only with H264/AVC in TS (MPEG-TS) and doesn't depend on the resolution.

Also I noticed a small bug in fa_video.c:

line 783:
if(!mcp.frame_rate_num || !mcp.frame_rate_num)

I believe it must be:
if(!mcp.frame_rate_num || !mcp.frame_rate_den)

During my tests with live mpeg-ts streams I noticed that often the frame-rate or the time base values are wrong (zero for time-base num for example).

#2 Updated by Dean Kasabow over 1 year ago

I tried using ffmpeg to create hls/m3u8 from these problematic streams without reencoding - just video/audio copy again in .ts and movian plays the stream perfectly!

My guess is that on android (with HW accel) Movian can't handle the garbage data before the first proper frame, which contains correct header and SPS/PPS data. Mediacodec won't produce any output and video packets seem not to be consumed at all.

[h264 04a3c740] SPS unavailable in decode_picture_timing
[h264
04a3c740] non-existing PPS 0 referenced
[h264 04a3c740] SPS unavailable in decode_picture_timing
[h264
04a3c740] non-existing PPS 0 referenced
[h264 04a3c740] decode_slice_header error
[h264
04a3c740] no frame!
[h264 04a3c740] Increasing reorder buffer to 2
Input #0, mpegts, from 'http://a.b.c.d/HistoryHD':
Duration: N/A, start: 84233.080000, bitrate: N/A
Program 2005
Stream #0:0[0x202]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 50 tbr, 90k tbn, 50 tbc
Stream #0:1[0x266](bul): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
Stream #0:2[0x288](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 256 kb/s
[hls
05d9a800] Opening 'tv0.ts' for writing
Output #0, hls, to 'tv.m3u8':
...
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:2 -> #0:1 (copy)
Press [q] to stop, [?] for help
[hls 05d9a800] Opening 'tv1.ts' for writing0:10.58 bitrate=N/A speed=2.18x
[hls
05d9a800] Opening 'tv.m3u8.tmp' for writing
[hls 05d9a800] Opening 'tv2.ts' for writing0:20.60 bitrate=N/A speed=1.38x
[hls
05d9a800] Opening 'tv.m3u8.tmp' for writing
...

#3 Updated by Dean Kasabow over 1 year ago

So I tried with these tv1/tv2/tv3.ts 10 second files which play fine in HLS mode - if played alone the problem persists, so I guess the handling in the HLS code is much better than for regular .TS streams.

Then I created a simple .m3u8 file with my http: link to the same stream:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:36600
#EXT-X-MEDIA-SEQUENCE:1
#EXTINF:36600,
http://a.b.c.d/HistoryHD
#EXT-X-ENDLIST

Guess what? :) Now it plays PERFECTLY fine :)

#4 Updated by Rob Koni over 1 year ago

Possibly related to my bug #3373 although that is the same on the actual mp4 not only on the M3U8.

#5 Updated by Dean Kasabow over 1 year ago

H264 in MPEG-TS problem is caused by av_bitstream_filter_filter in android_video_codec.c which returns -22 (platform specific error) for streams with no header.

Ignoring the error and fixing av_freep(&converted); allows for streams to play.

#6 Updated by Rob Koni 10 months ago

It even crashes my Android official build.

Also available in: Atom PDF