Skip to content

Instantly share code, notes, and snippets.

@shamil
Last active January 28, 2021 10:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shamil/4979295 to your computer and use it in GitHub Desktop.
Save shamil/4979295 to your computer and use it in GitHub Desktop.
VLC: how to merge and transcode multiple videos

Merge & Transcode

If you have more than one source files that need to be merged into a single output file, the general way is this (no transcoding is necessary if all streams match):

vlc file1.ps file2.ps file3.ps --sout "#gather:std{access=file,mux=ts,dst=all.ts}" --sout-keep

NB that whenever you use sout, your video and audio codecs must "be appropriate" for the mux you use (in this case, ps works with a ts mux, so we're ok).

If you want to write your files out to a mux that doesn't support the current audio or video encoding, or if you are wanting to join streams that do not have matching video/audio, then it is recommended to transcode as well.

Here is an example:

vlc -vvv FILE1.EXT FILE2.EXT FILE3.EXT ETC.ETC --sout-keep --sout=#gather:transcode{vcodec=h264,vb=1024,scale=1,acodec=mp4a,ab=192,channels=6}:standard{access=file,mux=ts,dst=out.mpg} --sout-all

Next edit the path to vlc, input files, and transcode parameters to meet your needs.

Or you can use file appending:

vlc go.ps.1 go.ps.2 go.ps.3  vlc://quit --sout-file-append --sout=file/ps:go.ps

Non Interactive Mode

To do any of this in "non interactive" mode, add -I dummy and also vlc://quit to the end of your list of inputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment