Opened 6 years ago
Closed 6 years ago
#7043 closed defect (duplicate)
stream_loop doesn't work when number of input files is more than 1.
| Reported by: | Gyan | Owned by: | |
|---|---|---|---|
| Priority: | normal | Component: | undetermined |
| Version: | git-master | Keywords: | |
| Cc: | Blocked By: | ||
| Blocking: | Reproduced by developer: | no | |
| Analyzed by developer: | no |
Description
For commands with a single input file (with or without sources created in filter_complex), stream_loop works fine. When more inputs are added, the option has no effect.
This is related to if the input is packetized using threads i.e. if av_read_frame processes the input, looping occurs; if get_input_packet_mt does it, no looping.
How to reproduce
1) Generate sources
ffmpeg -f lavfi -i testsrc2 -t 1 v.mp4
ffmpeg -f lavfi -i sine -t 5 a.mp4
2a) Single input --> loops
ffmpeg -stream_loop -1 -i v.mp4 -c copy -t 5 v-t5-copy.mp4
ffmpeg version N-90094-ga877d22d9a Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7.3.0 (Rev1, Built by MSYS2 project)
configuration: --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-fontconfig --enable-libass --enable-libbluray --enable-libfreetype --enable-libmfx --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libwavpack --enable-libwebp --enable-libxml2 --enable-libzimg --enable-libshine --enable-gpl --enable-openssl --enable-avisynth --enable-chromaprint --enable-decklink --enable-frei0r --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libfdk-aac --enable-libflite --enable-libfribidi --enable-libgme --enable-libgsm --enable-libilbc --enable-libkvazaar --enable-libmodplug --enable-libopenh264 --enable-libopenmpt --enable-librtmp --enable-librubberband --enable-libssh --enable-libtesseract --enable-libxavs --enable-libxvid --enable-libzmq --enable-libzvbi --enable-opencl --enable-opengl --enable-libvmaf --extra-cflags=-fopenmp --extra-libs=-lgomp --extra-cflags=-DLIBTWOLAME_STATIC --extra-libs=-lstdc++ --extra-cflags=-DLIBSSH_STATIC --extra-ldflags='-Wl,--allow-multiple-definition' --extra-cflags=-DCACA_STATIC --extra-cflags=-DMODPLUG_STATIC --extra-cflags=-DCHROMAPRINT_NODLL --extra-libs=-lstdc++ --extra-cflags=-DZMQ_STATIC --extra-libs=-lpsapi --extra-cflags=-DLIBXML_STATIC --disable-w32threads --extra-cflags=-DKVZ_STATIC_LIB --enable-version3 --enable-nonfree --disable-debug
libavutil 56. 7.101 / 56. 7.101
libavcodec 58. 11.101 / 58. 11.101
libavformat 58. 9.100 / 58. 9.100
libavdevice 58. 1.100 / 58. 1.100
libavfilter 7. 12.100 / 7. 12.100
libswscale 5. 0.101 / 5. 0.101
libswresample 3. 0.101 / 3. 0.101
libpostproc 55. 0.100 / 55. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'v.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.9.100
Duration: 00:00:01.00, start: 0.000000, bitrate: 295 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 286 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Output #0, mp4, to 'v-t5-copy.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.9.100
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 320x240 [SAR 1:1 DAR 4:3], q=2-31, 286 kb/s, 25 fps, 25 tbr, 12800 tbn, 12800 tbc (default)
Metadata:
handler_name : VideoHandler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame= 127 fps=0.0 q=-1.0 Lsize= 185kB time=00:00:04.96 bitrate= 304.8kbits/s speed=6.44e+003x
video:182kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.282910%
2b) Multiple inputs --> doesn't loop
ffmpeg -stream_loop -1 -i v.mp4 -i a.mp4 -c copy va.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'v.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.9.100
Duration: 00:00:01.00, start: 0.000000, bitrate: 295 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 286 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'a.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
encoder : Lavf58.9.100
Duration: 00:00:05.02, start: 0.000000, bitrate: 76 kb/s
Stream #1:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 74 kb/s (default)
Metadata:
handler_name : SoundHandler
Output #0, mp4, to 'va.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.9.100
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 320x240 [SAR 1:1 DAR 4:3], q=2-31, 286 kb/s, 25 fps, 25 tbr, 12800 tbn, 12800 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 74 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #1:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 25 fps=0.0 q=-1.0 Lsize= 83kB time=00:00:04.99 bitrate= 136.7kbits/s speed=5.17e+003x
video:35kB audio:45kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 3.544024%
2c) Single input + lavfi --> loops
ffmpeg -stream_loop -1 -i v.mp4 -lavfi sine -c:v copy -t 5 vlavfi.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'v.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.9.100
Duration: 00:00:01.00, start: 0.000000, bitrate: 295 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 286 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream mapping:
sine -> Stream #0:0 (aac)
Stream #0:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
Output #0, mp4, to 'vlavfi.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.9.100
Stream #0:0: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 69 kb/s (default)
Metadata:
encoder : Lavc58.11.101 aac
Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 320x240 [SAR 1:1 DAR 4:3], q=2-31, 286 kb/s, 25 fps, 25 tbr, 12800 tbn, 12800 tbc (default)
Metadata:
handler_name : VideoHandler
frame= 127 fps=0.0 q=-1.0 Lsize= 233kB time=00:00:05.01 bitrate= 381.0kbits/s speed=92.8x
video:182kB audio:45kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.428679%
3) Multiple inputs, with threading disabled --> loops
ffmpeg-wip -stream_loop -1 -i v.mp4 -i a.mp4 -c:v copy -t 5 va-copy-nothreads.mp4
ffmpeg version N-90168-gc0919c4985-2018-02-24 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7.3.0 (Rev1, Built by MSYS2 project)
configuration: --disable-everything --disable-doc --enable-protocols --enable-indev=lavfi --enable-demuxer='image2,matroska,mov,mp3,mpegps,mpegts,mxf,nut,rawvideo,wav' --enable-parser=mpegvideo --enable-decoder='aac,h264,mjpeg,mp2,mp3,mpeg2video,mpeg4,pcm_dvd,pcm_s16be,pcm_s16le,png,rawvideo' --enable-filters --enable-encoder='aac,flac,libmp3lame,mjpeg,mpeg2video,mpeg4,mp2,pcm_s16be,pcm_s16le,png,rawvideo,wrapped_avframe' --enable-muxer='adts,avi,image2,matroska,mp3,mp4,mpeg1system,mpeg1vcd,mpeg2dvd,mpeg2svcd,mpeg2vob,mpegts,mxf,mxf_d10,mxf_opatom,null,nut,rawvideo,wav' --enable-outdev=sdl2 --enable-libfreetype --enable-libmp3lame --disable-w32threads --disable-pthreads --enable-static --disable-shared --extra-ldflags=-static --pkg-config-flags=--static --enable-gpl --enable-version3 --extra-version=2018-02-24 --progs-suffix=-wip
libavutil 56. 7.101 / 56. 7.101
libavcodec 58. 13.100 / 58. 13.100
libavformat 58. 10.100 / 58. 10.100
libavdevice 58. 2.100 / 58. 2.100
libavfilter 7. 12.100 / 7. 12.100
libswscale 5. 0.101 / 5. 0.101
libswresample 3. 0.101 / 3. 0.101
libpostproc 55. 0.100 / 55. 0.100
[h264 @ 0000000000478f00] Warning: not compiled with thread support, using thread emulation
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'v.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.9.100
Duration: 00:00:01.00, start: 0.000000, bitrate: 295 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 286 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
[aac @ 00000000004687c0] Warning: not compiled with thread support, using thread emulation
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'a.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
encoder : Lavf58.9.100
Duration: 00:00:05.02, start: 0.000000, bitrate: 76 kb/s
Stream #1:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 74 kb/s (default)
Metadata:
handler_name : SoundHandler
[aac @ 00000000002fa000] Warning: not compiled with thread support, using thread emulation
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #1:0 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[aac @ 0000000002f10a80] Warning: not compiled with thread support, using thread emulation
Output #0, mp4, to 'va-copy-nothreads.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.10.100
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 320x240 [SAR 1:1 DAR 4:3], q=2-31, 286 kb/s, 25 fps, 25 tbr, 12800 tbn, 12800 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 69 kb/s (default)
Metadata:
handler_name : SoundHandler
encoder : Lavc58.13.100 aac
frame= 127 fps=0.0 q=-1.0 Lsize= 232kB time=00:00:05.01 bitrate= 378.1kbits/s speed= 70x
video:182kB audio:44kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.442461%
With threading, the get_input_packet call inside the looping block returns AVERROR_EOF.
If I keep threading enabled and divert packetization of only the looped input to av_read_frame, looping occurs but no. of written video frames is wrong (much higher) and DTS is reported by muxer as non-monotonous.
Change History (2)
comment:1 by , 6 years ago
comment:2 by , 6 years ago
| Resolution: | → duplicate |
|---|---|
| Status: | new → closed |



Related to #6121