Command-line video editing in Linux (cut, join and preview)
Posted
by
sdaau
on Super User
See other posts from Super User
or by sdaau
Published on 2011-11-16T13:52:07Z
Indexed on
2012/03/28
11:33 UTC
Read the original article
Hit count: 344
I have rather simple editing needs - I need to cut up some videos, maybe insert some PNGs in between them, and join these videos (don't need transitions, effects, etc.). Basically, pitivi
would do what I want - except, I use 640x480 30 fps AVI's from a camera, and as soon as I put in over a couple of minutes of that kind of material, pitivi
starts freezing on preview, and thus becomes unusable.
So, I started looking for a command line tool for Linux; I guess only ffmpeg
(command line - Using ffmpeg to cut up video - Super User) and mplayer
(Sam - Edit video file with mencoder under linux) are so far candidates, but I cannot find examples of the use I have in mind.
Basically, I'd imagine there's an encoder and player tools (like ffmpeg
vs ffplay
; or mencoder
vs mplayer
) - such that, to begin with, the edit sequence could be specified directly on the command line, preferably with frame resolution - a pseudocode would look like:
videnctool -compose --file=vid1.avi --start=00:00:30:12 --end=00:01:45:00 --file=vid2.avi --start=00:05:00:00 --end=00:07:12:25 --file=mypicture.png --duration=00:00:02:00 --file=vid3.avi --start=00:02:00:00 --end=00:02:45:10 --output=editedvid.avi
... or, it could have a "playlist" text file, like:
vid1.avi 00:00:30:12 00:01:45:00
vid2.avi 00:05:00:00 00:07:12:25
mypicture.png - 00:00:02:00
vid3.avi 00:02:00:00 00:02:45:10
... so it could be called with
videnctool -compose --playlist=playlist.txt --output=editedvid.avi
The idea here would be that all of the videos are in the same format - allowing the tool to avoid transcoding, and just do a "raw copy" instead (as in mencoder
's copy codec: "-oac copy -ovc copy
") - or in lack of that, uncompressed audio/video would be OK (although it would eat a bit of space). In the case of the still image, the tool would use the encoding set by the video files.
The thing is, I can so far see that mencoder
and ffmpeg
can operate on individual files; e.g. cut a single section from a single file, or join files (mencoder
also has Edit Decision Lists (EDL), which can be used to do frame-exact cutting - so you can define multiple cut regions, but it's again attributed to a single file). Which implies I have to work on cutting pieces first from individual files first (each of which would demand own temporary file on disk), and then joining them in a final video file.
I would then imagine, that there is a corresponding player tool, which can read the same command line option format / playlist file as the encoding tool - except it will not generate an output file, but instead play the video; e.g. in pseudocode:
vidplaytool --playlist=playlist.txt --start=00:01:14 --end=00:03:13
... and, given there's enough memory, it would generate a low-res video preview in RAM, and play it back in a window, while offering some limited interaction ( like mplayer
's keyboard shortcuts for play, pause, rewind, step frame). Of course, I'd imagine the start and end times to refer to the entire playlist, and include any file that may end up in that region in the playlist.
Thus, the end result of all this would be: command line operation; no temporary files while doing the editing - and also no temporary files (nor transcoding) when rendering final output... which I myself think would be nice.
So, while I think that all of the above may be a bit of a stretch - does there exist anything that would approximate the workflow described above?
© Super User or respective owner