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

2019-05-22 15:22发布

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条回答
小情绪 Triste *
2楼-- · 2019-05-22 16:19

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.

查看更多
登录 后发表回答