I have an long mpeg movie and I want to cut out a lot of material from the beginning and end, and certain patches in the middle. Is there a way I can easily do this from the linux command line?
The tool for the job is mpgtx (if not installed try, e.g., sudo apt-get install mpgtx).
Let's suppose your file is called input.mpg and you want to create output.mpg Here are some common tasks
Select segments from a mpeg movie, create a new mpeg movie out of them
//Grabs seconds 10-20, 42 through 52, then 1:23 through 1:33 and make a new mpeg movie
Note: mpgtx -j is equivalent to mpgjoin. Note: You need to install it via sudo apt-get install mpgtx
Select from the beginning or end of an mpeg movie
//Get the first 20 seconds, secs 42 through 52, then 1:23 through the end***
Split an mpeg movie into several files of custom lengths
//Splits out minutes 1-2 and 3-4 into two files (out-1.mpg and out-2.mpg)
Break an mpeg movie into equal length pieces
//Splits a movie into 5 equal length parts called out-1.mpg, out-2.mpg, ..., out-5.mpg
Concatenate or join multiple mpeg video files from the command line
Re-encoding a file if the timings are off
You may find that the timings are not very accurate because of the way that mpgtx works (which is on a group of pictures basis). I have found that reencoding the mpeg at a constant bitrate leads to files which then can be split very precisely with the above method. A simple re-encoding call is as follows.
//Re-encode at a constant bit rate of 2250k
Note. ffmpeg can do much of what mpgtx can do, but the latter makes it much easier to specify multiple cuts (and you can give the input in start and end times, as opposed to start and durations). However, ffmpeg is a great companion. I find that converting AVIs to mpeg with ffmeg, then doing the splitting with mpgtx is the quickest means to get the job done.
See the man pages for mpgtx and ffmpeg (as well as its online help page http://ffmpeg.org/ffmpeg-doc.html ) for more information.
You could try ffmpeg. See http://www.joeldare.com/wiki/video:cut_video_with_ffmpeg
Cut out pieces of the movie you wish to keep, then join them together to get you final movie (Joining videos: http://ffmpeg.org/faq.html#SEC30)
Documentation on more ffmpeg options available here: http://ffmpeg.org/ffmpeg-doc.html