0

I have 3 videos of mp4 format. They have same resolution (640 X 1280) but other properties like frame rate etc are different. I want to join them back to back.So I gave a check on internet and I used the following method

:: Create File List
echo file file1.mp4 >  mylist.txt 
echo file file2.mp4 >> mylist.txt
echo file file3.mp4 >> mylist.txt

:: Concatenate Files
ffmpeg -f concat -i mylist.txt -c copy output.mp4

But unfortunately it did not worked.In the resultant video, file1 part got freezed, and audio of whole video shifted (no idea how).And other methods are also not working properly

I just want to join them back to back.Any idea how to do it?

Edit:- I gave a check on the output of the ffmpeg (using pause command in bat and discovered the following. Maybe it may help regarding the issue)

C:\Users\Cascade_Games\Desktop\Cascade Empire\ffmpeg-4.3.1-2020-10-01-full_build\bin>ffmpeg -f concat -i mylist.txt -vcodec copy -acodec copy Mux1.mp4
ffmpeg version 4.3.1-2020-10-01-full_build-www.gyan.dev Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 10.2.0 (Rev3, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-libsnappy --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 000002a0474e6a40] Auto-inserting h264_mp4toannexb bitstream filter
Input #0, concat, from 'mylist.txt':
  Duration: N/A, start: -0.023220, bitrate: 2447 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x640 [SAR 1:1 DAR 2:1], 2320 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc
    Metadata:
      handler_name    : VideoHandle
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s
    Metadata:
      handler_name    : SoundHandler
Output #0, mp4, to 'Mux1.mp4':
  Metadata:
    encoder         : Lavf58.45.100
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x640 [SAR 1:1 DAR 2:1], q=2-31, 2320 kb/s, 30 fps, 30 tbr, 15360 tbn, 15360 tbc
    Metadata:
      handler_name    : VideoHandle
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mov,mp4,m4a,3gp,3g2,mj2 @ 000002a04750d700] Auto-inserting h264_mp4toannexb bitstream filter
[mov,mp4,m4a,3gp,3g2,mj2 @ 000002a0474ef040] Auto-inserting h264_mp4toannexb bitstream filter
[mp4 @ 000002a0478e09c0] Non-monotonous DTS in output stream 0:1; previous: 30282976, current: 27826977; changing to 30282977. This may result in incorrect timestamps in the output file.
[mp4 @ 000002a0478e09c0] Non-monotonous DTS in output stream 0:1; previous: 30282977, current: 27828129; changing to 30282978. This may result in incorrect timestamps in the output file.
(Same Thing was getting repeated,hence I deleted it)
[mp4 @ 000002a0478e09c0] Non-monotonous DTS in output stream 0:1; previous: 30283209, current: 28095393; changing to 30283210. This may result in incorrect timestamps in the output file.
[mp4 @ 000002a0478e09c0] Non-monotonous DTS in output stream 0:1; previous: 30283210, current: 28096545; changing to 30283211. This may result in incorrect timestamps in the output file.
[mp4 @ 000002a0478e09c0] aac bitstream error
    Last message repeated 234 times
frame=18937 fps=11438 q=-1.0 Lsize=   49051kB time=00:11:26.69 bitrate= 585.2kbits/s speed= 415x
video:40720kB audio:7653kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.401324%

Edit:- Info of all files (I have changed the video name to 1.mp4,2.mp4,3.mp4)

C:\Users\Cascade_Games\Desktop\Cascade Empire\ffmpeg-4.3.1-2020-10-01-full_build\bin>ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4
ffmpeg version 4.3.1-2020-10-01-full_build-www.gyan.dev Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 10.2.0 (Rev3, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-libsnappy --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.45.100
  Duration: 00:00:05.27, start: 0.000000, bitrate: 2337 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x640 [SAR 1:1 DAR 2:1], 2320 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandle
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '2.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.45.100
  Duration: 00:10:25.70, start: 0.000000, bitrate: 616 kb/s
    Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x640 [SAR 1:1 DAR 2:1], 511 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #1:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 96 kb/s (default)
    Metadata:
      handler_name    : SoundHandle
Input #2, mov,mp4,m4a,3gp,3g2,mj2, from '3.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.45.100
  Duration: 00:00:08.50, start: 0.000000, bitrate: 447 kb/s
    Stream #2:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv444p, 1280x640 [SAR 1:1 DAR 2:1], 228 kb/s, 2 fps, 2 tbr, 16384 tbn, 4 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #2:1(und): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 319 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
  • All inputs must have the same attributes to concatenate properly. Show the complete output of `ffmpeg -i file1.mp4 -i file2.mp4 -i file3.mp4`. It will not output a file, but will show info about each input. – llogan Feb 05 '21 at 03:46
  • Hi. I have edited my question. Thanks for giving a look to my question – Mayank Thapliyal Feb 05 '21 at 03:55
  • The input attributes vary. There are several methods to deal with this, but which method to recommend depends on what you're doing. Are you going to be concatenating often with arbitrary videos, or just this one time with these 3 particular inputs? – llogan Feb 05 '21 at 18:53
  • Hi. Thanks for giving a look to it. Yes,definitely I will be doing it many times with different videos. – Mayank Thapliyal Feb 06 '21 at 13:39
  • Also I did a little bit of research on the internet and I figured out this:- ffmpeg -i portrail_intro (5).mp4-i reddit.mp4 -i portrail_promo.mp4 -vsync 2 -filter_complex "[0:v] [0:a] [1:v] [1:a] [2:v] [2:a] concat=n=3:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" reddit_.mp4 . It worked but I am not sure about its workings. Will it be fine? – Mayank Thapliyal Feb 06 '21 at 13:41

0 Answers0