Search code examples
ffmpegvideo-processing

Ffmpeg concatenate video file with hw acceleration using cuvid


I am trying to use Nvidia hardware acceleration for FFmpeg using cuvid. I want to merge multiple h264 / mp4 files using a complex filter (simplified example):

ffmpeg -hwaccel cuvid -c:v h264_cuvid -i input.ts -y -fflags +genpts -filter_complex "[0:v:0][0:a:0]concat=n=1:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" output.mp4

I use the following version FFmpeg and Ubuntu 16.04:

version 3.4.2-1~16.04.york0.2 Copyright (c) 2000-2018 the FFmpeg developers built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 20160609

If i run the command i get the following error:

Impossible to convert between the formats supported by the filter 'Parsed_concat_0' and the filter 'auto_scaler_0'
Error reinitializing filters!
Failed to inject frame into filter network: Function not implemented

When i remove the hwaccel flag the command runs but i get a massive CPU load. How can i use a concat complex_filter in combination with cuvid hw acceleration?

SOLUTION

The concat demuxing worked. The output of the encoder is now in h264. I group the files in a list.txt:

file '/path/to/file1'
file '/path/to/file2'
file '/path/to/file3'

Then run ffmpeg:

ffmpeg -y -f concat -safe 0 -i list.txt -c copy result.mp4

Solution

  • SOLUTION

    The concat demuxing worked. The output of the encoder is now in h264. I group the files in a list.txt:

    file '/path/to/file1'
    file '/path/to/file2'
    file '/path/to/file3'
    

    Then run ffmpeg:

    ffmpeg -y -f concat -safe 0 -i list.txt -c copy result.mp4