Opened 6 years ago

Last modified 6 years ago

#7207 new defect

FFmpeg segmented output does not work

Reported by: Yurii Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: mpegts h264 dts
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

Segment format outputs only single file.
Ticket is filled after this thread in libav-user mailing list:
http://ffmpeg.org/pipermail/libav-user/2018-May/011143.html

The problem is somehow related to av_read_frame returning invalid PTS/DTS on every received key frame (see FFmpeg output).

How to reproduce:

% ffmpeg -i http://bitmovin-a.akamaihd.net/content/playhouse-vr/m3u8s/105560_video_1920_9000000.m3u8 -c copy -f segment -segment_time 10 part%03d.mp4

FFmpeg version:

ffmpeg version 4.0 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 20160609
configuration: --enable-pic --enable-shared --disable-static --disable-doc --disable-debug --disable-outdevs --enable-runtime-cpudetect

Same problem with older versions (3.3.2, 2.8.14).

FFmpeg output:

[http @ 0xf75b00] No trailing CRLF found in HTTP header.
Input #0, hls,applehttp, from 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/m3u8s/105560_video_1920_9000000.m3u8':
  Duration: 00:02:17.00, start: 0.066733, bitrate: 0 kb/s
  Program 0 
    Metadata:
      variant_bitrate : 0
    Stream #0:0: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 3840x1920 [SAR 1:1 DAR 2:1], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
[segment @ 0x107ee40] Codec for stream 0 does not use global headers but container format requires global headers
[mp4 @ 0x1016900] Codec for stream 0 does not use global headers but container format requires global headers
Output #0, segment, to 'part%03d.mp4':
  Metadata:
    encoder         : Lavf56.40.101
    Stream #0:0: Video: h264 ([27][0][0][0] / 0x001B), yuv420p, 3840x1920 [SAR 1:1 DAR 2:1], q=2-31, 29.97 fps, 29.97 tbr, 11988 tbn, 29.97 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[http @ 0x107fb80] No trailing CRLF found in HTTP header.
[mp4 @ 0x1016900] pts has no value
[http @ 0x10200c0] No trailing CRLF found in HTTP header.ate=N/A    
[mp4 @ 0x1016900] pts has no value
[http @ 0x107fb80] No trailing CRLF found in HTTP header.ate=N/A    
[mp4 @ 0x1016900] pts has no value
[http @ 0x107f9c0] No trailing CRLF found in HTTP header.ate=N/A    
[mp4 @ 0x1016900] pts has no value
[http @ 0x107fb80] No trailing CRLF found in HTTP header.ate=N/A    
...

Change History (5)

comment:1 by Yurii, 6 years ago

Component: undeterminedavformat

comment:2 by Carl Eugen Hoyos, 6 years ago

Please test current FFmpeg git head and provide the command line you tested together with the complete, uncut console output to make this a valid ticket.

comment:3 by Yurii, 6 years ago

Test command line (added -re option for confidence):

% ffmpeg -re -i http://bitmovin-a.akamaihd.net/content/playhouse-vr/m3u8s/105560_video_1920_9000000.m3u8 -c copy -f segment -segment_time 10 part%03d.mp4

Complete ffmpeg output:

ffmpeg version N-91076-g10ed9f2 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 20160609
  configuration: 
  libavutil      56. 18.102 / 56. 18.102
  libavcodec     58. 19.101 / 58. 19.101
  libavformat    58. 13.102 / 58. 13.102
  libavdevice    58.  4.100 / 58.  4.100
  libavfilter     7. 22.100 /  7. 22.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
[hls,applehttp @ 0x3acc4c0] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_0.ts' for reading
[hls,applehttp @ 0x3acc4c0] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_1.ts' for reading
[http @ 0x3ad71c0] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_2.ts' for reading
Input #0, hls,applehttp, from 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/m3u8s/105560_video_1920_9000000.m3u8':
  Duration: 00:02:17.00, start: 0.066733, bitrate: 0 kb/s
  Program 0 
    Metadata:
      variant_bitrate : 0
    Stream #0:0: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 3840x1920 [SAR 1:1 DAR 2:1], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Metadata:
      variant_bitrate : 0
