Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 1st December 2018, 04:23   #1  |  Link
Cyber Akuma
Registered User
 
Cyber Akuma's Avatar
 
Join Date: May 2002
Posts: 149
Trying to cut the first few seconds of a MP4 video on a non-keyframe

So, this has been driving me nuts. I have a video that I went to cut out the first 30-40 or so seconds without re-encoding the entire thing. Issue is, the part I want to cut on is not on a keyframe, so most software I used either cuts on the keyframe before the part I want (such as Avidemux) leaving in a few moments of garbage video, or gives me a video that is just bank for the first few moments (ffmpeg) until the next keyframe.

I couldn't figure out a way to make anything read the previous seconds of the video and generate a new keyframe at the beginning of the cut, so I figured my next best bet would be to actually split the video on that keyframe, then trim the part I want from the beginning by re-encoding just the half or so segment I want, and then joining that with the rest of the video.

Issue is, I have no idea how to attempt to duplicate the settings of the second half of the video so I can join it. All attempted have just resulted in it rejecting the second half of the video to join (mp4box) or spitting out a video that after that first half second or so is just corrupted and does not play the rest (avidemux).

Does anybody have any suggestions on this? I am assuming the re-encoding route is my only option, but how would I duplicate the settings of the original video so I can re-join it?
__________________
"A train station is where a train stops. A bus station is where a bus stops. On my desk I have a workstation..." - ComradOtter
Cyber Akuma is offline   Reply With Quote
Old 1st December 2018, 05:14   #2  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Posts: 2,329
I had very good results using VidCutter for MP4 files. It has a "Smart Rendering" feature which means that it can cut frame accurate without reencoding the whole file.

http://forum.doom9.org/showthread.ph...72#post1855172

https://www.videohelp.com/software/VidCutter


Good luck
manolito
manolito is offline   Reply With Quote
Old 4th December 2018, 23:14   #3  |  Link
Cyber Akuma
Registered User
 
Cyber Akuma's Avatar
 
Join Date: May 2002
Posts: 149
It doesn't seem to be working. Whenever I have Smart Rendering enabled, it just gets stuck at 0% when I try to trim a clip, I see no CPU or HDD usage from VidCutter.
__________________
"A train station is where a train stops. A bus station is where a bus stops. On my desk I have a workstation..." - ComradOtter
Cyber Akuma is offline   Reply With Quote
Old 7th December 2018, 01:49   #4  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Posts: 2,329
Yes, VidCutter still does have many problems when Smart Rendering is enabled. Many users report that oftentimes it just gets stuck at a certain percentage of the process. It also happens here, I could not really fix it, but I found some things which improve it a little bit...

I am on Win7 - 64bit, so I first used the 64-bit version of VidCutter. But after switching to the 32-bit version I got the feeling that the 32-bit version is a bit more reliable.

Another thing which improved the behavior was to use a newer FFmpeg version instead of the embedded version. I also found that it is not necessary to use shared FFmpeg versions, the static versions work fine.

The source file format also plays a role. I had better success with MP4 containers than with MKV. And probably the most importat reason for the software to just get stuck is the duration of the input file.

So it looks like the author still has a lot of work to do, I hope that he will get it right soon...


Cheers
manolito
manolito is offline   Reply With Quote
Old 7th December 2018, 16:15   #5  |  Link
Taurus
Registered User
 
Taurus's Avatar
 
Join Date: Mar 2002
Location: Krautland
Posts: 824
@manolito
I've just tested your suggestions.
And yes, the only halfway reliable workflow is repacking all your stuff into a mp4 container.
With mkv I've got scrambled/corrupted frames all over the place.
Mts/m2ts is fine in the timeline, editing ok... but the program just hangs at decoding/encoding stage.
No CPU, no HDD, no nothing
Exchanging both versions (32/64bit) to the latest ffmpeg binairies.
But same behaviour as far as I can see.
It's a shame, such a nice gui, and exactly what I needed.
Now back to search for a new tool....

Last edited by Taurus; 7th December 2018 at 16:16. Reason: grammar
Taurus is offline   Reply With Quote
Old 8th December 2018, 02:11   #6  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Posts: 2,329
Quote:
Originally Posted by Cyber Akuma View Post
... so I figured my next best bet would be to actually split the video on that keyframe, then trim the part I want from the beginning by re-encoding just the half or so segment I want, and then joining that with the rest of the video.

Issue is, I have no idea how to attempt to duplicate the settings of the second half of the video so I can join it. All attempted have just resulted in it rejecting the second half of the video to join (mp4box) or spitting out a video that after that first half second or so is just corrupted and does not play the rest (avidemux).
If VidCutter does not work in your case then I think your approach indeed is your best bet. If your reencoded segment uses the same codecs and the same frame size for video then there is a good chance that you can join these parts.

I first tried with MkvToolNix. I did get a warning about different private codec parameters, but the resulting file played fine.

The other thing I tried was FFmpeg for joining the files. dmMediaConverter is an FFmpeg GUI with some very useful options, and among other things it has an option to "Merge the same". This means that the input files need to use identical codecs and frame sizes, and I also got good results with this method.

What I did notice for both methods was a very small audio dropout at the merge point. Hardly audible, but of course this can be fixed with a WAV editor...


Cheers
manolito
manolito is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:01.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.