Opened 7 weeks ago
Last modified 7 weeks ago
#11337 new defect
Counter-intuitive "asegment" behavior of relative timestamps
Reported by: | pablo | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | avfilter |
Version: | git-master | Keywords: | asegment |
Cc: | pablo, MasterQuestionable | Blocked By: | |
Blocking: | Reproduced by developer: | yes | |
Analyzed by developer: | yes |
Description
Summary of the bug: asegment with relative timestamps produces segments with wrong duration. Absolute timestamps works as exepcted.
How to reproduce:
Use the first wav from here:
https://www2.cs.uic.edu/~i101/SoundFiles/
The third segment has duration N/A.
ffmpeg -i BabyElephantWalk60.wav -filter_complex "asegment=timestamps=1000ms|+1000ms|+1000ms[1][2][3][4]" -map "[1]" test1.wav -map "[2]" test2.wav -map "[3]" test3.wav -map "[4]" test4.wav ffmpeg version 5.1.6-0+deb12u1 Copyright (c) 2000-2024 the FFmpeg developers built with gcc 12 (Debian 12.2.0-14) configuration: --prefix=/usr --extra-version=0+deb12u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --disable-sndio --enable-libjxl --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-libplacebo --enable-librav1e --enable-shared libavutil 57. 28.100 / 57. 28.100 libavcodec 59. 37.100 / 59. 37.100 libavformat 59. 27.100 / 59. 27.100 libavdevice 59. 7.100 / 59. 7.100 libavfilter 8. 44.100 / 8. 44.100 libswscale 6. 7.100 / 6. 7.100 libswresample 4. 7.100 / 4. 7.100 libpostproc 56. 6.100 / 56. 6.100 Guessed Channel Layout for Input Stream #0.0 : mono Input #0, wav, from 'BabyElephantWalk60.wav': Duration: 00:01:00.00, bitrate: 352 kb/s Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 22050 Hz, mono, s16, 352 kb/s Stream mapping: Stream #0:0 (pcm_s16le) -> asegment:default asegment -> Stream #0:0 (pcm_s16le) asegment -> Stream #1:0 (pcm_s16le) asegment -> Stream #2:0 (pcm_s16le) asegment -> Stream #3:0 (pcm_s16le) Press [q] to stop, [?] for help Output #0, wav, to 'test1.wav': Metadata: ISFT : Lavf59.27.100 Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 22050 Hz, mono, s16, 352 kb/s Metadata: encoder : Lavc59.37.100 pcm_s16le Output #1, wav, to 'test2.wav': Metadata: ISFT : Lavf59.27.100 Stream #1:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 22050 Hz, mono, s16, 352 kb/s Metadata: encoder : Lavc59.37.100 pcm_s16le Output #2, wav, to 'test3.wav': Metadata: ISFT : Lavf59.27.100 Stream #2:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 22050 Hz, mono, s16, 352 kb/s Metadata: encoder : Lavc59.37.100 pcm_s16le Output #3, wav, to 'test4.wav': Metadata: ISFT : Lavf59.27.100 Stream #3:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 22050 Hz, mono, s16, 352 kb/s Metadata: encoder : Lavc59.37.100 pcm_s16le size= 43kB time=00:01:00.00 bitrate= 5.9kbits/s speed=3.19e+03x video:0kB audio:2584kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
You can also try:
ffmpeg -v verbose -y -lavfi "sine=d=10,asegment=timestamps=1|+1|+1" -c:a pcm_s16le out.mka 2>&1
ffmpeg -v verbose -y -lavfi "sine=d=10,asegment=timestamps=1|+2|+2" -c:a pcm_s16le out.mka 2>&1
Change History (3)
comment:1 by , 7 weeks ago
Analyzed by developer: | set |
---|---|
Cc: | added |
Component: | undetermined → avfilter |
Keywords: | asegment added |
Summary: | asegment with relative timestamps creates segments with wrong duration → "asegment" with relative timestamps created segments of wrong duration |
Version: | unspecified → 5.1.4 |
comment:2 by , 7 weeks ago
Reproduced by developer: | set |
---|---|
Version: | 5.1.4 → git-master |
I can reproduce this. The issue here appears that the second +1
is relative to the first absolute timestamp. This means something like 'sine=d=10,asegment=1|+1|+1
is creating the last segment as having the same offset as the second-to-last segment, so the second-to-last segment has zero duration. Which any encoder fails to encode (you can try with -f null -
, for example).
Try something like this:
ffmpeg -v verbose -lavfi 'sine=d=10,asegment=timestamps=1|+1|+4[a0][a1][a2][a3]' -map '[a0]' -map '[a1]' -map '[a2]' -map '[a3]' -f null -
The last segment should start 6 seconds after the initial one, but it actually starts 5 seconds after the initial one.
comment:3 by , 7 weeks ago
Summary: | "asegment" with relative timestamps created segments of wrong duration → Counter-intuitive "asegment" behavior of relative timestamps |
---|
͏ Try later versions? (prominently, "git-master")
͏ Reference:
͏ https://ffmpeg.org/ffmpeg-filters.html#segment_002c-asegment