Showing posts with label Avidemux. Show all posts
Showing posts with label Avidemux. Show all posts

Tuesday, October 18, 2011

Trimming FLV Videos

I wanted to trim some FLV videos without re-encoding.

flvtool2 is supposed to cut flv videos (in milliseconds!), but I always got errors.
flvtool2 -C -i 6000 -o 12000 input.flv output.flv
Avidemux opened the video and I could trim it (using keyframe arrows was necessary), but trying saving in FLV format had errors. Saving as an MP4 with copy/copy was successful, but sound was no longer synced. There is an option to shift the audio, but I didn't do any testing.

ffmpeg ended up being the easiest solution, but it didn't trim exactly where I specified. I'm guessing this has to do with keyframes. The following example trims approx first 15 seconds off the front of the video, and audio is synced.
ffmpeg -ss 15 -i input.flv -acodec copy -vcodec copy output.flv
According to the man pages, the value can be specified to millisecond: "hh:mm:ss[.xxx]", but I could never get this to work.

Saturday, May 7, 2011

MP4Box for trimming m4v videos

I had some H.264 m4v videos that I wanted to trim.

I used Avidemux a while back for trimming some xvid avi videos, but trying to trim the H.264 m4v videos didn't work. The cuts would work, but the video would be slightly jerky (using Copy). Re-encoding the video did work, but the whole point was to losslessly cut the video to save time & quality.

I tried using ffmpeg to trim the videos, but I could never get the -t flag to work. I came across a few other posts of other people having the same problem.

Then I found MP4Box, and it worked. (It's part of the gpac package).

This example extracts a new file starting at 0 and ending at 267.8 seconds.
MP4Box -splitx 0:267.8 input.m4v -out output.m4v
Notable commands from the manual that might be handy later:
-split time_in_seconds
splits in files of desired maximum duration. This will remove
all MPEG-4 Systems media.

-splits size_in_kilobytes
splits in files of desired maximum size. This will remove all
MPEG-4 Systems media.

-splitx start:end
extracts a new file from specified start to end times (in sec‐
onds). This will remove all MPEG-4 Systems media. When input
file is an ISO-Media file (QT, MP4, 3GP), if no output is speci‐
fied THE INPUT FILE IS OVERWRITTEN.


-cat <src_file>
concatenates all src_file tracks to input file, creating it if
not exisiting. Media samples are added at the end of existing
compatible tracks. If no compatible track is found for a media
it is created. Up to 20 cumulated -cat operations can be used.
Syntax is the same as -add.