Opened 11 years ago

Last modified 8 years ago

#1799 open defect

movie: loop option doesn't seem to work

Reported by: Clément Bœsch Owned by:
Priority: normal Component: avfilter
Version: git-master Keywords: movie
Cc: eric@getvictorious.com Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: yes

Description

Given a small video stream:

./ffmpeg -f lavfi -i testsrc=d=5 -y loopme.mkv

And trying to loop it N times until the output reaches a given duration:

./ffmpeg -f lavfi -i movie=loopme.mkv:loop=0 -t 20 -y out.mkv

...leads to an infinite loop. All the frames >126 are dropped (the input has 125 frames):

frame=  126 fps= 10 q=32766.0 Lsize=      23kB time=00:00:04.96 bitrate=  38.6kbits/s dup=0 drop=59352 

Complete output:

% ./ffmpeg -f lavfi -i movie=loopme.mkv:loop=0 -t 20 -y out.mkv
ffmpeg version N-45221-g25f44b0 Copyright (c) 2000-2012 the FFmpeg developers
  built on Oct 10 2012 08:57:07 with gcc 4.7 (Debian 4.7.2-3)
  configuration: --enable-gpl --enable-fontconfig --enable-libfreetype --enable-libmp3lame --cc='ccache cc' --extra-cflags=-fstack-protector-all --enable-libx264 --enable-libvorbis --enable-libmodplug --enable-libass --samples=/home/cboesch/fate-samples --prefix=/home/cboesch/src/ff/ffmpeg/ffmpeg_build --enable-x11grab --enable-libvpx
  libavutil      51. 74.100 / 51. 74.100
  libavcodec     54. 65.100 / 54. 65.100
  libavformat    54. 31.100 / 54. 31.100
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 19.102 /  3. 19.102
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 16.100 /  0. 16.100
  libpostproc    52.  1.100 / 52.  1.100
[lavfi @ 0x3288260] Estimating duration from bitrate, this may be inaccurate
Input #0, lavfi, from 'movie=loopme.mkv:loop=0':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (444P / 0x50343434), yuv444p, 320x240 [SAR 1:1 DAR 4:3], 25 tbr, 1k tbn, 1k tbc
[libx264 @ 0x47fd280] using SAR=1/1
[libx264 @ 0x47fd280] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX
[libx264 @ 0x47fd280] profile High 4:4:4 Predictive, level 1.3, 4:4:4 8-bit
[libx264 @ 0x47fd280] 264 - core 123 r2189 35cf912 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - 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=4 threads=12 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=25 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, matroska, to 'out.mkv':
  Metadata:
    encoder         : Lavf54.31.100
    Stream #0:0: Video: h264, yuv444p, 320x240 [SAR 1:1 DAR 4:3], q=-1--1, 1k tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> libx264)
Press [q] to stop, [?] for help
frame=  126 fps= 29 q=32766.0 Lsize=      23kB time=00:00:04.96 bitrate=  38.6kbits/s dup=0 drop=21081   

Change History (9)

comment:1 by Clément Bœsch, 11 years ago

Note that it's easy to add a loop option in the file protocol. It will only work with concatenable streams though. I'll submit a patch later.

comment:2 by Cigaes, 11 years ago

Analyzed by developer: set
Reproduced by developer: set
Status: newopen
Version: unspecifiedgit-master

In fact, the loop option works, but the timestamps are reset for each iteration, and that leads ffmpeg to drop frames.

We could fix movie to update the timestamps for each loop iteration, adding the timestamp of the end of the previous iteration. But I am not sure it is the right thing to do: the same problem will happen if movie is used with a VOB file with a timestamp reset in the middle, for example.

comment:3 by Elon Musk, 11 years ago

Can this still be reproduced?, I remember Michael fixed something similar.

comment:4 by Stylpe, 11 years ago

Yes, this still happens, tested this build with the same command (but an mp4 video): http://ffmpeg.gusari.org/static/64bit/ffmpeg.static.64bit.2013-02-27.tar.gz

Pretty much the same output:

$ ./ffmpeg -f lavfi -i movie=../bunny.mp4:loop=0 -t 20 -y out.mkv
ffmpeg version N-50337-g5d2f2c7 Copyright (c) 2000-2013 the FFmpeg developers
  built on Feb 27 2013 05:23:05 with gcc 4.6 (Debian 4.6.3-1)
  configuration: --prefix=/root/ffmpeg-static/64bit --extra-cflags='-I/root/ffmpeg-static/64bit/include -static' --extra-ldflags='-L/root/ffmpeg-static/64bit/lib -static' --extra-libs='-lxml2 -lexpat -lfreetype' --enable-static --disable-shared --disable-ffserver --disable-doc --enable-bzlib --enable-zlib --enable-postproc --enable-runtime-cpudetect --enable-libx264 --enable-gpl --enable-libtheora --enable-libvorbis --enable-libmp3lame --enable-gray --enable-libass --enable-libfreetype --enable-libopenjpeg --enable-libspeex --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-version3 --enable-libvpx
  libavutil      52. 17.103 / 52. 17.103
  libavcodec     54. 92.100 / 54. 92.100
  libavformat    54. 63.100 / 54. 63.100
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 41.100 /  3. 41.100
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
[lavfi @ 0x3800620] Estimating duration from bitrate, this may be inaccurate
Input #0, lavfi, from 'movie=../bunny.mp4:loop=0':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 24 tbr, 24 tbn, 24 tbc
[libx264 @ 0x49b7500] using SAR=1/1
[libx264 @ 0x49b7500] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX
[libx264 @ 0x49b7500] profile High, level 3.0
[libx264 @ 0x49b7500] 264 - core 129 r2230 1cffe9f - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - 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=12 lookahead_threads=2 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=24 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
  Metadata:
    encoder         : Lavf54.63.100
    Stream #0:0: Video: h264 (H264 / 0x34363248), yuv420p, 640x360 [SAR 1:1 DAR 16:9], q=-1--1, 1k tbn, 24 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> libx264)
Press [q] to stop, [?] for help
frame=  121 fps=2.6 q=-1.0 Lsize=     249kB time=00:00:04.95 bitrate= 412.1kbits/s dup=0 drop=135403

I've been trying to do something similar to produce a persistent test live stream, with the same results (the video just hangs when consuming it)

comment:5 by Carl Eugen Hoyos, 11 years ago

Keywords: movie added

comment:6 by Carl Eugen Hoyos, 11 years ago

Summary: loop option doesn't seem to workmovie: loop option doesn't seem to work

comment:7 by Roger Pack, 10 years ago

does this still fail?

comment:8 by Matt, 9 years ago

It still doesn't seem to be working for me. Is this something that is likely to be fixed?

The reason I am looking to use this is that I would like to loop a short clip and generate an HLS output for testing purposes (I'd rather use a looping video clip rather than a live stream from a device).

comment:9 by eric, 8 years ago

Cc: eric@getvictorious.com added
Note: See TracTickets for help on using tickets.