Ubuntu: best command line tool to join videos


I have used ffmpeg, but with it you have to first make mpg videos then do cat video1.mpg video2.mpg > joined.mpg and then convert to joined.mpg to joined.mp4 with ffmpeg to be able to upload on youtube. I heard there's mencoder which can join avi files without converting to mpg and using cat command. I'm making videos to upload on youtube so it needs to be avi mp4 or flv format. Which tool is the best to join videos from command line?



melt was meant as a test tool for the MLT framework, but it is also a powerful multitrack command line oriented video editor. It could also used as an minimalistic media player for audio and video files.


sudo apt-get install melt  


This package contains mencoder, a simple movie encoder, designed to encode MPlayer-playable movies (AVI/ASF/OGG/DVD/VCD/VOB/MPG/MOV/VIV/FLI/RM/NUV/NET) to other MPlayer-playable formats. It can encode with various codecs, like DivX4 (1 or 2 passes), libavcodec, PCM/MP3/VBRMP3 audio. Also has stream copying and video resizing abilities.


 sudo apt-get install mencoder  



For mp4 the only working solution I found was with MP4Box from gpac package

#!/bin/bash  filesList=""  for file in $(ls *.mp4|sort -n);do      filesList="$filesList -cat $file"  done  MP4Box $filesList -new merged_files_$(date +%Y%m%d_%H%M%S).mp4  

or command is

MP4Box -cat file1.mp4 -cat file2.mp4 -new mergedFile.mp4  

with mencoder and avconv I could'nt make it work :-(


This is called muxing (multiplexing). As well as the other suggestions, Handbrake will do this and a lot more, including ripping disks, transcoding etc. It has both a GUI and CLI version, and is available from the Software Centre. However, I find it to be a bit of overkill for simple muxing and use the simpler and faster mkvtoolnix package for that. It also has both GUI and CLI versions and is available for Ubuntu and many flavours of GNU/Linux and other Unix derivatives, even MS-Windows. mkvtools is also open source under the GPL, and is available from the website:


with instructions for installing it in Ubuntu. The only issue with Handbrake is that it just outputs to .mp4 (good for YouTube), or .mkv files, but I've had no trouble viewing .mkv video/movies with anything including Android (except a DIVX-only DVD player). mkvtools will only save in .mkv containers.

ffmpeg is probably the simplest CLI to convert your .mkvs to .mp4s

ffmpeg -i inputfilename.mkv -vcodec copy -acodec copy outputfilename.mp4  

Hope this helps.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »