FFMPEG,itsoffset with overlay命令不能正常工作 [英] FFMPEG, itsoffset with overlay command not working as it supposed to
问题描述
./ ffmpeg -i first.MOV -i second.MOV -filter_complexnullsrc = size = 1280x400:duration = 30 [bg]; [0] scale = 640:-1,pad = 1280:400 [first]; [bg] [first] overlay = 0:0 [base]; [1] scale = 640:-1 [second]; [base] [second] overlay = 640:0output.mp4
现在我想做的是延迟一个叠加层,直到另一个完成。对于这个,据我所知,命令是itsoffset,所以我修改为使用这个:
./ ffmpeg -i第一。 MOV -itsoffset 5 -i second.MOV -filter_complexnullsrc = size = 1280x400:duration = 30 [bg]; [0] scale = 640:-1,pad = 1280:400 [first]; [bg] overlay = 0:0 [base]; [1] scale = 640:-1 [second]; [base] [second] overlay = 640:0output.mp4
pre>
现在我唯一的问题是,我想显示延迟视频的第一帧,直到它开始...即使在某个地方我读到这应该做,不会。它留空,直到输入开始。
任何想法如何添加第二个视频的第一帧,直到itsoffset启动视频?
Update1:我可能会发现一个骗子,但问题在于第一秒还是很慢。
code> ./ ffmpeg -i first.MOV -i second.MOV -itsoffset 5 -i second.MOV -filter_complexcolor = size = 1280x400:duration = 30 [bg]; [1] select = eq \,0),标度= 640:-1 [FG]; [BG] [FG]叠加= 640:0 [BGC]; [0] =比例640:-1 [第一]; [BGC] [第一] overlay = 0:0 [firstb]; [2] scale = 640:-1 [second]; [firstb] [second] overlay = 640:0output.mp4
pre>
稍后再说,我需要动态创建一个真的很痛苦的命令行字符串。
解决方案对于解决方案,我最终结果如下:
./ ffmpeg -i first.MOV -i second.MOV -itsoffset 5 -i second.MOV -filter_complexcolor = size = 1280x400:duration = 30 [bg]; [1] select =当量(n\,0),标度= 640:-1 [FG]; [BG] [FG]叠加= 640:0 [BGC]; [0] =比例640:-1 [第一]; [BGC] [first] overlay = 0:0 [firstb]; [2] scale = 640:-1 [second]; [firstb] [second] overlay = 640:0output.mp4
我遇到的唯一问题是,由于某种原因,音频不会延迟,重叠的图像滞后,时间步长有点混乱向上。最后我只是想出我需要使用-async 1,它开始像魔术一样工作。第一帧显示从开始,音频延迟与视频等。
所以最终的命令应该如下所示:
./ ffmpeg -i first.MOV -i second.MOV -itsoffset 5 -i second.MOV -filter_complexcolor = size = 1280x400:duration = 30 [BG]; [1]选择=当量(n\,0),标度= 640:-1 [FG]; [BG] [FG]叠加= 640:0 [BGC]; [0] =规模640:-1 [first]; [bgc] [first] overlay = 0:0 [firstb]; [2] scale = 640:-1 [second]; [firstb] [second] overlay = 640:0 1 output.mp4
I managed to overlay two videos one by another with the overlay command and use a nullsrc command to play both video till both of them ended with the following command:
./ffmpeg -i first.MOV -i second.MOV -filter_complex "nullsrc=size=1280x400:duration=30[bg];[0]scale=640:-1,pad=1280:400[first];[bg][first]overlay=0:0[base];[1]scale=640:-1[second];[base][second]overlay=640:0" output.mp4
Now what I wanted to do is to delay one of the overlay till the other one finishes. For this as far as I know the command is itsoffset, so I modified to use this:
./ffmpeg -i first.MOV -itsoffset 5 -i second.MOV -filter_complex "nullsrc=size=1280x400:duration=30[bg];[0]scale=640:-1,pad=1280:400[first];[bg][first]overlay=0:0[base];[1]scale=640:-1[second];[base][second]overlay=640:0" output.mp4
Now my only problem with this is that I want to show the first frame of the delayed video till it starts... And even though somewhere I read that this should do it, it won't. It leaves it blank till the input starts.
Any idea how could I add the first frame of second video till the itsoffset starts the video?
Update1: I may found a cheat around it, but the problem with it it's really slow in the first second or so.
./ffmpeg -i first.MOV -i second.MOV -itsoffset 5 -i second.MOV -filter_complex "color=size=1280x400:duration=30[bg];[1]select=eq(n\,0),scale=640:-1[fg];[bg][fg]overlay=640:0[bgc];[0]scale=640:-1[first];[bgc][first]overlay=0:0[firstb];[2]scale=640:-1[second];[firstb][second]overlay=640:0" output.mp4
Not to mention later on I need to dynamically create the command line string which would be really painful like this.
解决方案For solution I ended up something like this:
./ffmpeg -i first.MOV -i second.MOV -itsoffset 5 -i second.MOV -filter_complex "color=size=1280x400:duration=30[bg];[1]select=eq(n\,0),scale=640:-1[fg];[bg][fg]overlay=640:0[bgc];[0]scale=640:-1[first];[bgc][first]overlay=0:0[firstb];[2]scale=640:-1[second];[firstb][second]overlay=640:0" output.mp4
The only problem with this I got was that for some reason the audio waasn't delayed and the overlaying images got lagging and the timestep was a bit messed up. Finally I just figured out that I need to use -async 1 and it started working like a magic. First frame showing up from the begining, audio delayed with video etc.
So the final command should look like this:
./ffmpeg -i first.MOV -i second.MOV -itsoffset 5 -i second.MOV -filter_complex "color=size=1280x400:duration=30[bg];[1]select=eq(n\,0),scale=640:-1[fg];[bg][fg]overlay=640:0[bgc];[0]scale=640:-1[first];[bgc][first]overlay=0:0[firstb];[2]scale=640:-1[second];[firstb][second]overlay=640:0" -async 1 output.mp4
这篇关于FFMPEG,itsoffset with overlay命令不能正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!