Log in

View Full Version : How to remove a few frames without re-encoding?


FraGTaLiTy
17th June 2010, 10:14
I need to be able to do two things:

1. Take an mp4 file that was encoded in x264 and muxed with mp3 audio, and separate the audio from the video file so that I have the original mp3 audio file by itself, and the mp4 video by itself. The original encoding and muxing was done in Megui, if that means anything.

2. Take the x264 encoded mp4 file and remove a couple of frames from the video (15-20 frames). (most important step)

Why I need to do this:

A friend of mine recently edited a video. While rendering the credits, he had to split it in 2 halves that would be reconnected later. He did this, but accidentally left a .75 second gap between them (which turned into unwanted black frames).

He did not know this.

So, he encoded the finished product, and deleted all his original files. Now, all he has is the final x264 encode with the audio already muxed to it. And we have a random black spot in the credits that needs to be eliminated. We do not want to re-encode or re-compress because we do not want to lose quality.

All we want to do is, if possible, remove those frames without re-encoding/re-compressing and without altering the file in anyway aside from removing those frames. Then we want detach the audio, and re-mux (which may not be even needed if you can remove those frames without causing "cuts" in the audio).

Is this possible? If so, I will be soo happy.

mp3dom
17th June 2010, 10:18
Try YAMB/MP4BOX (for the 1st question).
As for the second, I don't know the tool. Anyway you can't trim/cut the file where you want, but only when a keyframe occours. This depends by the encoding settings... it could be every second or even every 10 seconds.

FraGTaLiTy
17th June 2010, 10:45
Try YAMB/MP4BOX (for the 1st question).
As for the second, I don't know the tool. Anyway you can't trim/cut the file where you want, but only when a keyframe occours. This depends by the encoding settings... it could be every second or even every 10 seconds.

How can I check? Maybe there was a keyframe at the first black frame and last black frame :D

edit. Software worked perfect for extracting the audio. As for eliminating those frames, no go :/ I suppose it's because the keyframes aren't there.

Warperus
17th June 2010, 12:13
FraGTaLiTy
Try Avidemux for the second part, in copy mode.
1) Open first part, set A marker, move to first black frame, set B marker. Save first part.
2) Move to next keyframe (one click on right part of slider control above Selection label), set A marker, move to the end, set B marker. Save second part.
3) If you a lucky, keyframe starts at right place. If not, you'll have to reencode valuable part between 1-2 with parameters similar to original encoding.
4) Open first cut, append others, save in copy mode.

It works for me, but it's possible something will go wrong.

VirtualDUB can do similar things with smart encoding, but I'm not sure it'll handle mp4 container.

FraGTaLiTy
17th June 2010, 12:35
FraGTaLiTy
Try Avidemux for the second part, in copy mode.
1) Open first part, set A marker, move to first black frame, set B marker. Save first part.
2) Move to next keyframe (one click on right part of slider control above Selection label), set A marker, move to the end, set B marker. Save second part.
3) If you a lucky, keyframe starts at right place. If not, you'll have to reencode valuable part between 1-2 with parameters similar to original encoding.
4) Open first cut, append others, save in copy mode.

It works for me, but it's possible something will go wrong.

VirtualDUB can do similar things with smart encoding, but I'm not sure it'll handle mp4 container.

looks like I've got a keyframe at 5:16 and a keyframe at 5:25. I need to eliminate between 5:16 and 5:17.

How would I do step 3 so that I only have to encode those couple of seconds that are before the second keyframe? I have part A (0 - 5:16) and part C (5 25 - End). I need to obtain 5:17ish - 5.25.

Warperus
17th June 2010, 12:56
Select range with AB markers, select mpeg-4 avc encoder in video droplist, press Configure and set up encoder to settings similar to what you have in source. Profile, level, fps and resolution should be the same at least.
Then save the part - it will start encoding. Hopefully it will be compartible...

FraGTaLiTy
17th June 2010, 13:46
Select range with AB markers, select mpeg-4 avc encoder in video droplist, press Configure and set up encoder to settings similar to what you have in source. Profile, level, fps and resolution should be the same at least.
Then save the part - it will start encoding. Hopefully it will be compartible...

Did it. Have the 3 different mp4 files.

When I combine them, it gets really screwy. Lots of green blocking during the connection when played back :/

Guest
17th June 2010, 14:02
Doesn't VideoRedo support AVC now?

Warperus
17th June 2010, 16:11
neuron2
Their site doesn't say anything about AVC...

