Opened 12 months ago

Last modified 12 months ago

#8524 new defect

ffmpeg generated m3u8 segments durations do not match ffprobe

Reported by: mjustini99 Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: hls
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
I am attempting to create generate a new HLS stream based on an existing one, the new m3u8 playlist and segments are created fine, but the durations of each segment do not agree with what ffprobe says they are. For example, the second segment is listed in the newly generated m3u8 as a duration of 2.2s, while ffprobe says it is 2.238667

How to reproduce:

ffmpeg -i vid.m3u8 -y -t 5.000 -max_muxing_queue_size 1024 -ss 0.76 -f hls -hls_time 2 -c:v copy -c:a copy -map 0 segment.m3u8
ffmpeg version N-96723-g8e27867229-tessus  https://evermeet.cx/ffmpeg/  Copyright (c) 2000-2020 the FFmpeg developers
  built with Apple clang version 11.0.0 (clang-1100.0.33.17)
  configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvmaf --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-version3 --pkg-config-flags=--static --disable-ffplay
  libavutil      56. 40.100 / 56. 40.100
  libavcodec     58. 68.102 / 58. 68.102
  libavformat    58. 38.100 / 58. 38.100
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 75.100 /  7. 75.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
[hls @ 0x7fa838000400] Skip ('#EXT-X-VERSION:6')
[hls @ 0x7fa838000400] Skip ('#EXT-X-START:TIME-OFFSET=10.560')
[hls @ 0x7fa838000400] Skip ('#EXT-X-PROGRAM-DATE-TIME:2020-01-30T17:26:35.440Z')
[hls @ 0x7fa838000400] Skip ('#EXT-X-PROGRAM-DATE-TIME:2020-01-30T17:26:46.240Z')
[hls @ 0x7fa838000400] Opening 'part1.ts' for reading
Input #0, hls, from 'vid.m3u8':
  Duration: 00:00:21.60, start: 64820.533867, bitrate: 0 kb/s
  Program 0 
    Metadata:
      variant_bitrate : 0
    Stream #0:0: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, unknown/reserved/unknown), 720x576 [SAR 64:45 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
    Metadata:
      variant_bitrate : 0
    Stream #0:1: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp
    Metadata:
      variant_bitrate : 0
Output #0, hls, to 'segment.m3u8':
  Metadata:
    encoder         : Lavf58.38.100
    Stream #0:0: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, unknown/reserved/unknown), 720x576 [SAR 64:45 DAR 16:9], q=2-31, 25 fps, 25 tbr, 90k tbn, 25 tbc
    Metadata:
      variant_bitrate : 0
    Stream #0:1: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp
    Metadata:
      variant_bitrate : 0
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[hls @ 0x7fa83905e000] Opening 'segment0.ts' for writing
[hls @ 0x7fa83905e000] Opening 'segment.m3u8.tmp' for writing
[hls @ 0x7fa83905e000] Opening 'segment1.ts' for writing
[hls @ 0x7fa83905e000] Opening 'segment.m3u8.tmp' for writing
frame=   55 fps=0.0 q=-1.0 Lsize=N/A time=00:00:05.00 bitrate=N/A speed=1.34e+03x    
video:143kB audio:59kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown}}

Attachments (2)

test_vid.zip (1.6 MB) - added by mjustini99 12 months ago.
video input
ffmpeg-20200214-124821.log (67.8 KB) - added by mjustini99 12 months ago.
logging output from ffmpeg

Download all attachments as: .zip

Change History (4)

Changed 12 months ago by mjustini99

video input

Changed 12 months ago by mjustini99

logging output from ffmpeg

comment:1 Changed 12 months ago by cehoyos

  • Component changed from ffmpeg to avformat
  • Keywords hls added; ffmpeg HLS m3u8 removed
  • Version changed from 4.2 to git-master

comment:2 Changed 12 months ago by stevenliu

./ffmpeg -ss 0.76 -i part1.ts -y -t 5.000 -f hls -hls_time 2 -c:v copy -c:a copy -map 0 segment.m3u8

0.76 is not keyframe, so it cannot read video packets correct first segment.

liuqideMacBook-Pro:dash liuqi$ ffprobe segment0.ts
ffprobe version N-95812-gd73f062706 Copyright (c) 2007-2019 the FFmpeg developers
  built with Apple LLVM version 10.0.0 (clang-1000.11.45.5)
  configuration: --enable-fontconfig --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libspeex --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-version3 --enable-nonfree --enable-videotoolbox --enable-libxml2 --samples=fate-suite/ --enable-libopencv
  libavutil      56. 36.100 / 56. 36.100
  libavcodec     58. 62.100 / 58. 62.100
  libavformat    58. 35.100 / 58. 35.100
  libavdevice    58.  9.101 / 58.  9.101
  libavfilter     7. 66.100 /  7. 66.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
[mpegts @ 0x7fd9bc003000] start time for stream 0 is not set in estimate_timings_from_pts
[mpegts @ 0x7fd9bc003000] stream 0 : no TS found at start of file, duration not set
[mpegts @ 0x7fd9bc003000] Could not find codec parameters for stream 0 (Video: h264 ([27][0][0][0] / 0x001B), none): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, mpegts, from 'segment0.ts':
  Duration: 00:00:03.54, start: 1.400000, bitrate: 104 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 ([27][0][0][0] / 0x001B), none, 90k tbr, 90k tbn, 180k tbc
    Stream #0:1[0x101](eng): Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 82 kb/s
./ffmpeg -ss 0.76 -i part1.ts -y -t 5.000 -f mpegts -c:v copy -c:a copy -map 0 segment.ts
ffprobe -show_packets -of xml -select_streams v segment.ts |less

look at the segment.ts packets duraton, the last pts - first pts is 2.xx,
so maybe it correct when you make a wrong operation.

Note: See TracTickets for help on using tickets.