Post subject: Need help with trimming video files
Joined: 4/22/2014
Posts: 59
Location: United Kingdom
Not sure this is the best place to ask, it's TASVideos, so there's bound to be some wizards, but I'm wanting to cut out parts of a video file, like at the beginning, end, or a scene in the middle, but I've been having problems. Say, I captured gameplay footage with Fraps, at a crisp 60 FPS. I'm wanting to trim off parts of the output file. But the free video editors I used butcher the file down to 30 FPS. Is there any way, if at all, to cut out parts of a video file while maintaining 60 FPS, using free software?
Samsara
She/They
Senior Judge, Site Admin, Expert player (2123)
Joined: 11/13/2006
Posts: 2794
Location: Northern California
Avisynth paired with AvsPmod is your best bet. Avisynth is kind of a video editing scripting language, AvsPmod is probably the best way to write Avisynth scripts. It's not hard to learn.
TASvideos Admin and acting Senior Judge 💙 | Cohost
warmCabin wrote:
You shouldn't need a degree in computer science to get into this hobby.
mz
Player (79)
Joined: 10/26/2007
Posts: 693
You can also use something like Avidemux if you don't want to bother with scripting or re-encoding.
You're just fucking stupid, everyone hates you, sorry to tell you the truth. no one likes you, you're someone pretentious and TASes only to be on speed game, but don't have any hope, you won't get there.
creaothceann
He/Him
Editor
Joined: 4/7/2005
Posts: 1874
Location: Germany
This is an example of an Avisynth script:
Language: Avisynth