FraGTaLiTy
Sounds bad :( Back to CLI tools then
Well, mp4box can split mp4 files and concatenate them.
Reencoding of step 3 part can be done in x264.exe directly with frame range options (--seek & --frames)

txporter
17th June 2010, 19:25
Doesn't VideoRedo support AVC now?

Yes. Need to go to their forums. Oddly, they haven't updated their main site in quite some time. http://www.videoredo.net/msgBoard/forumdisplay.php?f=39

Guest
17th June 2010, 19:59
@txporter

Have you used it? I'd be curious to know how well it works with a view towards a possible purchase.

FraGTaLiTy
17th June 2010, 23:05
no luck yet, sigh.

laserfan
17th June 2010, 23:31
no luck yet, sigh.Get VideoReDo's trial version (you need to register it by giving them an email address) and give that a try. It's free to use for 2 weeks I believe.

Alternatively, if you can post a snippet of your file somewhere, one of us who owns VRD can try to open it to verify that it will work.

VRD only re-encodes those frames it needs to, leaving the rest alone. Works with .m2ts files from Blu-ray discs; I dunno tho about your mp4/mp3 combo.

Works sensationally well, though I have little use for h264 editing myself.

txporter
17th June 2010, 23:39
@txporter

Have you used it? I'd be curious to know how well it works with a view towards a possible purchase.

I haven't used it myself. All of the editing that I do is on MPEG2 video, so I am happy with VRD v3. I have used it for over 4 years now.

The forums have good support there from their staff. They are still working through issues with v4 (H.264 support), but it has come a LONG way.

There product comes with a free 15-day fully functional trial. I would suggest installing it when you have the time and running it through your courses. Thread for download. (http://www.videoredo.net/msgBoard/showthread.php?t=17563)

FraGTaLiTy
18th June 2010, 05:06
Get VideoReDo's trial version (you need to register it by giving them an email address) and give that a try. It's free to use for 2 weeks I believe.

Alternatively, if you can post a snippet of your file somewhere, one of us who owns VRD can try to open it to verify that it will work.

VRD only re-encodes those frames it needs to, leaving the rest alone. Works with .m2ts files from Blu-ray discs; I dunno tho about your mp4/mp3 combo.

Works sensationally well, though I have little use for h264 editing myself.


http://www.filefront.com/16786401/help.mp4

Is a small section from my encode, which contains the part in the credits that are messed up. As you'll see, it cuts to black for about a half second.

foxyshadis
18th June 2010, 06:25
Avidemux has a smart copy mode as well. Exact same method but use smart copy, and it'll only re-encode those 5 seconds of credits between keyframes.

FraGTaLiTy
18th June 2010, 10:09
Avidemux has a smart copy mode as well. Exact same method but use smart copy, and it'll only re-encode those 5 seconds of credits between keyframes.

I'm going to try this tomorrow. Thanks for the help. If some of you want to try it yourself, here are the two encodes I need to fix.

http://www.filefront.com/16786113/BlackBox-1080p.mp4/

http://www.megaupload.com/?d=NJTQU261

Same video file, different resolutions. Time of error: 5:16 - 5:17. It's for a fragvid competition.

laserfan
18th June 2010, 13:43
http://www.filefront.com/16786401/help.mp4

Is a small section from my encode, which contains the part in the credits that are messed up. As you'll see, it cuts to black for about a half second.
I will try it later, but...there appears to be no audiotrack in this file thus I think VRD will not load it.

UPDATE: Sorry, there is indeed a soundtrack, but my version of VRD won't open the file (maybe doesn't like .mp4 format? No, it opens/edits another .mp4 I have here just fine, so that's not the problem). But I will update to the newest version and try again.

UPDATE2: No good, VRD still doesn't recognize the file. Dunno what it doesn't like about it... I tried also to demux it using YAMB but YAMB doesn't like the file either--dunno what your "friend" did to mess this up? I'd try with one/both of your other links, but don't have the download bandwidth here, sorry. :(

Guest
18th June 2010, 14:27
Just re-encode it and be done. What's the point for a silly fragvid?

laserfan
18th June 2010, 14:52
Just re-encode it and be done. What's the point for a silly fragvid?
I dunno what a fragvid is, but here's the crux of it afaict:

A friend of mine recently edited a video...and deleted all his original files
VRD is a great tool but the "friend" did something to make a broken .mp4 file.

Guest
18th June 2010, 15:21
No, I meant just re-encode from the original encode. With decent settings the loss will be insignificant...for a silly fragvid.

FraGTaLiTy
20th June 2010, 00:07
Got it. I did this without encoding or re-rendering anything except for the credits. I basically had to convert everything to an mkv container, re-render the credits only right at the point of an x264 keyframe with the black part edited out, encode that portion, cut out the part up to that same keyframe in the original file, and connect them using MKVTOOLNIX.

Then I had to use YamB to separate the mp3 audio from the video in the original 1080p release, then remux that audio to the doctored up version I did in paragraph 1.

Conclusion: MKV > MP4 because it is much more stable. I had so many problems when I tried to do this in YAMB while using MP4.

Thanks everyone, this wouldn't have been able to happen without some of the posts here :D