Concatenating ogg video files from the command line
Okay. I've got a few ogg files I've created using a desktop recording tool. I've transcoded them using ffmpeg
once (mainly to clip out the beginnings and the ends).
Now, I have 3 such files which I want to concatenate into a single .ogv
file. I tried using oggCat
, it crashed with some kind of error (I tried concatenating a file to itself using oggCat
and that failed too leading me to believe that my distro is shipping a broken version of the package). Simply cat
ing the files works but I can't seek which is not cool. mencoder
run like this mencoder -ovc lavc -oac lavc file1.ogv file2.ogv file3.ogv -o complete.ogv
. It transcodes the files into an avi
and clips off a little of the 3 videos.
So, how do I do this?
Update 1: My current workaround is to transcode the 3 files into .mpg
using ffmpeg
, then cat
ing them together and then transcoding them back into ogv
.
Update 2: PiTiVi works for this kind of thing but I need something from the command line that I can automate and script.
Ogg Video Tools seems to do what you are looking for.
Short description:
Sometimes it would be nice to concatenate (join) two or more video files. For that you can use oggCat, which creates a continuous Ogg video file from the given files.
# oggCat newFile.ogv file1.ogv file2.ogv [ file3.ogv [...] ]
Note: The video files must correspond in framerate, keyframe gap, framesize etc.
See more here and here.
I would use ffmpeg's concat demuxer for this (requires a recent version of ffmpeg).
First, create a file called inputs.txt (or any arbitrary name), containing lines like:
file '/path/to/input1.ogv'
file '/path/to/input2.ogv'
file '/path/to/input3.ogv'
Note that that can be a relative or an absolute file path. If your files are all in the same directory and named in a pattern similar to input1.ogv, input2.ogv..., you can use a for loop to generate inputs.txt:
rm inputs.txt; for f in input*.ogv; do echo "$f" >> inputs.txt; done
Once you've created your file, you can losslessly concatenate the ogv files like so:
ffmpeg -f concat -i inputs.txt -c copy output.ogv
Have you tried using PiTiVi? Place the three clips sequentially on the timeline and then save the result as one file.