ffmpeg: How to add frames or black at the end of a video?

我的梦境 提交于 2019-12-10 11:07:40

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/10530538/ffmpeg-how-to-add-frames-or-black-at-the-end-of-a-video

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!