Answers.Body: <p>Regarding,</p>
  
  <pre><code>Cannot find a matching stream for unlabeled input pad 0 on filter Parsed_hwupload_cuda_17
  </code></pre>
  
  <p>in</p>
  
  <pre><code>[tmp3][lowerright] overlay=shortest=1:x=720:y=480;hwupload_cuda
  </code></pre>
  
  <p>you have to replace the <code>;</code> with a <code>,</code> else the overlay filterchain is terminated and the hwupload starts a new chain.</p>
  
  <p>Input options like <code>-hwaccel cuvid -c:v h264_cuvid</code> only apply to the input immediately following them. These options have to be prefixed before each input for which they're intended.</p>
  
  <p><code>scale_npp</code> 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 <code>hwdownload,format=nv12</code>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-23T08:38:01.637Z
Answers.LastActivityDate: 2018-10-23T08:38:01.637Z
Answers.UserDisplayName: Gyan
Body: <p>I'm currently trying to achieve a mosaic including 4 videos using FFmpeg and hardware acceleration.</p>
  
  <p>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.</p>
  
  <p>I've succeeded to create it without hardware acceleration but I'm stuck. Here is the command line I use : </p>
  
  <pre><code>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 -
  </code></pre>
  
  <p>It doesn't work and I get :</p>
  
  <pre><code>Cannot find a matching stream for unlabeled input pad 0 on filter Parsed_hwupload_cuda_17
  </code></pre>
  
  <p>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 <code>[base]</code> before <code>hwupload_cuda</code> but it doesn't help, and honestly, I'm a bit lost.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-22T14:51:13.740Z
Comments.Text: Do you mean to decode the same video four times?
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-22T15:03:54.073Z
Comments.Text: 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.
Comments.UserDisplayName: c.censier
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-22T15:07:30.770Z
Comments.Text: 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.
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-23T06:34:44.920Z
Comments.Text: 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 ?
Comments.UserDisplayName: c.censier
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-23T07:16:39.893Z
Comments.Text: You're scaling on the GPU so you need hwdownload and the format *after* `scale_npp`.
Comments.UserDisplayName: Gyan
Tags: <ffmpeg><nvidia>
Title: FFmpeg mosaic with hardware acceleration on Quadro P4000
UserDisplayName: c.censier
ThreadText: # FFmpeg mosaic with hardware acceleration on Quadro P4000
  
  (Asked by: username_0 on 2018-10-22)
  
  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.
  
  **Tags:** ffmpeg, nvidia
  
  > **Comments:**
  > **username_1**: Do you mean to decode the same video four times?  
  > **username_0**: 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.  
  > **username_1**: 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.  
  > **username_0**: 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 ?  
  > **username_1**: You're scaling on the GPU so you need hwdownload and the format *after* `scale_npp`.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-10-23. Score: 2 | Accepted answer
  
  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`.
  
  
  ---
  
  