Log in

View Full Version : ? Cutting AVI in Bitwise Identical Manner (at non-keyframes)


Synetech
23rd January 2008, 01:59
Hi,

I am trying to find a way to cut an AVI such that the bytes in the resulting video—the part that is kept aside from the header, etc.—are identical to the original. I have been using the v/nandub, etc. applications in direct stream copy mode to cut videos for a long time, but the videos that are made are not identical. In other words, when you do a binary comparison of the two files, you should get a few small differences in the header or whatever, and the original should be longer, but otherwise the files should be identical (ie, changes could be made with a hex-editor, like you can with an MP3 as long as you cut on a frame-boundary).

For example, let’s say that I have made a large video (eg 1GB), and am sharing it via FTP, P2P, HTTP, etc. (basically any resumable transfer method). I then decide to cut out the last minute of the video. Doing it like I have been doing causes the file to be drastically altered even if the resulting image and sound are identical. This means that people who have gotten only part of the video cannot use what they have and must start downloading it all over from scratch (and thus wasting my bandwidth).


Also, sometimes I run into the situation where I need to cut a video where there is no keyframe but cannot figure out how. I know I’ve done it a couple of times by chance with one of the dub apps and with another commercial app, but it never works when I purposely try to do it. Will re-deriving the keyframes work? If so, it will create a non-identical file right? This isn’t a high priority; I can keep a little extra.


Thanks a lot.

foxyshadis
23rd January 2008, 07:11
You're going to have to write a custom app to do this. Parse the header & index, cut where you want, rewrite the header without adding or removing anything and recreate the index. All other tools will interleave the file differently, unless you do something like mux it via virtualdub, cut it, and then mux again (should be essentially the same if it's tightly controlled). You don't have to rewrite the header, if you're just resuming files, it just has some values like total size & # of frames that make it simpler.

Synetech
23rd January 2008, 07:29
That’s pretty much what I’m told. :( I don’t understand why there aren’t already any apps that can cut a video cleanly, making as few modifications as possible.

Why are people so willing to allow apps to make all kinds of changes (the least of which is metadata) to a file for what should be a minor and trivial change? I’m sure that if there were enough demand, someone would have already written it. Imagine if in the days of celluloid, simply wanting to trim off a couple of seconds of film required exposing a new film to the negative instead of just snipping the existing one with a blade.