[FFmpeg-trac] #8806(undetermined:new): apad filter seems not working with HLS output

FFmpeg trac at avcodec.org
Mon Jul 20 15:50:22 EEST 2020


#8806: apad filter seems not working with HLS output
-------------------------------------+-------------------------------------
             Reporter:  mrskman      |                     Type:  defect
               Status:  new          |                 Priority:  normal
            Component:               |                  Version:
  undetermined                       |  unspecified
             Keywords:               |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
 I'm trying to add audio silence so the audio track length matches the
 length of video track. But it seems not working correctly.

 The input file has ~30s of video and ~1s of audio.
 {{{
 ffprobe -i apad_filter_not_working_with_hls_output.mkv

 ffprobe version 4.3.1 Copyright (c) 2007-2020 the FFmpeg developers
   built with gcc 4.9.4 (Ubuntu 4.9.4-2ubuntu1~12.04)
   configuration: --prefix=/opt/ffmpeg/4.3.1/build --cc= --cxx= --objcc=
 --dep-cc= --extra-cflags=' -I/usr/local/cuda-10.1/include' --extra-
 cxxflags= --extra-ldflags='-Wl,-rpath,/opt/ffmpeg/4.3.1/build/lib
 -L/opt/ffmpeg/4.3.1/build/lib -Wl,-rpath,/usr/local/cuda-10.1/lib64
 -L/usr/local/cuda-10.1/lib64' --bindir=/opt/ffmpeg/4.3.1/build/bin
 --enable-shared --disable-static --disable-doc --disable-htmlpages
 --disable-manpages --disable-podpages --disable-txtpages --enable-cuda-
 nvcc --enable-gpl --enable-libaom --enable-libfdk-aac --enable-libmp3lame
 --enable-libnpp --enable-libopenjpeg --enable-libopus --enable-librtmp
 --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp
 --enable-libx264 --enable-libx265 --enable-libxml2 --enable-nonfree
 --enable-nvdec --enable-nvenc --enable-openssl --enable-rpath --enable-
 version3
   libavutil      56. 51.100 / 56. 51.100
   libavcodec     58. 91.100 / 58. 91.100
   libavformat    58. 45.100 / 58. 45.100
   libavdevice    58. 10.100 / 58. 10.100
   libavfilter     7. 85.100 /  7. 85.100
   libswscale      5.  7.100 /  5.  7.100
   libswresample   3.  7.100 /  3.  7.100
   libpostproc    55.  7.100 / 55.  7.100
 Input #0, matroska,webm, from
 'apad_filter_not_working_with_hls_output.mkv':
   Metadata:
     ENCODER         : Lavf58.45.100
   Duration: 00:00:30.11, start: 0.000000, bitrate: 227 kb/s
     Stream #0:0(eng): Video: h264 (High), yuv420p(tv, bt709, progressive),
 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc
 (default)
     Metadata:
       BPS             : 212945
       BPS-eng         : 212945
       DURATION-eng    : 00:10:05.063000000
       NUMBER_OF_FRAMES: 14507
       NUMBER_OF_FRAMES-eng: 14507
       NUMBER_OF_BYTES : 16105645
       NUMBER_OF_BYTES-eng: 16105645
       _STATISTICS_WRITING_APP: mkvmerge v7.2.0 ('On Every Street') 32bit
 built on Sep 13 2014 15:42:11
       _STATISTICS_WRITING_APP-eng: mkvmerge v7.2.0 ('On Every Street')
 32bit built on Sep 13 2014 15:42:11
       _STATISTICS_WRITING_DATE_UTC: 2014-09-19 01:06:47
       _STATISTICS_WRITING_DATE_UTC-eng: 2014-09-19 01:06:47
       _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
       _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
       DURATION        : 00:00:30.113000000
     Stream #0:1(eng): Audio: mp3, 48000 Hz, stereo, fltp, 80 kb/s
 (default)
     Metadata:
       BPS             : 34181
       BPS-eng         : 34181
       DURATION-eng    : 00:00:01.056000000
       NUMBER_OF_FRAMES: 44
       NUMBER_OF_FRAMES-eng: 44
       NUMBER_OF_BYTES : 4512
       NUMBER_OF_BYTES-eng: 4512
       _STATISTICS_WRITING_APP: mkvmerge v7.2.0 ('On Every Street') 32bit
 built on Sep 13 2014 15:42:11
       _STATISTICS_WRITING_APP-eng: mkvmerge v7.2.0 ('On Every Street')
 32bit built on Sep 13 2014 15:42:11
       _STATISTICS_WRITING_DATE_UTC: 2014-09-19 01:06:47
       _STATISTICS_WRITING_DATE_UTC-eng: 2014-09-19 01:06:47
       _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
       _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
       DURATION        : 00:00:01.056000000
 }}}

 I'm trying to convert it to HLS using this command:

 {{{
 ffmpeg -i apad_filter_not_working_with_hls_output.mkv -filter_complex
 '[0:a]apad=whole_dur=30[audio]' -map '0:v' -map '[audio]' -f hls -hls_time
 5 -y test.m3u8

 ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
   built with gcc 4.9.4 (Ubuntu 4.9.4-2ubuntu1~12.04)
   configuration: --prefix=/opt/ffmpeg/4.3.1/build --cc= --cxx= --objcc=
 --dep-cc= --extra-cflags=' -I/usr/local/cuda-10.1/include' --extra-
 cxxflags= --extra-ldflags='-Wl,-rpath,/opt/ffmpeg/4.3.1/build/lib
 -L/opt/ffmpeg/4.3.1/build/lib -Wl,-rpath,/usr/local/cuda-10.1/lib64
 -L/usr/local/cuda-10.1/lib64' --bindir=/opt/ffmpeg/4.3.1/build/bin
 --enable-shared --disable-static --disable-doc --disable-htmlpages
 --disable-manpages --disable-podpages --disable-txtpages --enable-cuda-
 nvcc --enable-gpl --enable-libaom --enable-libfdk-aac --enable-libmp3lame
 --enable-libnpp --enable-libopenjpeg --enable-libopus --enable-librtmp
 --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp
 --enable-libx264 --enable-libx265 --enable-libxml2 --enable-nonfree
 --enable-nvdec --enable-nvenc --enable-openssl --enable-rpath --enable-
 version3
   libavutil      56. 51.100 / 56. 51.100
   libavcodec     58. 91.100 / 58. 91.100
   libavformat    58. 45.100 / 58. 45.100
   libavdevice    58. 10.100 / 58. 10.100
   libavfilter     7. 85.100 /  7. 85.100
   libswscale      5.  7.100 /  5.  7.100
   libswresample   3.  7.100 /  3.  7.100
   libpostproc    55.  7.100 / 55.  7.100
 Input #0, matroska,webm, from
 'apad_filter_not_working_with_hls_output.mkv':
   Metadata:
     ENCODER         : Lavf58.45.100
   Duration: 00:00:30.11, start: 0.000000, bitrate: 227 kb/s
     Stream #0:0(eng): Video: h264 (High), yuv420p(tv, bt709, progressive),
 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc
 (default)
     Metadata:
       BPS             : 212945
       BPS-eng         : 212945
       DURATION-eng    : 00:10:05.063000000
       NUMBER_OF_FRAMES: 14507
       NUMBER_OF_FRAMES-eng: 14507
       NUMBER_OF_BYTES : 16105645
       NUMBER_OF_BYTES-eng: 16105645
       _STATISTICS_WRITING_APP: mkvmerge v7.2.0 ('On Every Street') 32bit
 built on Sep 13 2014 15:42:11
       _STATISTICS_WRITING_APP-eng: mkvmerge v7.2.0 ('On Every Street')
 32bit built on Sep 13 2014 15:42:11
       _STATISTICS_WRITING_DATE_UTC: 2014-09-19 01:06:47
       _STATISTICS_WRITING_DATE_UTC-eng: 2014-09-19 01:06:47
       _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
       _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
       DURATION        : 00:00:30.113000000
     Stream #0:1(eng): Audio: mp3, 48000 Hz, stereo, fltp, 80 kb/s
 (default)
     Metadata:
       BPS             : 34181
       BPS-eng         : 34181
       DURATION-eng    : 00:00:01.056000000
       NUMBER_OF_FRAMES: 44
       NUMBER_OF_FRAMES-eng: 44
       NUMBER_OF_BYTES : 4512
       NUMBER_OF_BYTES-eng: 4512
       _STATISTICS_WRITING_APP: mkvmerge v7.2.0 ('On Every Street') 32bit
 built on Sep 13 2014 15:42:11
       _STATISTICS_WRITING_APP-eng: mkvmerge v7.2.0 ('On Every Street')
 32bit built on Sep 13 2014 15:42:11
       _STATISTICS_WRITING_DATE_UTC: 2014-09-19 01:06:47
       _STATISTICS_WRITING_DATE_UTC-eng: 2014-09-19 01:06:47
       _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
       _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
       DURATION        : 00:00:01.056000000
 Stream mapping:
   Stream #0:1 (mp3float) -> apad (graph 0)
   Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
   apad (graph 0) -> Stream #0:1 (aac)
 Press [q] to stop, [?] for help
 [libx264 @ 0x13f4780] using SAR=1/1
 [libx264 @ 0x13f4780] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
 AVX FMA3 BMI2 AVX2
 [libx264 @ 0x13f4780] profile Progressive High, level 4.0, 4:2:0, 8-bit
 [libx264 @ 0x13f4780] 264 - core 157 - H.264/MPEG-4 AVC codec - Copyleft
 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=3
 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00
 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0
 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=34
 lookahead_threads=5 sliced_threads=0 nr=0 decimate=1 interlaced=0
 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1
 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=23
 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0
 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
 Output #0, hls, to 'test.m3u8':
   Metadata:
     encoder         : Lavf58.45.100
     Stream #0:0(eng): Video: h264 (libx264), yuv420p, 1920x1080 [SAR 1:1
 DAR 16:9], q=-1--1, 23.98 fps, 90k tbn, 23.98 tbc (default)
     Metadata:
       BPS             : 212945
       BPS-eng         : 212945
       DURATION-eng    : 00:10:05.063000000
       NUMBER_OF_FRAMES: 14507
       NUMBER_OF_FRAMES-eng: 14507
       NUMBER_OF_BYTES : 16105645
       NUMBER_OF_BYTES-eng: 16105645
       _STATISTICS_WRITING_APP: mkvmerge v7.2.0 ('On Every Street') 32bit
 built on Sep 13 2014 15:42:11
       _STATISTICS_WRITING_APP-eng: mkvmerge v7.2.0 ('On Every Street')
 32bit built on Sep 13 2014 15:42:11
       _STATISTICS_WRITING_DATE_UTC: 2014-09-19 01:06:47
       _STATISTICS_WRITING_DATE_UTC-eng: 2014-09-19 01:06:47
       _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
       _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
       DURATION        : 00:00:30.113000000
       encoder         : Lavc58.91.100 libx264
     Side data:
       cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
     Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp, 128 kb/s
 (default)
     Metadata:
       encoder         : Lavc58.91.100 aac
 [hls @ 0x13e78c0] Opening 'test0.ts' for writing1.17 bitrate=N/A
 speed=7.39x
 [hls @ 0x13e78c0] Opening 'test.m3u8.tmp' for writing
 [hls @ 0x13e78c0] Opening 'test1.ts' for writing3.56 bitrate=N/A
 speed=7.81x
 [hls @ 0x13e78c0] Opening 'test.m3u8.tmp' for writing
 [hls @ 0x13e78c0] Opening 'test2.ts' for writing6.73 bitrate=N/A speed=
 7.6x
 [hls @ 0x13e78c0] Opening 'test.m3u8.tmp' for writing
 [hls @ 0x13e78c0] Opening 'test3.ts' for writing
 [hls @ 0x13e78c0] Opening 'test.m3u8.tmp' for writing
 frame=  722 fps=197 q=-1.0 Lsize=N/A time=00:00:30.01 bitrate=N/A speed=
 8.2x
 video:683kB audio:8kB subtitle:0kB other streams:0kB global headers:0kB
 muxing overhead: unknown
 [libx264 @ 0x13f4780] frame I:4     Avg QP: 8.36  size:  3162
 [libx264 @ 0x13f4780] frame P:433   Avg QP:16.78  size:   976
 [libx264 @ 0x13f4780] frame B:285   Avg QP:17.01  size:   924
 [libx264 @ 0x13f4780] consecutive B-frames: 29.4% 53.7%  0.8% 16.1%
 [libx264 @ 0x13f4780] mb I  I16..4: 85.2% 13.3%  1.5%
 [libx264 @ 0x13f4780] mb P  I16..4:  3.1%  1.4%  0.2%  P16..4:  1.6%  0.2%
 0.2%  0.0%  0.0%    skip:93.4%
 [libx264 @ 0x13f4780] mb B  I16..4:  0.4%  0.0%  0.1%  B16..8:  5.8%  0.6%
 0.1%  direct: 0.0%  skip:92.9%  L0:46.9% L1:52.8% BI: 0.3%
 [libx264 @ 0x13f4780] 8x8 transform intra:25.5% inter:12.7%
 [libx264 @ 0x13f4780] coded y,uvDC,uvAC intra: 2.1% 0.0% 0.0% inter: 0.1%
 0.0% 0.0%
 [libx264 @ 0x13f4780] i16 v,h,dc,p: 98%  2%  0%  0%
 [libx264 @ 0x13f4780] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu:  7%  5% 88%  0%  0%
 0%  0%  0%  0%
 [libx264 @ 0x13f4780] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 34% 18% 33%  4%  2%
 3%  2%  4%  1%
 [libx264 @ 0x13f4780] i8c dc,h,v,p: 100%  0%  0%  0%
 [libx264 @ 0x13f4780] Weighted P-Frames: Y:0.0% UV:0.0%
 [libx264 @ 0x13f4780] ref P L0: 82.0%  1.3%  9.3%  7.3%
 [libx264 @ 0x13f4780] ref B L0: 91.4%  6.9%  1.6%
 [libx264 @ 0x13f4780] ref B L1: 98.6%  1.4%
 [libx264 @ 0x13f4780] kb/s:185.61
 [aac @ 0x13d8c40] Qavg: 65536.000
 }}}

 After that I inspect the first chunk and I see that audio is less then 1s
 long instead of 5s.

 {{{
 ffprobe -show_streams -select_streams a -i test0.ts

 ffprobe version 4.3.1 Copyright (c) 2007-2020 the FFmpeg developers
   built with gcc 4.9.4 (Ubuntu 4.9.4-2ubuntu1~12.04)
   configuration: --prefix=/opt/ffmpeg/4.3.1/build --cc= --cxx= --objcc=
 --dep-cc= --extra-cflags=' -I/usr/local/cuda-10.1/include' --extra-
 cxxflags= --extra-ldflags='-Wl,-rpath,/opt/ffmpeg/4.3.1/build/lib
 -L/opt/ffmpeg/4.3.1/build/lib -Wl,-rpath,/usr/local/cuda-10.1/lib64
 -L/usr/local/cuda-10.1/lib64' --bindir=/opt/ffmpeg/4.3.1/build/bin
 --enable-shared --disable-static --disable-doc --disable-htmlpages
 --disable-manpages --disable-podpages --disable-txtpages --enable-cuda-
 nvcc --enable-gpl --enable-libaom --enable-libfdk-aac --enable-libmp3lame
 --enable-libnpp --enable-libopenjpeg --enable-libopus --enable-librtmp
 --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp
 --enable-libx264 --enable-libx265 --enable-libxml2 --enable-nonfree
 --enable-nvdec --enable-nvenc --enable-openssl --enable-rpath --enable-
 version3
   libavutil      56. 51.100 / 56. 51.100
   libavcodec     58. 91.100 / 58. 91.100
   libavformat    58. 45.100 / 58. 45.100
   libavdevice    58. 10.100 / 58. 10.100
   libavfilter     7. 85.100 /  7. 85.100
   libswscale      5.  7.100 /  5.  7.100
   libswresample   3.  7.100 /  3.  7.100
   libpostproc    55.  7.100 / 55.  7.100
 Input #0, mpegts, from 'test0.ts':
   Duration: 00:00:05.03, start: 1.462089, bitrate: 262 kb/s
   Program 1
     Metadata:
       service_name    : Service01
       service_provider: FFmpeg
     Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B),
 yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr,
 90k tbn, 47.95 tbc
     Stream #0:1[0x101]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000
 Hz, stereo, fltp, 4 kb/s
 [STREAM]
 index=1
 codec_name=aac
 codec_long_name=AAC (Advanced Audio Coding)
 profile=LC
 codec_type=audio
 codec_time_base=1/48000
 codec_tag_string=[15][0][0][0]
 codec_tag=0x000f
 sample_fmt=fltp
 sample_rate=48000
 channels=2
 channel_layout=stereo
 bits_per_sample=0
 id=0x101
 r_frame_rate=0/0
 avg_frame_rate=0/0
 time_base=1/90000
 start_pts=131588
 start_time=1.462089
 duration_ts=67200
 duration=0.746667
 bit_rate=4875
 max_bit_rate=N/A
 bits_per_raw_sample=N/A
 nb_frames=N/A
 nb_read_frames=N/A
 nb_read_packets=N/A
 DISPOSITION:default=0
 DISPOSITION:dub=0
 DISPOSITION:original=0
 DISPOSITION:comment=0
 DISPOSITION:lyrics=0
 DISPOSITION:karaoke=0
 DISPOSITION:forced=0
 DISPOSITION:hearing_impaired=0
 DISPOSITION:visual_impaired=0
 DISPOSITION:clean_effects=0
 DISPOSITION:attached_pic=0
 DISPOSITION:timed_thumbnails=0
 [/STREAM]
 }}}


 If I use separate files as an audio/video inputs the audio in the first
 chunk is closely to 5s.

 {{{
 ffmpeg -i apad_filter_not_working_with_hls_output.mkv -i
 apad_filter_not_working_with_hls_output.mkv -filter_complex
 '[0:a]apad=whole_dur=30[audio]' -map '1:v' -map '[audio]' -f hls -hls_time
 5 -y test.m3u8
 }}}
 {{{
 ffprobe -show_streams -select_streams a -i test0.ts

 ...
 duration=4.736000
 ...
 }}}

--
Ticket URL: <https://trac.ffmpeg.org/ticket/8806>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list