This article is a mirror article of machine translation, please click here to jump to the original article.

View: 17009|Reply: 4

Use GPU-accelerated ffmpeg to process tasks under Windows

[Copy link]
Posted on 2019-11-7 21:08:29 | | | |
ffmpeg download

Official website download page:
The hyperlink login is visible.
It is recommended to download the compiled version and download the page:
The hyperlink login is visible.
I generally prefer to download the latest version (named after the date) and of course there is a stable version (named after the version number).



CUDA download

CUDA is a driver that allows the GPU to perform related operations, because we develop applications that do not directly control the GPU, but operate through the driver.
The hyperlink login is visible.
Here I choose the version as shown below:
Of course, you can also click the link below to go directly to the settings when I downloaded.
The hyperlink login is visible.


After downloading, remember to install it, so I won't introduce it, after all, they are all developing software.

command

Query commands
Check whether the downloaded ffmpeg supports cuda, if it doesn't (I downloaded it), then download it again or compile it yourself.




Test commands

Convert the 0.mp4 in the current directory to 00.mp4
Convert the 0.mp4 in the current directory to 00.mp4 and specify the output frame rate of 15 (-r 15) and the bitrate of 500k (-b 500k).
-hwaccel cuvid: Specifies the use of cuvid hardware acceleration
-c:v h264_cuvid: Video decoding using h264_cuvid
-c:v h264_nvenc: Video encoding with h264_nvenc
-vf scale_npp=1280:-1: Specify the width and height of the output video, note that this is different from the -vf scale=x:x used for soft decoding

Multiple graphics card commands

GPU transcoding efficiency test
On a server with two Intel-E5-2630v3 CPUs and two Nvidia Tesla M4 graphics cards, the h264 video transcoding test was performed as follows:

Average GPU transcoding time: 8s
Average CPU transcoding time: 25s

When transcoding in parallel, the efficiency of CPU soft conversion is improved, and all 32 cores are occupied when the three transcoding tasks are parallel

Average GPU transcoding time: 8s
Average CPU transcoding time: 18s

It is not difficult to see that the transcoding speed of the GPU does not increase when parallel, which shows that a GPU can only perform one transcoding task at the same time. So, if multiple graphics cards are inserted on the server, will ffmpeg use multiple GPUs for parallel transcoding?
Unfortunately, the answer is no.
ffmpeg does not have the ability to automatically assign transcoding tasks to different GPUs, but after some investigation, it was found that the GPU used for the transcoding task can be specified by the -hwaccel_device parameter!
Submit transcoding tasks to different GPUs

Graphics 0


Graphics card1

Illustrate:

-hwaccel_device N: Specify a GPU to perform a transcoding task, N is a number





Previous:[Practical combat] Create a Docker image based on Nginx
Next:2000 logo prototypes
 Landlord| Posted on 2019-11-7 21:18:35 |
//参数说明
/*
    * -i filename(input) source file directory
    * -y Outputs new files, whether to force overwrite existing files
    * -c Specifies the encoder
    * -fs limit_size(outinput) sets the limit on the file size, expressed in bytes. No further byte blocks are written after the limit is exceeded. The size of the output file is slightly larger than the requested file size.
    * -s video ratio 4:3 320x240/640x480/800x600 16:9 1280x720, default value 'wxh', same as the original video size
    * -vframes number(output) sets the number of video frames to the output. Alias: -frames:v
    * -dframes number (output) sets the number of data frames to the output. Alias: -frames:d
    * -frames[:stream_specifier] framecount(output,per-stream) stops writing to the stream for the number of frames.
    * -bsf[:stream_specifier] bitstream_filters (output,per-stream) specifies the output file stream format,
For example, output an MP4 file encoded by h264: ffmpeg -i h264.mp4 -c:v copy -bsf:v h264_mp4toannexb -an out.h264
    * -r 29.97 Zhen rate (can be changed, make sure that non-standard Zhen rate will cause the sound and picture to be out of sync, so it can only be set to 15 or 29.97)
    *
    */
 Landlord| Posted on 2019-11-8 15:07:05 |
ffmpeg.exe -hwaccel_device 1 -hwaccel cuvid -i C:\Users\DELL\Desktop\VideoDemo\VideoDemo\bin\Debug\A14.mp4 -y C:\Users\DELL\Desktop\VideoDemo\VideoDemo\bin\Debug\A16.avi

https://blog.csdn.net/Tosonw/article/details/90178195


nvcc --version

CUVID is a CUDA-based video decoding library that uses CUVID for decoding


Failed to create Direct3D device
Device creation failed: -1313558101.

The ffmpeg version must correspond to the synchronous graphics card driver to enable hardware acceleration correctly.


Check out the NVIDIA hardware acceleration codec:

.\ffmpeg.exe -codecs | sls nvenc
.\ffmpeg.exe -codecs | sls cuvid

The prefix has the following meanings:

Prefix meaning
D….. = Decoding supported
. E…. = Encoding supported
.. V… = Video codec
.. A… = Audio codec
.. S… = Subtitle codec
… I.. = Intra frame-only codec
….L. = Lossy compression
….. S = Lossless compression



ffmpeg.exe -hwaccel_device 1 -hwaccel cuvid -c:v h264_cuvid -i C:\Users\DELL\Desktop\VideoDemo\VideoDemo\bin\Debug\A14.mp4 -c:v h264_nvenc -y C:\Users\DELL\Desktop\VideoDemo\ VideoDemo\bin\Debug\A16.avi

ffmpeg.exe -hwaccel cuvid -c:v h264_cuvid -i C:\Users\DELL\Desktop\VideoDemo\VideoDemo\bin\Debug\A14.mp4 -c:v h264_nvenc -y C:\Users\DELL\Desktop\VideoDemo\VideoDemo\bin\Debug\ A16.avi


https://developer.nvidia.com/ffmpeg
Posted on 2023-2-26 12:11:24 |
Prompt:Authors are banned or removed content is automatically blocked
Posted on 2023-2-26 12:13:35 |
Prompt:Authors are banned or removed content is automatically blocked
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com