AVISource("file name.avi") # open file Info # draw info onto the video v1 = Trim(0, 999) # select the first 1000 frames (start..end index) v2 = Trim(0, -1000) # select the first 1000 frames (start index, number of frames) v3 = Trim(0, -1) # select the first frame v4 = Trim(1, -1) # select the second frame v5 = Trim(FrameCount-1000, 0) # select the last 1000 frames v6 = Trim(0, 0) # select all frames v1 + v2 + v3 + v4 + v5 + v6 # combine all results
You can use e.g. VirtualDub to encode a script's result back to a video file.
Joined: 4/22/2014
Posts: 59
Location: United Kingdom
mz wrote:
You can also use something like Avidemux if you don't want to bother with scripting or re-encoding.
That program seemed to do the trick! The way it decodes files is a little annoying, but it outputs properly at least.
Site Admin, Skilled player (1237)
Joined: 4/17/2010
Posts: 11274
Location: RU
Actually, the easiest (and still very compatible) way is to use VirtualDub. You drop files right into it, select with Home and End keys and delete segments. If the source is not AVI, this can be used as a pluging to allow all other formats: http://codecpack.co/download/FFInputDriver.html
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.
mz
Player (79)
Joined: 10/26/2007
Posts: 693
I don't see how that is easier than Avidemux... In Avidemux you don't need plugins or any other crap to use pretty much any format that you might find. You can drag and drop too, and use its hotkeys. Also, Avidemux doesn't look like vomit and you don't need to visit pages from 1992 to get some simple filters for it (and good luck trying to get anything for the x64 version of VirtualDub. :D)
You're just fucking stupid, everyone hates you, sorry to tell you the truth. no one likes you, you're someone pretentious and TASes only to be on speed game, but don't have any hope, you won't get there.
Site Admin, Skilled player (1237)
Joined: 4/17/2010
Posts: 11274
Location: RU
Well, I said that because I actually never tried Avidemux, while VD is my everyday life's thing :)
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.
Banned User, Former player
Joined: 3/10/2004
Posts: 7698
Location: Finland
Btw, does avidemux simply copy (parts of) the stream from the input file to the output file without re-encoding it? (One of the major annoyances with most actual video editing software is that they always want to re-encode even if all you are doing is cutting part of a video out and nothing more. Re-encoding in this situation is completely unnecessary, extremely slow, and only degrades the quality of the video for no good reason.)
mz
Player (79)
Joined: 10/26/2007
Posts: 693
Yes, both Avidemux and VirtualDub can do that.
You're just fucking stupid, everyone hates you, sorry to tell you the truth. no one likes you, you're someone pretentious and TASes only to be on speed game, but don't have any hope, you won't get there.
Editor, Skilled player (1941)
Joined: 6/15/2005
Posts: 3247
I use Avisynth+VirtualDub to edit video pre-encode (VirtualDub is pretty much just a gateway; there may be better options but that's what I'm used to). Video encoding is done using x264.exe by command-line/batch file and audio encoding with something else (usually neroaacenc or whatever it's called). I use Avidemux if I need to trim or split the video post-encode; there are options to copy input stream (since there is no point re-encoding obviously) but you can only split or set start range on a keyframe (I-frame).
creaothceann
He/Him
Editor
Joined: 4/7/2005
Posts: 1874
Location: Germany
FractalFusion wrote:
better options
AvsPmod
Joined: 4/22/2014
Posts: 59
Location: United Kingdom
Actually, now I think of it, Avidemux seems to choke on video files generated by BizHawk's recording feature. The video screen goes greenish, and you can't seem to go to any keyframe at all.
Editor, Skilled player (1941)
Joined: 6/15/2005
Posts: 3247
What codec ("compressor") are you using to dump AVI in BizHawk, and what settings?
Joined: 4/22/2014
Posts: 59
Location: United Kingdom
I kinda forgotten what codec I used. But I tried another one and it worked fine. Just have to experiment, I guess. Some codecs though seem to crash BizHawk when I try using them to capture, which is frustrating. But now I have a new dilemma. I want to change the video size (like HD), but regardless of the method I use, it ends up being "lossy" afterwards. Anything I'm not getting? EDIT: Regarding codecs, it seems to hate Lagarith Lossless Codec, so that one is out of the question. EDIT 2: Okay, I don't know how, but I seem to have permanently broken the ability to use the AVI writer. BizHawk crashes every single time I try to record with it now, regardless of the codec. And it turns out that Avidemux hates anything captured with the FFmpeg writer. I am having such a fun time. >_<
Samsara
She/They
Senior Judge, Site Admin, Expert player (2123)
Joined: 11/13/2006
Posts: 2794
Location: Northern California
Beed28 wrote:
But now I have a new dilemma. I want to change the video size (like HD), but regardless of the method I use, it ends up being "lossy" afterwards. Anything I'm not getting? EDIT: Regarding codecs, it seems to hate Lagarith Lossless Codec, so that one is out of the question. EDIT 2: Okay, I don't know how, but I seem to have permanently broken the ability to use the AVI writer. BizHawk crashes every single time I try to record with it now, regardless of the codec. And it turns out that Avidemux hates anything captured with the FFmpeg writer. I am having such a fun time. >_<
Let me just say I'm still biased towards Avisynth and AvsPmod so a lot of this advice is going to sum up to "learn those". 1. It depends on how you're resizing it. I'm not familiar with Avidemux at all, but in Avisynth there are a few different ways to resize a video. For sprite-based games (most of the content on the site), PointResize is the best. If there are different resize filters in Avidemux, you might wanna try one of those. Also, it's much better to resize within the native aspect ratio. x2 or x4 native aspect ratio will work better than just resizing straight to, say, 1920x1080. 2. There are other lossless codecs out there, or you could just use uncompressed. Avisynth should be able to take everything, though, assuming you can get Bizhawk to work again.
TASvideos Admin and acting Senior Judge 💙 | Cohost
warmCabin wrote:
You shouldn't need a degree in computer science to get into this hobby.
Joined: 4/22/2014
Posts: 59
Location: United Kingdom
Guess I'll have to try those. Also, BizHawk seems to record using AVI writer again. Don't know how it's working again, but trying to overwrite a file while its open in Avidemux seems to be harmful.
AntyMew
It/Its
Encoder, Player (35)
Joined: 10/22/2014
Posts: 425
Beed28 wrote:
I kinda forgotten what codec I used. But I tried another one and it worked fine. Just have to experiment, I guess. Some codecs though seem to crash BizHawk when I try using them to capture, which is frustrating. But now I have a new dilemma. I want to change the video size (like HD), but regardless of the method I use, it ends up being "lossy" afterwards. Anything I'm not getting? EDIT: Regarding codecs, it seems to hate Lagarith Lossless Codec, so that one is out of the question. EDIT 2: Okay, I don't know how, but I seem to have permanently broken the ability to use the AVI writer. BizHawk crashes every single time I try to record with it now, regardless of the codec. And it turns out that Avidemux hates anything captured with the FFmpeg writer. I am having such a fun time. >_<
Personally I've never had any trouble whatsoever with Bizhawk and Lagarith
Just a Mew! 〜 It/She ΘΔ 〜
creaothceann
He/Him
Editor
Joined: 4/7/2005
Posts: 1874
Location: Germany
Beed28 wrote:
trying to overwrite a file while its open in Avidemux
Site Admin, Skilled player (1237)
Joined: 4/17/2010
Posts: 11274
Location: RU
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.
Titan91
He/Him
Joined: 8/9/2015
Posts: 22
What these programs do is simply trim the video stream within the A/V container (AVI, MP4, etc.) and re-pack it into a new file. Often you will run into restrictions with keyframes, as interframe compression relies on a keyframe to begin compression/decompression. Some editors may allow you to use a non-keyframe as your initial frame but the first few seconds of playback will be corrupt because the referenced keyframe does not exist. I know Avidemux doesn't even let you do this anyway.