[FFmpeg-user] m3u8 = non-monotonous DTS

Louis Letourneau lletourn49 at gmail.com
Fri Oct 14 02:18:34 EEST 2016


I'm having trouble understanding if I'm doing something wrong or if I'm
missing a flag and I hope you guys can help

If I create an m3u8 with the following command (version 3.1.4)
mkdir a
./ffmpeg -y -s 640x480 -f rawvideo -pix_fmt rgb24 -r 25 -i /dev/zero -an
-vcodec libx264 -preset medium -tune stillimage -crf 24 -pix_fmt yuv420p
-shortest -force_key_frames "expr:gte(t,n_forced*5)" -bf 0 -hls_time 5
-hls_list_size 0 -hls_wrap 0 -hls_allow_cache 1 -hls_segment_filename
"a/a_%04d.ts" -t 60 a/a.m3u8

and then convert it to mp4
./ffmpeg -y -i a/a.m3u8 -codec copy a.mp4

I will get
--------------->
ffmpeg version n3.1.4 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.1) 20160609
  configuration: --prefix=/data/software/ffmpeg-3.1.4 --enable-libfreetype
--enable-x11grab --enable-libpulse --enable-gpl --enable-sdl
--enable-libx264 --enable-opengl --enable-nonfree --enable-libfdk-aac
--enable-libopus --enable-libvpx --enable-openssl --enable-static
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 48.101 / 57. 48.101
  libavformat    57. 41.100 / 57. 41.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 47.100 /  6. 47.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
[hls,applehttp @ 0x3085340] No longer receiving playlist 0
[hls,applehttp @ 0x3085340] Now receiving playlist 0, segment 0
Input #0, hls,applehttp, from 'a/a.m3u8':
  Duration: 00:00:59.96, start: 1.400000, bitrate: 0 kb/s
  Program 0
    Metadata:
      variant_bitrate : 0
    Stream #0:0: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p,
640x480, 25 fps, 25 tbr, 90k tbn, 50 tbc
[mp4 @ 0x31bb100] Using AVStream.codec to pass codec parameters to muxers
is deprecated, use AVStream.codecpar instead.
Output #0, mp4, to 'a.mp4':
  Metadata:
    encoder         : Lavf57.41.100
    Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 640x480,
q=2-31, 25 fps, 25 tbr, 90k tbn, 90k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mpegts @ 0x3088c40] DTS 126000 < 572400 out of order
[hls,applehttp @ 0x3085340] DTS 126000 < 572400 out of order
[mp4 @ 0x31bb100] Non-monotonous DTS in output stream 0:0; previous:
446400, current: 0; changing to 446401. This may result in incorrect
timestamps in the output file.
[mp4 @ 0x31bb100] Non-monotonous DTS in output stream 0:0; previous:
446401, current: 3600; changing to 446402. This may result in incorrect
timestamps in the output file.
[mp4 @ 0x31bb100] Non-monotonous DTS in output stream 0:0; previous:
446402, current: 7200; changing to 446403. This may result in incorrect
timestamps in the output file.
[mp4 @ 0x31bb100] Non-monotonous DTS in output stream 0:0; previous:
446403, current: 10800; changing to 446404. This may result in incorrect
timestamps in the output file.
[mp4 @ 0x31bb100] Non-monotonous DTS in output stream 0:0; previous:
446404, current: 14400; changing to 446405. This may result in incorrect
timestamps in the output file.
[mp4 @ 0x31bb100] Non-monotonous DTS in output stream 0:0; previous:
446405, current: 18000; changing to 446406. This may result in incorrect
timestamps in the output file.
[mp4 @ 0x31bb100] Non-monotonous DTS in output stream 0:0; previous:
446406, current: 21600; changing to 446407. This may result in incorrect
timestamps in the output file.
[...]
frame= 1625 fps=0.0 q=-1.0 Lsize=      64kB time=00:00:59.96 bitrate=
8.7kbits/s speed=2.16e+03x
video:79kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: unknown
--------------->

or
./ffmpeg -y -vsync 0 -i a/a.m3u8 -f image2 "a/out%d.jpg"

--------------->
ffmpeg version n3.1.4 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.1) 20160609
  configuration: --prefix=/data/software/ffmpeg-3.1.4 --enable-libfreetype
--enable-x11grab --enable-libpulse --enable-gpl --enable-sdl
--enable-libx264 --enable-opengl --enable-nonfree --enable-libfdk-aac
--enable-libopus --enable-libvpx --enable-openssl --enable-static
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 48.101 / 57. 48.101
  libavformat    57. 41.100 / 57. 41.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 47.100 /  6. 47.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
[hls,applehttp @ 0x3b30360] No longer receiving playlist 0
[hls,applehttp @ 0x3b30360] Now receiving playlist 0, segment 0
Input #0, hls,applehttp, from 'a/a.m3u8':
  Duration: 00:00:59.96, start: 1.400000, bitrate: 0 kb/s
  Program 0
    Metadata:
      variant_bitrate : 0
    Stream #0:0: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p,
640x480, 25 fps, 25 tbr, 90k tbn, 50 tbc
[swscaler @ 0x3b6b240] deprecated pixel format used, make sure you did set
range correctly
[image2 @ 0x3c66120] Using AVStream.codec to pass codec parameters to
muxers is deprecated, use AVStream.codecpar instead.
Output #0, image2, to 'a/out%d.jpg':
  Metadata:
    encoder         : Lavf57.41.100
    Stream #0:0: Video: mjpeg, yuvj420p(pc), 640x480, q=2-31, 200 kb/s, 25
fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.48.101 mjpeg
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
Press [q] to stop, [?] for help
[mpegts @ 0x3b33c60] DTS 126000 < 572400 out of order
[hls,applehttp @ 0x3b30360] DTS 126000 < 572400 out of order
[mjpeg @ 0x3b82e00] Invalid pts (0) <= last (124)
Video encoding failed
--------------->

It seems the first segment gets repeated, which explains this message
125 = 25fps * 5secs per segment

And if I use
./ffprobe -show_packets -i a/a.m3u8 | grep dts= | less

I see that the first segments packets (pts or dts), a/a_0000.ts,  seem to
be repeated.

if I look at each segment one after the other the dts and pts keep
incrementing fine, so it's really starting from an m3u8 that's the problem.

It's been like this at least since 3.1.2 but head of master doesn't seem to
have this issue. I'm now wondering, if it's fixed, when does master get
merged into the branches (when will this be stable)?

The 2.8 branch also seems to be ok. (I tested 2.8.8)

Thank you
Louis


More information about the ffmpeg-user mailing list