View Full Version : How to replace a keyframe of a video with a keyframe from another one?
rs3d
25th January 2006, 17:50
This is a visual experiment idea, but nevertheless a complicated
technical task ... I want to exchange the keyframe in one video
with a keyframe of another MPEG4 video. I encoded both with
the same bitrate/resolution and keyframing only every 200 frames.
When replacing the keyframe, theoretically the exchanged picture
would be distorted with the motion of the other video...
I tried some simple binary replacements, but the format is too
complicated and gets corrupted... sometimes broken videos
create a similar effect, I just want to have a certain control
over it.
Has anybody an idea how to do so or maybe another idea
how to transfer a video motion to another video?
Thanks a lot! RS
smallart
26th January 2006, 04:34
Let me restate what you’re asking, because I know the effect that you’re looking for. I too have seen it in broken videos.
What you would like to do is to apply the motion from a video to a still image. (or as you said, the key-frames from another video.)
This happens with certain broken video files when the motion vectors get decoded properly, but the key-frames do not. Watching the motion is what gives you the strange ghosting effect.
You’re right that mpeg4 can get very complicated. You’re method of replacing the raw bits in a video stream is faulty for a number of reasons and not worth getting into. To do what you are asking, you will at the very least need to parse the videos yourself. Rather than augment an existing video, you will have to create a new one altogether as well. You should look into optical flow algorithms, like the kind that are used in video compression, in order to apply them yourself. Sites like citeseer would be a good place to start reading, but you could probably piece together parts of different open source projects to achieve this effect.
rs3d
26th January 2006, 11:10
Yes, that's the main idea... something like the flowing ghost images...
As I'm not a programmer, I'm stuck with existing software. The reason
why I wanted to use a video codec and not some optical flow software
is, that they are really optimized and generate interesting secondary
artefacts... I hoped there is some DIVX repair tool or MPEG4 editor
capable to do so ... optical flow software I know only works with the
movement of a singular frame, not a whole video and replacing this
only results in jittering sequence... But thanks for the ideas!
foxyshadis
26th January 2006, 13:24
If you have an avi, you should be able to use virtualdub to select every frame following a keyframe up to the next, save it to a new avi, and then insert that avi into another somewhere. As long as they're the same size, framerate, and encoded with the same parameters there should be no problem. B-frames throw a monkey wrench in it so you might want to pass on those for the time.
You might need to experiment a bit, depending on the effect you want; high bitrate sources would tend to make the inserted video clearly defined much faster, while low bitrate would just move it all around and make crazy blocks.
rs3d
26th January 2006, 16:08
Virtualdub doesn't write corrupted AVIs what essentially would be
the case. It's always generting a new keyframe so appending isn't
working this way...
rs3d
26th January 2006, 16:24
To quote the documentation: "VirtualDub will not let you write a video
stream with dangling delta frames" ... too bad for me, good for all others ;)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.