[FFmpeg-trac] #6841(avformat:open): 1ms gap in WebM Opus files encoded with ffmpeg

FFmpeg trac at avcodec.org
Fri Dec 1 02:32:51 EET 2017


#6841: 1ms gap in WebM Opus files encoded with ffmpeg
------------------------------------+------------------------------------
             Reporter:  ntrrgc      |                    Owner:
                 Type:  defect      |                   Status:  open
             Priority:  normal      |                Component:  avformat
              Version:  git-master  |               Resolution:
             Keywords:  mkv opus    |               Blocked By:
             Blocking:              |  Reproduced by developer:  1
Analyzed by developer:  0           |
------------------------------------+------------------------------------

Comment (by mkver):

 This seems to be a problem with encoder delay (that opus signals
 explicitly) and rounding timestamps too early. In more detail: The
 reference opus encoder has a default encoding delay of 312 samples (6.5ms
 at a sample rate of 48000.) So the first audio block has a PTS of -6.5ms;
 the second of 13.5ms. Upon conversion to ms precision (the Matroska muxer
 uses 1/1000 as timebase) the first becomes -7ms, the second 14ms. This is
 then shifted by default to avoid negative timestamps (depends upon
 -avoid_negative_ts). Here is the log:
 {{{
 ffmpeg started on 2017-12-01 at 00:48:14
 Report written to "ffmpeg-20171201-004814.log"
 Command line:
 ffmpeg -debug_ts -report -i sin.opus -c copy sin.mka
 ffmpeg version N-89341-gd13b8f68d7 Copyright (c) 2000-2017 the FFmpeg
 developers
   built with gcc 7.2.0 (Rev1, Built by MSYS2 project)
   configuration: --disable-static --enable-shared --enable-avisynth
 --enable-gcrypt --enable-libopus --enable-libvorbis --enable-gnutls
 --enable-libbluray --enable-libmfx --enable-libwavpack --enable-gpl
 --disable-decoder=h264_cuvid --disable-decoder=hevc_cuvid --disable-
 decoder=mjpeg_cuvid --disable-decoder=mpeg1_cuvid --disable-
 decoder=mpeg2_cuvid --disable-decoder=mpeg4_cuvid --disable-
 decoder=vc1_cuvid --disable-decoder=vp8_cuvid --disable-decoder=vp9_cuvid
 --disable-encoder=dca --disable-encoder=nellymoser --disable-
 encoder=real_144 --disable-encoder=truehd --disable-encoder=vorbis
 --disable-encoder=sonic --disable-encoder=sonicls --disable-encoder=amv
 --disable-encoder=asv1 --disable-encoder=asv2 --disable-encoder=flashsv
 --disable-encoder=flashsv2 --disable-encoder=roqvideo --disable-
 encoder=svq1 --disable-encoder=zmbv --disable-encoder=zlib --disable-
 encoder=snow --disable-encoder=cinepak --disable-encoder=h264_nvenc
 --disable-encoder=hevc_nvenc --disable-encoder=nvenc_hevc --disable-
 encoder=nvenc --  libavutil      56.  4.100 / 56.  4.100
   libavcodec     58.  6.102 / 58.  6.102
   libavformat    58.  2.103 / 58.  2.103
   libavdevice    58.  0.100 / 58.  0.100
   libavfilter     7.  5.100 /  7.  5.100
   libswscale      5.  0.101 /  5.  0.101
   libswresample   3.  0.101 /  3.  0.101
   libpostproc    55.  0.100 / 55.  0.100
 Splitting the commandline.
 Reading option '-debug_ts' ... matched as option 'debug_ts' (print
 timestamp debugging info) with argument '1'.
 Reading option '-report' ... matched as option 'report' (generate a
 report) with argument '1'.
 Reading option '-i' ... matched as input url with argument 'sin.opus'.
 Reading option '-c' ... matched as option 'c' (codec name) with argument
 'copy'.
 Reading option 'sin.mka' ... matched as output url.
 Finished splitting the commandline.
 Parsing a group of options: global .
 Applying option debug_ts (print timestamp debugging info) with argument 1.
 Applying option report (generate a report) with argument 1.
 Successfully parsed a group of options.
 Parsing a group of options: input url sin.opus.
 Successfully parsed a group of options.
 Opening an input file: sin.opus.
 [NULL @ 00000000005f5a40] Opening 'sin.opus' for reading
 [file @ 00000000005dea00] Setting default whitelist 'file,crypto'
 [ogg @ 00000000005f5a40] Format ogg probed with size=2048 and score=100
 [ogg @ 00000000005f5a40] 684 bytes of comment header remain
 [ogg @ 00000000005f5a40] Before avformat_find_stream_info() pos: 2007
 bytes read:2007 seeks:0 nb_streams:1
 [ogg @ 00000000005f5a40] All info found
 [ogg @ 00000000005f5a40] After avformat_find_stream_info() pos: 2007 bytes
 read:2007 seeks:0 frames:1
 Input #0, ogg, from 'sin.opus':
   Duration: 00:00:00.10, start: 0.000000, bitrate: 160 kb/s
     Stream #0:0, 1, 1/48000: Audio: opus, 48000 Hz, mono, fltp
     Metadata:
       ENCODER         : opusenc from opus-tools 0.1.10-9-gbd65450
 Successfully opened the file.
 Parsing a group of options: output url sin.mka.
 Applying option c (codec name) with argument copy.
 Successfully parsed a group of options.
 Opening an output file: sin.mka.
 [file @ 00000000005debe0] Setting default whitelist 'file,crypto'
 Successfully opened the file.
 Output #0, matroska, to 'sin.mka':
   Metadata:
     encoder         : Lavf58.2.103
     Stream #0:0, 0, 1/1000: Audio: opus ([255][255][255][255] /
 0xFFFFFFFF), 48000 Hz, mono, fltp
     Metadata:
       ENCODER         : opusenc from opus-tools 0.1.10-9-gbd65450
 Stream mapping:
   Stream #0:0 -> #0:0 (copy)
 Press [q] to stop, [?] for help
 cur_dts is invalid (this is harmless if it occurs once at the start per
 stream)
 demuxer -> ist_index:0 type:audio next_dts:NOPTS next_dts_time:NOPTS
 next_pts:NOPTS next_pts_time:NOPTS pkt_pts:-312 pkt_pts_time:-0.0065
 pkt_dts:-312 pkt_dts_time:-0.0065 off:0 off_time:0
 demuxer+ffmpeg -> ist_index:0 type:audio pkt_pts:-312 pkt_pts_time:-0.0065
 pkt_dts:-312 pkt_dts_time:-0.0065 off:0 off_time:0
 muxer <- type:audio pkt_pts:-7 pkt_pts_time:-0.007 pkt_dts:-7
 pkt_dts_time:-0.007 size:300
 [matroska @ 00000000005f76c0] get_metadata_duration returned: 0
 demuxer -> ist_index:0 type:audio next_dts:-6500 next_dts_time:-0.0065
 next_pts:-6500 next_pts_time:-0.0065 pkt_pts:648 pkt_pts_time:0.0135
 pkt_dts:648 pkt_dts_time:0.0135 off:0 off_time:0
 demuxer+ffmpeg -> ist_index:0 type:audio pkt_pts:648 pkt_pts_time:0.0135
 pkt_dts:648 pkt_dts_time:0.0135 off:0 off_time:0
 muxer <- type:audio pkt_pts:14 pkt_pts_time:0.014 pkt_dts:14
 pkt_dts_time:0.014 size:165
 [matroska @ 00000000005f76c0] Writing block at offset 9, size 300, pts 0,
 dts 0, duration 20, keyframe 1
 demuxer -> ist_index:0 type:audio next_dts:13500 next_dts_time:0.0135
 next_pts:13500 next_pts_time:0.0135 pkt_pts:1608 pkt_pts_time:0.0335
 pkt_dts:1608 pkt_dts_time:0.0335 off:0 off_time:0
 demuxer+ffmpeg -> ist_index:0 type:audio pkt_pts:1608 pkt_pts_time:0.0335
 pkt_dts:1608 pkt_dts_time:0.0335 off:0 off_time:0
 muxer <- type:audio pkt_pts:34 pkt_pts_time:0.034 pkt_dts:34
 pkt_dts_time:0.034 size:174
 [matroska @ 00000000005f76c0] Writing block at offset 316, size 165, pts
 21, dts 21, duration 20, keyframe 1
 demuxer -> ist_index:0 type:audio next_dts:33500 next_dts_time:0.0335
 next_pts:33500 next_pts_time:0.0335 pkt_pts:2568 pkt_pts_time:0.0535
 pkt_dts:2568 pkt_dts_time:0.0535 off:0 off_time:0
 demuxer+ffmpeg -> ist_index:0 type:audio pkt_pts:2568 pkt_pts_time:0.0535
 pkt_dts:2568 pkt_dts_time:0.0535 off:0 off_time:0
 muxer <- type:audio pkt_pts:54 pkt_pts_time:0.054 pkt_dts:54
 pkt_dts_time:0.054 size:173
 [matroska @ 00000000005f76c0] Writing block at offset 488, size 174, pts
 41, dts 41, duration 20, keyframe 1
 demuxer -> ist_index:0 type:audio next_dts:53500 next_dts_time:0.0535
 next_pts:53500 next_pts_time:0.0535 pkt_pts:3528 pkt_pts_time:0.0735
 pkt_dts:3528 pkt_dts_time:0.0735 off:0 off_time:0
 demuxer+ffmpeg -> ist_index:0 type:audio pkt_pts:3528 pkt_pts_time:0.0735
 pkt_dts:3528 pkt_dts_time:0.0735 off:0 off_time:0
 muxer <- type:audio pkt_pts:74 pkt_pts_time:0.074 pkt_dts:74
 pkt_dts_time:0.074 size:320
 [matroska @ 00000000005f76c0] Writing block at offset 669, size 173, pts
 61, dts 61, duration 20, keyframe 1
 No more output streams to write to, finishing.
 [matroska @ 00000000005f76c0] Writing block at offset 849, size 320, pts
 81, dts 81, duration 20, keyframe 1
 [matroska @ 00000000005f76c0] end duration = 101
 [matroska @ 00000000005f76c0] stream 0 end duration = 101
 size=       2kB time=00:00:00.07 bitrate= 206.1kbits/s speed=10.3x
 video:0kB audio:1kB subtitle:0kB other streams:0kB global headers:0kB
 muxing overhead: 68.374557%
 Input file #0 (sin.opus):
   Input stream #0:0 (audio): 5 packets read (1132 bytes);
   Total: 5 packets (1132 bytes) demuxed
 Output file #0 (sin.mka):
   Output stream #0:0 (audio): 5 packets muxed (1132 bytes);
   Total: 5 packets (1132 bytes) muxed
 0 frames successfully decoded, 0 decoding errors
 [AVIOContext @ 00000000023b00c0] Statistics: 14 seeks, 10 writeouts
 [AVIOContext @ 00000000005ff2a0] Statistics: 2007 bytes read, 0 seeks
 }}}

--
Ticket URL: <https://trac.ffmpeg.org/ticket/6841#comment:5>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list