ffmpeg # 画中画中的视频进行循环
ffmpeg -i bunny.mp4 -vf "movie=test.mov[logo];[0:v][logo]overlay=x=100:y=100" -y out.mp4
以上命令test.mov,只显示1遍,后边重复显示最后一帧。
如果想让test.mov一直循环呢? 添加:loop=0,setpts=N/FRAME_RATE/TB即可。
ffmpeg -i bunny.mp4 -vf "movie=test.mov:loop=0,setpts=N/FRAME_RATE/TB[logo];[0:v][logo]overlay=x=100:y=100" -y out.mp4
Zero loop= arguments means infinity loop. Values greater zero sets repeat counts. setpts filters required for PTS adjusting for second and later repeats, otherwise most output muxers will fails with non-monotonic PTS increasing: loop does not recalc PTS.
loop=0表示无限循环,如果后边跟的是数字,则表示循环几遍。
setpts filters用于调整后续显示的pts。
另外,如果只想test.mov显示一遍,然后不显示呢?
Some filters with several inputs support a common set of options. These options can only be set by name, not with the short notation.
eof_action
The action to take when EOF is encountered on the secondary input; it accepts one of the following values:
repeat
Repeat the last frame (the default). (默认的 重复最后一帧)
endall
End both streams.
pass
Pass the main input through.
shortest
If set to 1, force the output to terminate when the shortest input terminates. Default value is 0.
repeatlast
If set to 1, force the filter to extend the last frame of secondary streams until the end of the primary stream. A value of 0 disables this behavior. Default value is 1.
利用eof_action即可控制只显示一遍。
ffmpeg -i bunny.mp4 -vf "movie=test.mov[logo];[0:v][logo]overlay=x=100:y=100:eof_action=pass" -vframes 1000 -y out.mp4
用以上命令,即可实现test.mov显示一遍,不再重复最后一帧。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了