[segment @ 0x3b87f80] Opening 'part000.mp4' for writing
Output #0, segment, to 'part%03d.mp4':
  Metadata:
    encoder         : Lavf58.13.102
    Stream #0:0: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 3840x1920 [SAR 1:1 DAR 2:1], q=2-31, 29.97 fps, 29.97 tbr, 11988 tbn, 29.97 tbc
    Metadata:
      variant_bitrate : 0
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[segment @ 0x3b87f80] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[mp4 @ 0x3b2bd40] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[mp4 @ 0x3b2bd40] pts has no value
[http @ 0x3af1a40] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_3.ts' for reading
[mp4 @ 0x3b2bd40] pts has no value
[http @ 0x3ad71c0] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_4.ts' for reading
[mp4 @ 0x3b2bd40] pts has no value
[http @ 0x3af1a40] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_5.ts' for reading
[mp4 @ 0x3b2bd40] pts has no value
[http @ 0x3ad71c0] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_6.ts' for reading
[mp4 @ 0x3b2bd40] pts has no value
[http @ 0x3af1a40] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_7.ts' for reading
[mp4 @ 0x3b2bd40] pts has no value
[http @ 0x3ad71c0] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_8.ts' for reading
[mp4 @ 0x3b2bd40] pts has no valueA time=00:00:27.89 bitrate=N/A speed=   1x    
[http @ 0x3af1a40] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_9.ts' for reading
[mp4 @ 0x3b2bd40] pts has no value
[http @ 0x3ad71c0] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_10.ts' for reading
[mp4 @ 0x3b2bd40] pts has no value
[http @ 0x3af1a40] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_11.ts' for reading
[mp4 @ 0x3b2bd40] pts has no value
[http @ 0x3ad71c0] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_12.ts' for reading
[mp4 @ 0x3b2bd40] pts has no value
[http @ 0x3af1a40] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_13.ts' for reading
[mp4 @ 0x3b2bd40] pts has no value
[http @ 0x3ad71c0] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_14.ts' for reading
[mp4 @ 0x3b2bd40] pts has no value
[http @ 0x3af1a40] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_15.ts' for reading
[mp4 @ 0x3b2bd40] pts has no value
[http @ 0x3ad71c0] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_16.ts' for reading
[mp4 @ 0x3b2bd40] pts has no value
[http @ 0x3af1a40] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_17.ts' for reading
[mp4 @ 0x3b2bd40] pts has no value
[http @ 0x3ad71c0] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_18.ts' for reading
[mp4 @ 0x3b2bd40] pts has no value
[http @ 0x3af1a40] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_19.ts' for reading
[mp4 @ 0x3b2bd40] pts has no valueA time=00:01:11.93 bitrate=N/A speed=   1x    
[http @ 0x3ad71c0] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_20.ts' for reading
[mp4 @ 0x3b2bd40] pts has no valueA time=00:01:15.97 bitrate=N/A speed=   1x    
[http @ 0x3af1a40] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_21.ts' for reading
[mp4 @ 0x3b2bd40] pts has no value
[http @ 0x3ad71c0] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_22.ts' for reading
[mp4 @ 0x3b2bd40] pts has no value
[http @ 0x3af1a40] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_23.ts' for reading
[mp4 @ 0x3b2bd40] pts has no value
[http @ 0x3ad71c0] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_24.ts' for reading
[mp4 @ 0x3b2bd40] pts has no value
[http @ 0x3af1a40] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_25.ts' for reading
[mp4 @ 0x3b2bd40] pts has no value
[http @ 0x3ad71c0] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_26.ts' for reading
[mp4 @ 0x3b2bd40] pts has no value
[http @ 0x3af1a40] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_27.ts' for reading
[mp4 @ 0x3b2bd40] pts has no value
[http @ 0x3ad71c0] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_28.ts' for reading
[mp4 @ 0x3b2bd40] pts has no value
[http @ 0x3af1a40] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_29.ts' for reading
[mp4 @ 0x3b2bd40] pts has no value
[http @ 0x3ad71c0] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_30.ts' for reading
[mp4 @ 0x3b2bd40] pts has no valueA time=00:01:55.98 bitrate=N/A speed=   1x    
[http @ 0x3af1a40] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_31.ts' for reading
[mp4 @ 0x3b2bd40] pts has no value
[http @ 0x3ad71c0] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_32.ts' for reading
[mp4 @ 0x3b2bd40] pts has no value
[http @ 0x3af1a40] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_33.ts' for reading
[mp4 @ 0x3b2bd40] pts has no value
[http @ 0x3ad71c0] Opening 'http://bitmovin-a.akamaihd.net/content/playhouse-vr/video/1920_9000000/hls/segment_34.ts' for reading
[mp4 @ 0x3b2bd40] pts has no value
[mp4 @ 0x3b2bd40] pts has no valueA time=00:02:15.70 bitrate=N/A speed=   1x    
frame= 4118 fps= 30 q=-1.0 Lsize=N/A time=00:02:17.30 bitrate=N/A speed=   1x    
video:150714kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

FFmpeg was built from current github master: https://github.com/FFmpeg/FFmpeg/commit/10ed9f2b12936a51047124358dffcee7dab8f421

comment:4 by Carl Eugen Hoyos, 6 years ago

Keywords: mpegts h264 dts added; segment pts av_read_frame removed
Version: unspecifiedgit-master

comment:5 by Linjie.Fu, 6 years ago

Reproduced this issue in the latest version of ffmpeg.

The root cause of this issue is the redundant PPS slice info attached behind the last frame of each segment_x.ts.

PPS info is attached behind frame data in one PES packet, and the redundant info will be found while parsing.

In h264_parser, h264_find_frame_end for last PPS info returns END_NOT_FOUND, and causes the following IDR frame of next segment.ts to return END_NOT_FOUND too. And this leads to the failure of parsing pts.

Provide a patch to skip the redundant pps info and parse the pts info of following frame correctly.

commit id: 02e6ae3ffd7babd0a4f9dd7b02f0b91932b0ea16
mail list: http://ffmpeg.org/pipermail/ffmpeg-devel/2018-October/235565.html
patchwork: https://patchwork.ffmpeg.org/patch/10776/

Note: See TracTickets for help on using tickets.