[FFmpeg-user] The option of -hwaccel device doesn't works well(FFmpeg n3.4)

Baek Seung Hoon seung51hoon at gmail.com
Sat Nov 4 04:48:37 EET 2017

Thanks to your reply :-)

As your mentions, Hw decoder already has resize option.
Why I use scale_npp filter with Sw decoder is Hw decoder(=cuvid) couldn't
read some of video files while Sw decoder(=h264) could read it.
So I choose a decoder this way -> use the Sw decoder if Hw decoder failed
read video file.

Your reply message is helpful to me ^^.
But I have a problem what same as previous mail.
In case that I use both Sw decoder and Hw encoder with below command, and
Only GPU0 encoder have working.
I did change option as -gpu 0 or -gpu 1, it doesn't affect.
I assume that "hwupload_cuda" have a unknown bug because "gpu" option was
works well when I remove "hwupload_cuda".

*[FFmpeg command]*
  > ffmpeg -y -i ./input.mp4 -filter_complex
"[0:v]hwupload_cuda,scale_npp=w=960:h=540,setsar=1[map0]" -map [map0] -c:v
h264_nvenc -gpu "1" -vprofile high -map 0:a -c:a copy ./output.mp4
    (Only Gpu0 decoder will be working) -> I want to assign encoding job to

  > ffmpeg -y -i ./input.mp4 -filter_complex "[0:v]setsar=1[map0]" -map
[map0] -c:v h264_nvenc -gpu "1" -vprofile high -map 0:a -c:a copy

Would you hele me out one more to solve this problem ?
Thanks to read this mail.

2017-11-03 13:07 GMT+09:00 James Girotti <james.girotti at gmail.com>:

> Hello,
> Let me start by saying that I only have one NVENC capable GPU, so I cannot
> test this. I hope to point you in the right direction though.
> On Thu, Nov 2, 2017 at 7:38 PM, Baek Seung Hoon <seung51hoon at gmail.com>
> wrote:
> > Could you tell me how can I select gpu device with FFmpeg CLI in this
> > problem?
> >
> For all of the nvenc encoders there is a '-gpu' option: "Selects which
> NVENC capable GPU to use. First GPU is 0, second is 1, and so on. (from -2
> to INT_MAX) (default any)"
> The cuvid decoders have similar '-gpu' options.
> > *====================================================*
> > *Below is test command*
> > 1. The first gpu device(index is 0) is always working although input
> option
> > is hwaccel_device 1.
> >     $) ffmpeg -hwaccel_device 1 -y -i ./input.mp4 -filter_complex
> > "[0:v]hwupload_cuda,scale_npp=w=960:h=540:format=yuv420p:
> > interp_algo=lanczos,setsar=1[map0]"
> > -map [map0] -c:v h264_nvenc -vprofile high -map 0:a -c:a copy
> ./output.mp4
> >
> >
> The above command doesn't use a hw-decoder (not a real problem if that's
> what you want.) But I'm not sure if the '-hwaccel_device' option does
> anything without something like '-hwaccel cuvid' and specifying '-c:v
> h264_cuvid' before '-i ./input.mp4'.
> > 2. If I remove "hwupload_cuda" options in filter_complex, hwaccel_device
> > option works well.
> >     $) ffmpeg -hwaccel_device 1 -hwaccel cuvid -y -c:v h264_cuvid -i
> > ./input.mp4 -filter_complex
> > "[0:v]scale_npp=w=960:h=540:format=yuv420p:interp_algo=
> > lanczos,setsar=1[map0]"
> > -map [map0] -c:v h264_nvenc -vprofile high -map 0:a -c:a copy
> ./output.mp4
> >
> This command is significantly different from the previous. It's more than
> just removing "hwupload_cuda". This command uses hw-decoding, which is why
> you don't have to "hwupload_cuda" because the frames are already in GPU
> memory. Also, likely why '-hwaccel_device 1' works.
> I see that you are using scale_npp to resize your video and I would be
> amiss if I did not mention that the cuvid decoders have resizing and
> cropping built in now. You don't need to use scale_npp to scale/resize, you
> could do something as simple as:
> ffmpeg -hwaccel_device 1 -hwaccel cuvid -c:v h264_cuvid -resize 960x540 -i
> ./input.mp4 -vf "setsar=sar=1" -c:v h264_nvenc -vprofile high -map 0:a -c:a
> copy ./output.mp4
> I hope that help!
> -J
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".

More information about the ffmpeg-user mailing list