Recently, I am developing a video analysis system based on video streams. When using the browser to play the finished video, the browser needs the fmp4 format stream, which needs to be transcoded by ffmpeg. During the development phase, the CPU version of ffmpeg was used, but the online deployment was very unsatisfactory. So I compiled a GPU version.
Compiling hardware-accelerated ffmpeg from source code requires several steps
- Download the
ffmpegsource code https://git.ffmpeg.org/ffmpeg.git
- download the Nvidia driver
- install CUDA toolkit
nv-codec-headerssource code https://github.com/FFmpeg/nv-codec-headers.git
Since I have the specified version of the Nvidia driver and CUDA toolkit installed locally, I skip these two steps.
After the above steps, the GPU version of ffmpeg is compiled and tested to see if it works.
The original CPU version of the transcode command.
Modify the transcoding command to the GPU version.
The conversion was tested successfully.
Of course, in the video analysis system, it is not directly transcoded using the command line in this way, but through the input and output pipeline, and the input parameters and output parameters also need to be adjusted accordingly according to the actual encoding format.