2

I have a NVIDIA Quadro P620. I have a lot of research on how to accelerate my transcoding using my graphic card.

I stumble on this page https://trac.ffmpeg.org/wiki/HWAccelIntro#Usewiththeffmpegcommand-linetool

So, I tried

ffmpeg -hwaccel cuda -i input.avi output.mp4

It did not turn out any faster than

ffmpeg -i input.avi output.mp4

It actually took longer for transcoding.

I can see it spend the same CPU usage on resmon as without -hwaccel option.

Did I do something wrong? How do I know ffmpeg is correctly using my GPU?

5
  • So, I'm assuming you're using Linux? That would be one the details you should've posted already, that and your Nvidia drivers and CUDA versions. Apr 22, 2021 at 15:23
  • I am using windows 10. I can see it did accelerate now after adding the h264_nvenc codec now
    – Hoy Cheung
    Apr 22, 2021 at 15:24
  • You may want to ask a different question or edit this one. This isn't a forum, it's a Q&A. Apr 22, 2021 at 15:29
  • 4
    Different encoders have different goals. Nvidia encoders (and hardware encoders in general) are more optimised for streaming and speed and efficient use of power than they are towards high quality and small file size. If you want best quality for smallest size then CPU encoding is the way to go. Fixed function hardware is far faster, but due to being fixed in hardware has far less scope for catering for every possible optimisation and is entirely incapable of being upgraded in place. You want a newer and better encoder, you replace your graphics card type thing...
    – Mokubai
    Apr 22, 2021 at 15:44
  • 2
    In short, hardware encoders and decoders for video files — think archiving — really stink unless you are using video card that is specifically designed for high quality video compression. And in my experience x264 is the best format for hardware encoding and decoding. x265 is a very CPU intensive codec and one can assume the only video cards that can really handle that well — as far as encoding goes — are really pricey. Apr 22, 2021 at 16:24

1 Answer 1

5

According to the Video Encode and Decode GPU Support Matrix, your GPU supports hardware-assisted decode and encode, also called NVENC.

The only troubling point here is the list of codecs that your GPU supports, which are: H.264 and H.265. If your videos are not encoded with these codecs, hardware acceleration might not work for you.

For the right codecs and for reference, the Stack Overflow post make ffmpeg chose Nvidia CUDA over Intel QSV mentioned that hardware acceleration was working with the following command:

ffmpeg -hide_banner -hwaccel cuda -i "input.avi" -c:a copy -ac 1 -c:v h264_nvenc -preset hq -movflags faststart -qp 30 "output.mp4"
7
  • I viewed my p620 spec. It says the card specialized in encoding H.264 and HEVC. Which does a better compression? How do I transcode too HEVC in ffmpeg?
    – Hoy Cheung
    Apr 22, 2021 at 16:51
  • See Why is HEVC Better than H.264?
    – harrymc
    Apr 22, 2021 at 16:54
  • I found the codec name for hevc is libx265. So when I try to transcode the file, ffmpeg told me off: Video uses a non-standard and wasteful way to store B-frames ('packed B-frames'). Consider using the mpeg4_unpack_bframes bitstream filter without encoding but stream copy to fix it. Impossible to convert between the formats supported by the filter 'Parsed_null_0' and the filter 'auto_scaler_0' Error reinitializing filters! Failed to inject frame into filter network: Function not implemented Error while processing the decoded data for stream #0:0 How do I get pass this?
    – Hoy Cheung
    Apr 22, 2021 at 17:00
  • Try H.264, but the problem might be with the format of the input.
    – harrymc
    Apr 22, 2021 at 17:03
  • Problem is H264 compression is no good. File size is so big.
    – Hoy Cheung
    Apr 22, 2021 at 17:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .