ffmpeg:如何在视频结尾添加帧或黑色? [英] ffmpeg: How to add frames or black at the end of a video?

查看:1302
本文介绍了ffmpeg:如何在视频结尾添加帧或黑色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在任何视频结尾复制最后一帧的任意数量的副本?或者,如何在任何视频的末尾添加黑框?这可以通过脚本和ffmpeg来完成吗?当然,任何其他工具都可以,只要该操作是可脚本化的。



难度在于所有视频格式,或者至少可以使用尽可能多的视频格式应该得到支持。脚本应该采用任何视频格式,而无需手动更改每个视频的脚本。

解决方案

查看FFMpeg文档连接,看看你能想出什么。


如何加入视频文件?


如果是我,我会研究一些可以按照这些行做的事情:


  1. 使用预制您想要添加的黑色框架的视频(与要添加的视频相同的文件夹),并检查视频是否具有相同的格式。我将这个预制视频制作为常用的默认格式,并具有连接(MPEG)的功能。


  2. 如果视频不同格式,找出您要添加的视频的格式,并使用ffmpeg将其编码为与黑色视频相同的格式。您还可以检查您要添加的视频是否以适当的格式进行连接,只需将黑色视频更改为该格式即可(也可能只有一堆预制的黑色视频,允许所有格式允许连接)。


  3. 一旦这两个视频格式相同,连接它们。如果要使用不同的格式,请再次使用ffmpeg将其编码为您的选择。请注意,根据ffmpeg文档,-same_quant选项或高比特率设置应被传递到ffmpeg以通过所有转换保持高质量。


如果你可以让这个工作的唯一缺点是,你必须单独制作你添加的框架的视频,而不是在飞行中或按照命令。 / p>

How to copy an arbitrary amount of duplicates of the last frame at the end of any video? Or alternatively, how to add black frames at the end of any video? Can this be done by scripting and ffmpeg? Of course any other tool is fine, as long as the action is scriptable.

The difficulty is that all video formats, or at least as wide range of video formats as possible, should be supported. The script should take in any video formats without manually changing the script per video.

解决方案

Take a look at the FFMpeg documentation for concatenating, and see what you can come up with.

How can I join video files?

If it were me, I'd look into something that would do something along these lines:

  1. Use a pre-made video of the black frames you're trying to add on to the end (in the same folder as the video you're adding it to) and check if the videos have the same format. I'd make this pre-made video a default format that is commonly used and has the ability to be concatenated (MPEG).

  2. If the videos have different formats, figure out the format of the video you're adding to and use ffmpeg to encode it to the same format as your black video. You could also check if the video you're adding to is in a proper format for concatenating, and just change the black video to that format for speed (could also just have a bunch of pre-made black videos of all the formats that allow concatenating).

  3. Once both videos are in the same format, concatenate them. If you want them in a different format, use ffmpeg again to encode them to your choice. Note that the -same_quant option or a high bit-rate setting should be passed into ffmpeg to keep a high quality through all conversions, as per the ffmpeg documentation.

The only downside here if you can get this to work is that you'd have to make the video of the frames you're adding on separately instead of on the fly or by command.

这篇关于ffmpeg:如何在视频结尾添加帧或黑色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