Tuesday, June 29, 2010

How to concatenate files from Dos cmd

To combine multiple files, e.g. concatenate them...

copy /b file1+file2 dest


copy /b 00001.mts+00002.mts+00003.mts combined.mts

Copies the mts files into one file, combined.mts

If this, like i am using is for combining video streams, you can then easily remux with ffmpeg, to fix the broken indexes.

ffmpeg -i combined.mts -acodec copy -vcodec copy -scodec copy combined_indexfixed.mp4

How to pipe from ffmpeg to ffmpeg in windows or linux

Its quite interesting to look at time lapse videos.. but how do you make them? It is fairly easy with ffmpeg, but the standard method is to create fifty bazillion images from the source video, then re-encode that to whatever... thats quite troublesome and takes dozens of GB of space, especially when using HD video, and... what about all the wasted cpu cycles from compressing the png/jpg frames? (i know you can use bmp, see above about the DOZENS OF GB, or 5.5 MB/frame for 1920x1080)

Surely there must be a better way to do this, in linux you can easily pipe from one program to another, but no one seems to know how to do that with ffmpeg in windows.

So... I just spend the last...6? hours trying to figure this out... couldn't find it anywhere in Google, so as i always forget stuff, I thought, why not post it on a blog or something... perhaps it will save time for someone else...


This exact syntax works with both linux and windows consoles.
Using this command somehow suppresses the ffmpeg check that sees if the output target file exists, so it will overwrite without asking anything.
-deinterlace is deprecated, instead use

-filter:v yadif 

(much better quality)

c:\>ffmpeg -i "source_video" -r 2 -deinterlace -f image2pipe -vcodec ppm - | ffmpeg -r 29.97 -f image2pipe -vcodec ppm -i - -vcodec libx264 -fpre libx264-superfast.ffpreset -fpre libx264-main.ffpreset -threads 0 -crf 24 -s 1920x1080 -y test.mkv

What this does, is tell ffmpeg to take 2 frames per sec from the source vid, then pipe that to the next ffmpeg and, with the settings i use, re-encode that to x.264

The bare command, if you wanted to specify your options like bitrate, other codec etc would be:

C:\>ffmpeg -i "src_vid" -f image2pipe -vcodec ppm - | ffmpeg -f image2pipe -vcodec ppm -i - -vcodec
(whatever you want after this e.g. xvid, etc etc...)

At the moment im working on a 4 hr time lapse of the clouds and sunrise... should be good :)

Edit 2012/06/01

I made another video using this method:

Edit 2012/06/18

Yet another, added notes section above :)
This one was done on linux:

$ ffmpeg -i 00070.MTS -r .5 -filter:v yadif -f image2pipe -vcodec ppm - | ffmpeg -r 29.97 -f image2pipe -vcodec ppm -i - -vcodec libx264 -crf 24 -s 1920x1080 -y /home/vm/Videos/ice1.mkv

There were 3 parts, as my camera splits into 2 GB files, after they were sped up, avidemux was used to combine them.