How to replace a keyframe with another image
Created by: Krulvis
I'm trying to do some data moshing and I would like to be able to replace the only keyframe of a video with a custom png, such that the delta frames following the key frame affect the replaced frame. First I convert the target video using YUV420 and settings such that there will only be 1 keyframe:
process1 = (
ffmpeg
.input(input_video)
.output(target_avi, r=fps, b=500000, g=fps * (end_sec - start_sec), pix_fmt='yuv420p', keyint_min=999999,
ss=start_sec, to=end_sec)
.run(overwrite_output=True)
)
However, I dont know how to replace the single left over keyframe with a custom PNG, any help is appreciated!
To be clear, I dont want to overwrite simply using .overlay(overlay_ffmpeg, eof_action='pass')
as this just overlays the video with a png image, I want the video to consist of only p-frames to be able to have the inserted png be morphed by the p-frames.