2

I'm currently trying to achieve a mosaic including 4 videos using FFmpeg and hardware acceleration.

I'm working on Ubuntu 16.04, I've installed NVIDIA drivers using apt repo aswell as CUDA. I'm using FFmpeg in version 3.3.

I've succeeded to create it without hardware acceleration but I'm stuck. Here is the command line I use :

ffmpeg -hwaccel cuvid -c:v h264_cuvid \
-i bbb_sunflower_2160p_30fps_normal.mp4 \
-i bbb_sunflower_2160p_30fps_normal.mp4 \
-i bbb_sunflower_2160p_30fps_normal.mp4 \
-i bbb_sunflower_2160p_30fps_normal.mp4 \
-filter_complex "nullsrc=size=1440x960 [base]; \
[0:v] hwdownload, format=nv12, scale_npp=720x480 [upperleft]; \
[1:v] hwdownload, format=nv12, scale_npp=720x480 [upperright]; \
[2:v] hwdownload, format=nv12, scale_npp=720x480 [lowerleft]; \
[3:v] hwdownload, format=nv12, scale_npp=720x480 [lowerright]; \
[base][upperleft] overlay=shortest=1 [tmp1]; \
[tmp1][upperright] overlay=shortest=1:x=720 [tmp2]; \
[tmp2][lowerleft] overlay=shortest=1:y=480 [tmp3]; \
[tmp3][lowerright] overlay=shortest=1:x=720:y=480; \
hwupload_cuda" \
-c:v h264_nvenc -f matroska pipe:1 | ffplay -i -

It doesn't work and I get :

Cannot find a matching stream for unlabeled input pad 0 on filter Parsed_hwupload_cuda_17

I think the issue is about the upload of modified frames by filters into the card but I can't figure how to achieve it. I've tried to add [base] before hwupload_cuda but it doesn't help, and honestly, I'm a bit lost.

5
  • Do you mean to decode the same video four times?
    – Gyan
    Commented Oct 22, 2018 at 14:51
  • I work with the same video 4 times for test purpose, but the goal is to decode 4 differents video and display it in a mosaic.
    – c.censier
    Commented Oct 22, 2018 at 15:03
  • Ok. You'll need -hwaccel cuvid -c:v h264_cuvid before each -i and and a comma instead of a semi-colon after the last overlay.
    – Gyan
    Commented Oct 22, 2018 at 15:07
  • I got an error Impossible to convert between the formats supported by the filter 'Parsed_format_2' and the filter 'auto_scaler_0' and Failed to inject frame into filter network: Function not implemented. I may have to specify a hardware compliant format ?
    – c.censier
    Commented Oct 23, 2018 at 6:34
  • You're scaling on the GPU so you need hwdownload and the format after scale_npp.
    – Gyan
    Commented Oct 23, 2018 at 7:16

1 Answer 1

2

Regarding,

Cannot find a matching stream for unlabeled input pad 0 on filter Parsed_hwupload_cuda_17

in

[tmp3][lowerright] overlay=shortest=1:x=720:y=480;hwupload_cuda

you have to replace the ; with a , else the overlay filterchain is terminated and the hwupload starts a new chain.

Input options like -hwaccel cuvid -c:v h264_cuvid only apply to the input immediately following them. These options have to be prefixed before each input for which they're intended.

scale_npp is a CUDA scaler, so for a hardware-decoded stream, no filter is required to transfer frames. After scaling, frames will have to be transported to system memory using hwdownload,format=nv12.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.