filmov
tv
ffmpeg join two mp4 files with ffmpeg on command line (4 Solutions!!)

Показать описание
ffmpeg join two mp4 files with ffmpeg on command line
The Question: I can successfully join multiple files using the following command:
The only problem with this command is that you need to read the filepaths from
Is there a way to achieve the same goal without having to read the filepaths
from a file? I have tried the following with no luck:
Do I have to use a different command?
Solutions: Please watch the whole video to see all solutions, in order of how many people found them helpful
== This solution helped 38 people ==
***** 2019 Update: *****
As mentioned in the comments, Stack Overflow has a great description of the
available options for concatenation, as well as a discussion of which method to
use depending on the types of files you're using:
using-ffmpeg
***** Original 2016 Answer: *****
method to combine the files:
In addition, the FFmpeg manual discusses a method specifically for MP4 files,
in order to losslessly concatenate them, but requires that you create temporary
files (or named pipes):
== This solution helped 2 people ==
No, there appears to be no way to use the ffmpeg concat demuxer on a single
command line without some hack. You need to create the input text file with the
list of files. I thought this strange myself, maybe someone will add this to
FFMpeg at a later date.
The accepted answer to this question uses the concat protocol, not the concat
demuxer which is what the OP asked.
== This solution helped 1 person ==
You could still do it in a script without changing the command. Something like:
echo "file fname1" >$$.tmp #single redirect creates or truncates file
echo "file fname2" >>$$.tmp # double redirect appends
echo "file fname3" >>$$.tmp # do as many as you want.
rm $$.tmp # just to clean up the temp file.
# For debugging, I usually leave this out.
The $$ expands to the pid of the shell running the command, so the file name
will be different every time you run it. so you could use $$.txt if you prefer.
Or something else...
Also, you can use here files to add a bunch of data to the file:
cat <<EOF >$$.tmp
file fname1
file fname2
file fname3
EOF
bash Variable substitution works, so you can programatically determine the
content of the file, it doesn't have to be fixed. I embed this sort of stuff in
for loops all the time. Finally, the redirect works the same as above, so
>$$.tmp truncates then writes, >>$$.tmp appends.
The Question: I can successfully join multiple files using the following command:
The only problem with this command is that you need to read the filepaths from
Is there a way to achieve the same goal without having to read the filepaths
from a file? I have tried the following with no luck:
Do I have to use a different command?
Solutions: Please watch the whole video to see all solutions, in order of how many people found them helpful
== This solution helped 38 people ==
***** 2019 Update: *****
As mentioned in the comments, Stack Overflow has a great description of the
available options for concatenation, as well as a discussion of which method to
use depending on the types of files you're using:
using-ffmpeg
***** Original 2016 Answer: *****
method to combine the files:
In addition, the FFmpeg manual discusses a method specifically for MP4 files,
in order to losslessly concatenate them, but requires that you create temporary
files (or named pipes):
== This solution helped 2 people ==
No, there appears to be no way to use the ffmpeg concat demuxer on a single
command line without some hack. You need to create the input text file with the
list of files. I thought this strange myself, maybe someone will add this to
FFMpeg at a later date.
The accepted answer to this question uses the concat protocol, not the concat
demuxer which is what the OP asked.
== This solution helped 1 person ==
You could still do it in a script without changing the command. Something like:
echo "file fname1" >$$.tmp #single redirect creates or truncates file
echo "file fname2" >>$$.tmp # double redirect appends
echo "file fname3" >>$$.tmp # do as many as you want.
rm $$.tmp # just to clean up the temp file.
# For debugging, I usually leave this out.
The $$ expands to the pid of the shell running the command, so the file name
will be different every time you run it. so you could use $$.txt if you prefer.
Or something else...
Also, you can use here files to add a bunch of data to the file:
cat <<EOF >$$.tmp
file fname1
file fname2
file fname3
EOF
bash Variable substitution works, so you can programatically determine the
content of the file, it doesn't have to be fixed. I embed this sort of stuff in
for loops all the time. Finally, the redirect works the same as above, so
>$$.tmp truncates then writes, >>$$.tmp appends.