user14469: I'm trying to overlay a video on top of an image. The problem that I'm facing is that the video duration that I want is longer than my input video's duration.
To solve this issue, I try to generate a streaming loop and hardcode the duration that I want using the parameter "t".
I'm using the setpts filter to make sure that my container format (.mp4) accepts past frames by rewriting their timestamps:
ffmpeg -loop 1 -i image.jpg -stream_loop -1 -i video.mov  -filter_complex "[1:v]setpts=N/(FRAME_RATE*TB)[1v];[0:v][1v]overlay=x=main_w*0.44:y=main_h*0.33[out]" -map [out] -t 00:00:15  out.mp4

So the command reads as follows:

take one infinite input where each frame is image.jpg
take another infinite input (video.mov) by looping (-stream_loop -1)

Each frame will go through the filter:

setpts will re-write the timestamps for source 1 (video.mov)
overlay will put each setpts-ed frame from video.mov on top of each frame from the initial input (image.jpg - 0:v)

This should continue until a file with 00:00:15 seconds is created.
This command does generate that file but the video.mov isn't looped, once the first loop finishes the last frame is repeated until the output movie ends.
FYI: I made a couple more tests:
ffmpeg -stream_loop -1 -i movie.mov -filter_complex "[0:v]setpts=N/(FRAME_RATE*TB)[out]" -map [out] -t 00:00:30 output.mp4

This works fine, it generates a movie with 30 seconds duration with the input movie looped to fill the output movie
on the other hard, if I add one more input file:
ffmpeg -stream_loop -1 -i movie.mov -loop 1 -i image.jpg -filter_complex "[0:v]setpts=N/(FRAME_RATE*TB)[out]" -map [out] -t 00:00:30 output.mp4

This will not create a movie with 30 seconds, although one of the inputs is never used, ffmpeg creates a movie file with just one loop of movie.mov and the same length of movie.mov.
Any advices please ?
Thank you very much!
Ze

user1871: Try with the movie filter instead
ffmpeg -loop 1 -i image.jpg -filter_complex \
        "movie=video.mov:loop=999,setpts=N/(FRAME_RATE*TB)[1v]; \
        [0:v][1v]overlay=x=main_w*0.44:y=main_h*0.33[out]" \
       -map [out] -t 00:00:15  out.mp4


14469: <p>I'm trying to overlay a video on top of an image. The problem that I'm facing is that the video duration that I want is longer than my input video's duration.</p>

<p>To solve this issue, I try to generate a streaming loop and hardcode the duration that I want using the parameter "t".</p>

<p>I'm using the setpts filter to make sure that my container format (.mp4) accepts past frames by rewriting their timestamps:</p>

<pre><code>ffmpeg -loop 1 -i image.jpg -stream_loop -1 -i video.mov  -filter_complex "[1:v]setpts=N/(FRAME_RATE*TB)[1v];[0:v][1v]overlay=x=main_w*0.44:y=main_h*0.33[out]" -map [out] -t 00:00:15  out.mp4
</code></pre>

<p>So the command reads as follows:</p>

<ol>
<li>take one infinite input where each frame is image.jpg</li>
<li>take another infinite input (video.mov) by looping (-stream_loop -1)</li>
</ol>

<p>Each frame will go through the filter:</p>

<ul>
<li>setpts will re-write the timestamps for source 1 (video.mov)</li>
<li>overlay will put each setpts-ed frame from video.mov on top of each frame from the initial input (image.jpg - 0:v)</li>
</ul>

<p>This should continue until a file with 00:00:15 seconds is created.</p>

<p>This command does generate that file but the video.mov isn't looped, once the first loop finishes the last frame is repeated until the output movie ends.</p>

<p>FYI: I made a couple more tests:</p>

<pre><code>ffmpeg -stream_loop -1 -i movie.mov -filter_complex "[0:v]setpts=N/(FRAME_RATE*TB)[out]" -map [out] -t 00:00:30 output.mp4
</code></pre>

<p>This works fine, it generates a movie with 30 seconds duration with the input movie looped to fill the output movie</p>

<p>on the other hard, if I add one more input file:</p>

<pre><code>ffmpeg -stream_loop -1 -i movie.mov -loop 1 -i image.jpg -filter_complex "[0:v]setpts=N/(FRAME_RATE*TB)[out]" -map [out] -t 00:00:30 output.mp4
</code></pre>

<p>This will not create a movie with 30 seconds, although one of the inputs is never used, ffmpeg creates a movie file with just one loop of movie.mov and the same length of movie.mov.</p>

<p>Any advices please ?</p>

<p>Thank you very much!</p>

<p>Ze</p>
 1871: <p>Try with the movie filter instead</p>

<pre><code>ffmpeg -loop 1 -i image.jpg -filter_complex \
        "movie=video.mov:loop=999,setpts=N/(FRAME_RATE*TB)[1v]; \
        [0:v][1v]overlay=x=main_w*0.44:y=main_h*0.33[out]" \
       -map [out] -t 00:00:15  out.mp4
</code></pre>
