I have 4 video clips that I want to merge as one. They are about 10 minutes each. I have often used ffmpeg for different things and found [google search] a way to concatenate using the concat demuxer from a post on StackOverflow where I was to creat a text list of my filemnames [mylist.txt]. The mp4 files are in a folder on my desktop with the mylist.txt file.
$ cat mylist.txt
file 'MVI1hookmovie1test.mp4'
file 'MVI2hookmovie2test.mp4'
file 'MVI3hookmovie31test.mp4'
file 'MVI4hookmovie32test.mp4'
$ ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4
The following is my output after running the ffmpeg command:
labud@localhost:~/Desktop/testmp4> cat mylist.txt
file 'MVI1hookmovie1test.mp4'
file 'MVI2hookmovie2test.mp4'
file 'MVI3hookmovie31test.mp4'
file 'MVI4hookmovie32test.mp4'
labud@localhost:~/Desktop/testmp4> ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4
ffmpeg version 4.4 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 11 (SUSE Linux)
configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --incdir=/usr/include/ffmpeg --extra-cflags='-O2 -Wal
l -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=r
eturn-type -flto=auto -ffat-lto-objects -g' --optflags='-O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables
-fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -ffat-lto-objects -g' --disable-htmlpage
s --enable-pic --disable-stripping --enable-shared --disable-static --enable-gpl --enable-version3 --enable-libsmbclient --dis
able-openssl --enable-avresample --enable-gnutls --enable-ladspa --enable-vulkan --enable-libaom --enable-libass --enable-libb
luray --enable-libbs2b --enable-libcelt --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libdc1394 --enable-libd
rm --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libjack --enable-libmp3lame --enab
le-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librav1e --enable-librubberb
and --enable-libsvtav1 --enable-libsoxr --enable-libspeex --enable-libssh --enable-libsrt --enable-libtheora --enable-libtwola
me --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libv4l2 --enable-libvpx --enable-libwebp --enable-libxml2
--enable-libzimg --enable-libzmq --enable-libzvbi --enable-lto --enable-lv2 --enable-libmfx --enable-vaapi --enable-vdpau --en
able-version3 --enable-libfdk-aac-dlopen --enable-nonfree --enable-libvo-amrwbenc --enable-libx264 --enable-libx265 --enable-l
ibrtmp --enable-libxvid
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
[concat @ 0x55dafb978f40] Impossible to open 'MVI1hookmovie1test.mp4'
mylist.txt: No such file or directory
labud@localhost:~/Desktop/testmp4>
Any ideas why this is not working? Is there something I didn’t do?
Why would it be
Impossible to open 'MVI1hookmovie1test.mp4
. The clips all play well idependantly.
Is there a better way to do this?
Thank you
Maybe use the full path???
Thanks for replying gogalthorp.
I changed the mylist.txt file to show full path, but the result was the same.
labud@localhost:~/Desktop/testmp4> ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4
ffmpeg version 4.4 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 11 (SUSE Linux)
configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --incdir=/usr/include/ffmpeg --extra-cflags='-O2 -Wal
l -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=r
eturn-type -flto=auto -ffat-lto-objects -g' --optflags='-O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables
-fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -ffat-lto-objects -g' --disable-htmlpage
s --enable-pic --disable-stripping --enable-shared --disable-static --enable-gpl --enable-version3 --enable-libsmbclient --dis
able-openssl --enable-avresample --enable-gnutls --enable-ladspa --enable-vulkan --enable-libaom --enable-libass --enable-libb
luray --enable-libbs2b --enable-libcelt --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libdc1394 --enable-libd
rm --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libjack --enable-libmp3lame --enab
le-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librav1e --enable-librubberb
and --enable-libsvtav1 --enable-libsoxr --enable-libspeex --enable-libssh --enable-libsrt --enable-libtheora --enable-libtwola
me --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libv4l2 --enable-libvpx --enable-libwebp --enable-libxml2
--enable-libzimg --enable-libzmq --enable-libzvbi --enable-lto --enable-lv2 --enable-libmfx --enable-vaapi --enable-vdpau --en
able-version3 --enable-libfdk-aac-dlopen --enable-nonfree --enable-libvo-amrwbenc --enable-libx264 --enable-libx265 --enable-l
ibrtmp --enable-libxvid
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
[concat @ 0x55f0bafd5f40] Impossible to open '/home/labud/Desktop/testmp4/MVI1hook.mp4'
mylist.txt: No such file or directory
I found another example for ffmpeg concat, the result is as follows:
Not too sure what is meant by “unsafe filename”.
labud@localhost:~/Desktop/testmp4> ffmpeg -f concat -i mylist.txt -c copy output.mp4
ffmpeg version 4.4 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 11 (SUSE Linux)
configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --incdir=/usr/include/ffmpeg --extra-cflags='-O2 -Wal
l -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=r
eturn-type -flto=auto -ffat-lto-objects -g' --optflags='-O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables
-fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -ffat-lto-objects -g' --disable-htmlpage
s --enable-pic --disable-stripping --enable-shared --disable-static --enable-gpl --enable-version3 --enable-libsmbclient --dis
able-openssl --enable-avresample --enable-gnutls --enable-ladspa --enable-vulkan --enable-libaom --enable-libass --enable-libb
luray --enable-libbs2b --enable-libcelt --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libdc1394 --enable-libd
rm --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libjack --enable-libmp3lame --enab
le-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librav1e --enable-librubberb
and --enable-libsvtav1 --enable-libsoxr --enable-libspeex --enable-libssh --enable-libsrt --enable-libtheora --enable-libtwola
me --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libv4l2 --enable-libvpx --enable-libwebp --enable-libxml2
--enable-libzimg --enable-libzmq --enable-libzvbi --enable-lto --enable-lv2 --enable-libmfx --enable-vaapi --enable-vdpau --en
able-version3 --enable-libfdk-aac-dlopen --enable-nonfree --enable-libvo-amrwbenc --enable-libx264 --enable-libx265 --enable-l
ibrtmp --enable-libxvid
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
[concat @ 0x5650c4a21e80] Unsafe file name '/home/labud/Desktop/testmp4/MVI1hook.mp4'
mylist.txt: Operation not permitted
labud@localhost:~/Desktop/testmp4>
If you cannot manage it on the command line Kdenlive will do it; it normally displays the ffmeg command that it is using.
thank you john_hudson for taking the time to help.
I will try that next if the ffmpeg cmd I am currently trying does not work.
There seem to be many different ways thru ffmpeg to merge files.
This is the 4th one I have tried.
4th time lucky I hope.
Well that one was the best one yet. At least it gave me an output, albeit not the one I was looking for.
It took my 4 files and stitched them together and when I played the output file there they were, all 4 files playing simultaneously ](https://www.google.com/search?q=simultaneously&spell=1&sa=X&ved=2ahUKEwieps3htqryAhWPLc0KHWT1AeYQkeECKAB6BAgBEDA ) , all in a row.
This was the code:
labud@localhost:~> ffmpeg -i MVI1hook.mp4 -i MVI2hook.mp4 -i MVI3hook.mp4 -i MVI4hook.mp4 -filter_complex \
> "[0:v][1:v]hstack=inputs=4[v]; \
> [0:a][1:a]amerge[a]" \
> -map "[v]" -map "[a]" -ac 2 output.mp4
Maybe I needed different parameters to merge rather than stitch?
I find Avidemux easier, just open the first file and append the others from the File menu.
@john_hudson - thank you
I tried KdenLive and it was fairly easy to merge the clips. Took about 10 mins to render them once I had added the clips.
thank you brunomcl, I will check that one out also.
oldcpu
August 12, 2021, 11:23am
10
LaQuirrELL:
It took my 4 files and stitched them together and when I played the output file there they were, all 4 files playing simultaneously ](simultaneously - Google Suche ) , all in a row.
This was the code:
labud@localhost:~> ffmpeg -i MVI1hook.mp4 -i MVI2hook.mp4 -i MVI3hook.mp4 -i MVI4hook.mp4 -filter_complex \
> "[0:v][1:v]hstack=inputs=4[v]; \
> [0:a][1:a]amerge[a]" \
> -map "[v]" -map "[a]" -ac 2 output.mp4
Maybe I needed different parameters to merge rather than stitch?
If it were me, aside from using kdenlive, I would try this ffmpeg command:
ffmpeg -i "concat:MVI1hook.mp4|MVI2hook.mp4|MVI3hook.mp4|MVI4hook.mp4" -c copy output.mp4
Note that if video is set to copy, the clips have to be the same format. Otherwise you have to render the video again.