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.
If it were me, I'd look into something that would do something along these lines:
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).
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).
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.