0

I have 40-50 video files, each about 1 GB large (all same resolution, framerate, encoding). I need to concatenate all of them and have tried to follow this for the same. Basically I put the names of all the videos in a txt and passed it to the ffmpeg concat command. However, since my PC only has 16 gigs of RAM, the concat command gives the error:

av_interleaved_write_frame(): Cannot allocate memory

after about 16 GB of files are processed. Is there any way to avoid this error?

Edit: Added log:

ffmpeg -f concat -safe 0 -i vidlist.txt -c copy final.mp4
ffmpeg version git-2020-04-22-2e38c63 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.3.1 (GCC) 20200328
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 42.102 / 56. 42.102
  libavcodec     58. 80.100 / 58. 80.100
  libavformat    58. 42.101 / 58. 42.101
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 79.100 /  7. 79.100
  libswscale      5.  6.101 /  5.  6.101
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001a346e04bc0] Auto-inserting h264_mp4toannexb bitstream filter
Input #0, concat, from 'vidlist.txt':
  Duration: N/A, start: 0.000000, bitrate: 193 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 193 kb/s, 50 fps, 50 tbr, 12800 tbn, 100 tbc
    Metadata:
      handler_name    : VideoHandler
Output #0, mp4, to 'final.mp4':
  Metadata:
    encoder         : Lavf58.42.101
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 193 kb/s, 50 fps, 50 tbr, 12800 tbn, 12800 tbc
    Metadata:
      handler_name    : VideoHandler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001a346e05c80] Auto-inserting h264_mp4toannexb bitstream filter.29e+03x
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001a346e05c80] Auto-inserting h264_mp4toannexb bitstream filter821x
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001a346e0d480] Auto-inserting h264_mp4toannexb bitstream filter601x
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001a346e0d480] Auto-inserting h264_mp4toannexb bitstream filter449x
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001a346e0d480] Auto-inserting h264_mp4toannexb bitstream filter316x
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001a346ebdb00] Auto-inserting h264_mp4toannexb bitstream filter 265x
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001a346ebdb00] Auto-inserting h264_mp4toannexb bitstream filter 229x
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001a346eca940] Auto-inserting h264_mp4toannexb bitstream filter194x
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001a346ec9000] Auto-inserting h264_mp4toannexb bitstream filter163x
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001a346ec9640] Auto-inserting h264_mp4toannexb bitstream filter141x
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001a346ec9000] Auto-inserting h264_mp4toannexb bitstream filter 125x
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001a346eca300] Auto-inserting h264_mp4toannexb bitstream filter 116x
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001a346e8f280] Auto-inserting h264_mp4toannexb bitstream filter 106x
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001a3472f4dc0] Auto-inserting h264_mp4toannexb bitstream filter96.6x
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001a346e8ec00] Auto-inserting h264_mp4toannexb bitstream filter88.9x
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001a346e8ec00] Auto-inserting h264_mp4toannexb bitstream filter  83x
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001a346e918c0] Auto-inserting h264_mp4toannexb bitstream filter77.8x
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001a346e91f00] Auto-inserting h264_mp4toannexb bitstream filter73.4x
av_interleaved_write_frame(): Cannot allocate memory186:23:47.18 bitrate= 192.9kbits/s speed=70.7x

Edit 2: I've converted all the mp4s to .ts files, and am using the following command to concatenate them into a final mp4:

ffmpeg -i "concat:intermediate0.ts|intermediate1.ts|intermediate2.ts|intermediate3.ts|intermediate4.ts" -c copy -bsf:a aac_adtstoasc final.mp4

It seems to be working, but it's giving me a Packet corrupt error ever so often (I'm guessing this is happening at the end of each intermediate ts file):

Output #0, mp4, to 'final.mp4':
  Metadata:
    encoder         : Lavf58.42.101
    Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 50 fps, 50 tbr, 90k tbn, 90k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mpegts @ 000001f8888fc940] Packet corrupt (stream = 0, dts = 3240124200).95.9kbits/s speed=1.14e+03x
[mpegts @ 000001f8888fc940] Packet corrupt (stream = 0, dts = 3240124200).95.4kbits/s speed= 632x
[mpegts @ 000001f8888fc940] Packet corrupt (stream = 0, dts = 3240124200).95.6kbits/s speed= 395x
frame=6035458 fps=17546 q=-1.0 size= 2881536kB time=33:31:49.10 bitrate= 195.6kbits/s speed= 351x

Is the error fine? Or can I fix it in some way?

Edit 3: I've used the concat protocol but am getting the same cannot allocate error:

Output #0, mp4, to 'final.mp4':
  Metadata:
    encoder         : Lavf58.42.101
    Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 50 fps, 50 tbr, 90k tbn, 90k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mpegts @ 000001f8888fc940] Packet corrupt (stream = 0, dts = 3240124200).95.9kbits/s speed=1.14e+03x
[mpegts @ 000001f8888fc940] Packet corrupt (stream = 0, dts = 3240124200).95.4kbits/s speed= 632x
[mpegts @ 000001f8888fc940] Packet corrupt (stream = 0, dts = 3240124200).95.6kbits/s speed= 395x
[mpegts @ 000001f8888fc940] Packet corrupt (stream = 0, dts = 3240124200).95.6kbits/s speed= 291x
[mpegts @ 000001f8888fc940] Packet corrupt (stream = 0, dts = 3240124200).95.6kbits/s speed= 233x
[mpegts @ 000001f8888fc940] Packet corrupt (stream = 0, dts = 3240124200).95.7kbits/s speed= 195x
[mpegts @ 000001f8888fc940] Packet corrupt (stream = 0, dts = 3240124200).95.8kbits/s speed= 169x
[mpegts @ 000001f8888fc940] Packet corrupt (stream = 0, dts = 3240124200).95.8kbits/s speed= 134x
[mpegts @ 000001f8888fc940] Packet corrupt (stream = 0, dts = 3240124200).95.8kbits/s speed= 120x
[mpegts @ 000001f8888fc940] Packet corrupt (stream = 0, dts = 3240124200).195.7kbits/s speed= 110x
[mpegts @ 000001f8888fc940] Packet corrupt (stream = 0, dts = 3240124200).195.6kbits/s speed= 101x
[mpegts @ 000001f8888fc940] Packet corrupt (stream = 0, dts = 3240124200).195.5kbits/s speed=93.9x
[mpegts @ 000001f8888fc940] Packet corrupt (stream = 0, dts = 3240124200).195.4kbits/s speed=87.2x
[mpegts @ 000001f8888fc940] Packet corrupt (stream = 0, dts = 3240124200).195.4kbits/s speed=81.2x
[mpegts @ 000001f8888fc940] Packet corrupt (stream = 0, dts = 3240124200).195.4kbits/s speed=76.6x
[mpegts @ 000001f8888fc940] Packet corrupt (stream = 0, dts = 3240124200).195.3kbits/s speed=  72x
[mpegts @ 000001f8888fc940] Packet corrupt (stream = 0, dts = 3240124200).195.3kbits/s speed=67.9x
av_interleaved_write_frame(): Cannot allocate memory186:24:07.66 bitrate= 195.3kbits/s speed=  66x

0 Answers0