[FFmpeg-user] Video in video not from start
Cecil Westerhof
Cecil at decebal.nl
Fri Jan 5 13:40:27 EET 2024
Cecil Westerhof via ffmpeg-user <ffmpeg-user at ffmpeg.org> writes:
> Cecil Westerhof via ffmpeg-user <ffmpeg-user at ffmpeg.org> writes:
>
>> Ferdi Scholten <ferdi at sttc-nlp.nl> writes:
>>
>>> I want to play a video in a video from a certain point. I understood I
>>>> could do something like:
>>>> ffmpeg \
>>>> -i input1.mp4 \
>>>> -i input2.mp4 \
>>>> -filter_complex "
>>>> [0:v][1:v] overlay=25:25:
>>>> enable='between(t,8,20)'
>>>> " \
>>>> -pix_fmt yuv420p \
>>>> -c:a copy \
>>>> output.mp4
>>>>
>>>> But this starts input2.mp4 from the start of input2.mp4 on the 8
>>>> second, for twelve seconds.
>>>> Is it possible to let input2.mp4 not start from second 0, but from
>>>> second 17?
>>>>
>>> Try putting -ss 17 between the two inputs.
>>
>> I was thinking about that. But that means that if I want to use
>> input2.mp4 several times, I should use input2.mp4 several times with
>> the correct -ss. Not really a problem, but I had hoped for a more
>> efficient way. But I will use it like this for the moment then.
>> Thanks.
>
> At the moment I have:
> ffmpeg -y \
> -to 30 -i "${inputFile}" \
> -ss 11 -to 28 -i "${overlayFile}" \
> -filter_complex "
> [0:v][1:v] overlay=main_w-(overlay_w+10):10:
> enable='between(t,8,25)'
> " \
> -pix_fmt yuv420p \
> -acodec libmp3lame \
> -vcodec libx264 \
> -preset veryfast \
> -crf 26 \
> "${outputFile}"
>
> It works, but I have a question and found a problem.
…
> In my search to find this solution, I think I saw a method to scale
> the overlay file. But I cannot find it anymore. :'-(
> Am I mistaken, or is it possible? I would like to scale the overlay
> file to 640:-2.
I found the solution I think:
ffmpeg -y \
-to 30 -i "${inputFile}" \
-ss 11 -to 28 -i "${overlayFile}" \
-filter_complex "
[1:v] scale=960:-2[scaled:v],
[0:v][scaled:v] overlay=main_w-(overlay_w+10):10:
enable='between(t,8,25)'
" \
-pix_fmt yuv420p \
-acodec libmp3lame \
-vcodec libx264 \
-preset veryfast \
-crf 26 \
"${outputFile}"
I needed another scale as I thought.
It looks like the end part of the overlay is not displayed correctly,
but I will look into that.
--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
More information about the ffmpeg-user
mailing list