美文网首页
ffmpeg # 画中画中的视频进行循环

ffmpeg # 画中画中的视频进行循环

作者: FlyingPenguin | 来源:发表于2019-03-25 17:10 被阅读0次
    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显示一遍,不再重复最后一帧。

    References:

    https://stackoverflow.com/questions/47562747/loop-overlay-input-video
    https://ffmpeg.org/ffmpeg-filters.html#framesync

    相关文章

      网友评论

          本文标题:ffmpeg # 画中画中的视频进行循环

          本文链接:https://www.haomeiwen.com/subject/geebvqtx.html