I'm attempting to trim and concatenate several video files using ffmpeg. These videos have already been transcoded with H.264 at a resolution of 720p. However, when executing the command, I encounter the following error.
[aost#0:1/copy @ 0x55728055fe00] Error submitting a packet to the muxer: Cannot allocate memory+03x
Last message repeated 1 times [out#0/mp4 @ 0x55727ff66f80] Error muxing a packet [out#0/mp4 @ 0x55727ff66f80] Task finished with error code: -12 (Cannot allocate memory) [out#0/mp4 @ 0x55727ff66f80] Terminating thread with return code -12 (Cannot allocate memory) [out#0/mp4 @ 0x55727ff66f80] Error writing trailer: Cannot allocate memory
My command is:
ffmpeg -hwaccel cuda -v error -stats -y -i input1.mp4 -i input2.mp4 -i input3.mp4 -i input4.mp4 -stream_loop -1 -i audio.mp3 -filter_complex '[1:v]trim=start=1371:end=1384,setpts=PTS-STARTPTS[v1];[2:v]trim=start=3471:end=3484,setpts=PTS-STARTPTS[v2];[0:v][v1][v2][3:v]concat=n=4:v=1:a=0[v]' -map '[v]' -vsync 2 -map 4:a:0 -c:a copy -c:v h264_nvenc -preset fast -f mp4 output.mp4
Any help please ? Also, I'm wondering if using cuda can help speed the operation.
-ss
and-to
instead oftrim
filter, and add-shortest
:ffmpeg -hwaccel cuda -stats -y -an -i input1.mp4 -ss 1371 -to 1384 -an -i input2.mp4 -ss 3471 -to 3484 -an -i input3.mp4 -an -i input4.mp4 -stream_loop -1 -i audio.mp3 -filter_complex "[0:v][1:v][2:v][3:v]concat=n=4:v=1:a=0[v]" -map "[v]" -fps_mode:v vfr -map 4:a:0 -c:a copy -c:v h264_nvenc -preset fast -shortest -f mp4 output2.mp4