With H.264 video and AAC audio, the following can be used:įfmpeg -i input1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.tsįfmpeg -i input2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.tsįfmpeg -i "concat:intermediate1.ts|intermediate2.ts" -c copy -bsf:a aac_adtstoasc output.mp4
#Ffmpeg windows concat mp4
If you have MP4 files, these could be losslessly concatenated by first transcoding them to MPEG-2 transport streams. The following command concatenates three MPEG-2 TS files and concatenates them without re-encoding:įfmpeg -i "concat:input1.ts|input2.ts|input3.ts" -c copy output.ts This is analogous to using cat on UNIX-like systems or copy on Windows. Certain files (MPEG-2 transport streams, possibly others) can be concatenated. While the demuxer works at the stream level, the concat protocol works at the file level. Note that recursively referencing playlist files will cause ffmpeg to eventually run out of file descriptors (or other resources) because ffmpeg only closes the playlist file when the playlist has finished, but in the example above because of the recursive chaining none of the playlist files actually end. (for %i in (*.wav) do file '%i') > mylist.txtįoreach ($i in Get-ChildItem.
Either of the following would generate a list file containing every *.wav in the working directory:įor f in *.wav do echo "file '$f'" > mylist.txt done It is possible to generate this list file with a bash for loop, or using printf. The -safe 0 above is not required if the paths are relative. Then you can stream copy or re-encode your files:įfmpeg -f concat -safe 0 -i mylist.txt -c copy output.wav Note that these can be either relative or absolute paths. All files must have the same streams (same codecs, same time base, etc.) but can be wrapped in different container formats.Ĭreate a file mylist.txt with all the files you want to have concatenated in the following form (lines starting with a # are ignored): This demuxer reads a list of files and other directives from a text file and demuxes them one after the other, as if all their packets had been muxed together. You can read about the concat demuxer in the documentation. The demuxer is more flexible – it requires the same codecs, but different container formats can be used and it can be used with any container formats, while the protocol only works with a select few containers. There are two methods within ffmpeg that can be used to concatenate files of the same type: If you have media with different codecs you can concatenate them as described in " Concatenation of files with different codecs" below. If you have media files with exactly the same codec and codec parameters you can concatenate them as described in " Concatenation of files with same codecs".
I am trying to make sense of FFMPEG's Quicksync documentation but it's too mature for an amateur like me. Is there a way I could use my GPUs (i3's Quicksync or R5's AMF/VCE) to speed up these operation without compromising the quality of the output videos? But the in-built Switchable Graphics Monitor suggests that neither of the processes are using the dGPU. I also set ffmpeg.exe and cmd.exe to "High Performance" in the AMD Switchable Graphics settings. However, I don't notice any increase in speed. I tried using -hwaccel dxva2 in the above mentioned commands as follows:įfmpeg.exe -hwaccel dxva2 -i "INPUT_VIDEO" -ss START_TIME -to END_TIME -c copy "OUTPUT_VIDEO"įfmpeg.exe -hwaccel dxva2 -f concat -safe 0 -i VideosToBeConcatenated.txt -c copy "CONCATENATED_OUTPUT_VIDEO" Is there a way I could use my GPU to speed up these operation? Say, using the i3's Quicksync or R5's AMF/VCE? Running them in two Command Windows simultaneously drops the speed to 10-12x, while also making my system lag/freeze. Running these commands in a single Command Window gives me a speed of 20-25x. Where VideosToBeConcatenated.txt contains the file names of the videos to be concatenated. Right now, I am trimming individual videos using the following command:įfmpeg.exe -i "INPUT_VIDEO" -ss START_TIME -to END_TIME -c copy "OUTPUT_VIDEO"Īnd then I concatenate the videos using this command:įfmpeg.exe -f concat -safe 0 -i VideosToBeConcatenated.txt -c copy "CONCATENATED_OUTPUT_VIDEO" This operation needs to be performed for all these videos. I need to trim 2-4 videos and then concatenate them into one single file. Each video occupies 2-3 GB minimum and is at least 1 hour long. Cumulatively, they are over 100 hours long.
#Ffmpeg windows concat windows 10
I am running FFMPEG on a Windows 10 (64-bit) laptop with Intel i3 (6th generation) processor and AMD R5 M430 GPU.