View Full Version : Trimming a whole movie with video, audios and subtitles.
mbcd
12th June 2016, 14:00
Need some advice.
I want to load some files with video, 2 Stereo-WAV-Audio and PGS-Subtitle into Avisynth.
There I want to use filters but ALSO trim(), to delete long black breaks within videostream.
So my problem is: audio and subtitle gets async if they are not trimed also.
Is there a way to trim (and output to seperated wav-files) my 2 stereo-audiofiles.
What about the PGS Subtitle ... how could they get trimmed inside avisynth? A plugin to load them is available, thats a beginning, but dont know how to cut them and export them.
Any suggestions how to solve this problem?
hello_hello
12th June 2016, 19:03
I'm not sure about the subtitles, but MeGUI has an AVS Cutter under the Tools menu. You can open a script and specify multiple start and end frames (using a preview) and MeGUI will add them to the script for you using multiple Trim()s. It can also save a "cuts" file which can be loaded into the audio section to re-encode the audio to match the video, or there's an audio cutter under the Tools menu for cutting the audio to match without re-encoding it.
If you're hard-coding the subtitles it's fine. Add them to the script for encoded as you normally would, then add your required trims to the end of the script. If you're not encoding the subtitles.....
A method I use works for all types of streams, as long as you're happy with MKV as the output container, although when it's done you could take the finished MKV and remux it into a different format.
I open a script with the AVS Cutter and add the cuts, but I add cuts for the sections I want to keep as well as the ones I don't. If there's (for example) 5x Trim() at the end of the script, I then make five copies of the script, and edit each one so it only has one Trim(). The idea being, the first copy of the script encodes the first lots of frames you want, the second copy encodes the ones you want to discard, the third copy ones to keep, and so on.....
The reason for doing it like that is when each section is encoded it'll begin with a keyframe, which is important because you can only cut on keyframes.
Encode each script using the same encoder settings (you can probably delete slow Avisynth filtering from the scripts encoding the sections you want to discard) and be sure to use -stitchable in the x264 command line so the encoded sections can be appended correctly.
When the encodes are done, open the first one with MKVToolNixGUI and append the others. Add the unedited audio and subtitles etc for muxing. Under the Output tab, configure splitting as appropriate. The idea being to split the output at the beginning of each section you encoded, and the audio and subtitles are split to match. When that's done you'll have several MKVs containing video, audio and subtitles. You can then discard the ones you don't want and append the rest together, and the audio and subtitles will remain in sync with the video because they've all been edited together.
Hopefully that'll make sense and I didn't make it sound more complicated than it is, because it's not hard once you know how to do it, and often it's a lot easier than having to edit streams to match the video.
Normally when you encode a video from start to finish the x264 encoder is pretty good at putting keyframes on the first frame of each scene change, so quite often you'll be able to split exactly where you want to, but there's no guarantee and for long sections of unchanging picture or slow fade-in or fade-outs the location of keyframes becomes less predictable, hewnce my suggestion for encoding the video in sections, appending it and then splitting it again. It ensures there'll always be a keyframe where you want to split and MKVToolNix can take care of splitting the and appending the audio and subtitles etc to match the video.
Another option might be to use a Program such as SubtitleEdit to manually edit the subtitles to match the edited video.
thecoreyburton
16th June 2016, 05:40
I created a similar thread (http://forum.doom9.org/showthread.php?t=173467) a little while ago, perhaps some of the answers there will be of some help!
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.