The processing demands from high quality video applications have pushed limits for broadcast and telecommunication networks. Content in production may arrive in one of the large numbers of codec formats that needs to be transcoded into another for distribution or archiving. Video providers want to reduce the cost of delivering more content with great quality to more screens. The massive video content generated on all fronts requires robust hardware acceleration of video encoding, decoding, and transcoding.
Actual support depends on the GPU that is used.
Hardware acceleration dramatically improves the performance of the workflow. Figure 2 shows the different elements of the transcoding process with FFmpeg.
Activating support for hardware acceleration when building from source requires some extra steps:. But this is going to be slow slow since it only uses the CPU-based software encoder and decoder. Maximizing the transcoding speed also means making sure that the decoded image is kept in GPU memory so the encoder can efficiently access it.
These two additional transfers create latency due to the transfer time and will increase PCIe bandwidth occupancy. Transcoding often involves not only changing format or bitrate of the input stream, but also resizing it.
The nvcuvid resize option can be used when transcoding from one input to one output stream with different resolution transcode. See the next line for an example. This way we can generate multiple output streams with multiple different resolutions but only using one resize step for all streams.
See the next line for an example of transcode. Using the super-sampling algorithm is recommended for best quality when downscaling. See below for an example:. In the example below, an H. In the example below the work will be executed on the gpu with index 1. All encoder and decoder units should be utilized as much as possible for best throughput. Multiple actions may be taken depending on those results.
If encoder utilization is low, it might be feasible to introduce another transcoding pipeline that uses CPU decode and NVENC encode to generate additional workload for the hardware encoder. If possible, filters should run on the GPU. The application timeline is illustrated on fig. Turquoise blocks show colorspace conversion done by CUDA kernels while yellow blocks show memory transfer between host and device.
Using Visual profiler allows users to easily track operations done on GPU, such as CUDA-accelerated filters and data transfers to ensure no excessive memory copies are done. Collect CPU-side perforamnce statistics by compiling ffmpeg with the --disable-stripping CLI option to enable performance profiling. This prevents the compiler from stripping function names so that commodity profilers like Gprof or Visual Studio profiler can collect performance statistics.
Figure 6 shows an example screenshot. FFmpeg is a powerful and flexible open source video processing library with hardware accelerated decoding and encoding backends.Note that this filter is not FDA approved, nor are we medical professionals.
Nor has this filter been tested with anyone who has photosensitive epilepsy. FFmpeg and its photosensitivity filter are not making any medical claims.
That said, this is a new video filter that may help photosensitive people watch tv, play video games or even be used with a VR headset to block out epiletic triggers such as filtered sunlight when they are outside. Or you could use it against those annoying white flashes on your tv screen.
The filter fails on some input, such as the Incredibles 2 Screen Slaver scene. It is not perfect. If you have other clips that you want this filter to work better on, please report them to us on our trac. See for yourself. We are not professionals. Please use this in your medical studies to advance epilepsy research.
If you decide to use this in a medical setting, or make a hardware hdmi input output realtime tv filter, or find another use for this, please let me know. This filter was a feature request of mine since FFmpeg 4. Some of the highlights:. We strongly recommend users, distributors, and system integrators to upgrade unless they use current git master. FFmpeg 3. This has been a long time coming but we wanted to give a proper closure to our participation in this run of the program and it takes time.
Sometimes it's just to get the final report for each project trimmed down, others, is finalizing whatever was still in progress when the program finished: final patches need to be merged, TODO lists stabilized, future plans agreed; you name it.
Without further ado, here's the silver-lining for each one of the projects we sought to complete during this Summer of Code season:. Stanislav Dolganov designed and implemented experimental support for motion estimation and compensation in the lossless FFV1 codec. The design and implementation is based on the snow video codec, which uses OBMC. Stanislav's work proved that significant compression gains can be achieved with inter frame compression.
Petru Rares Sincraian added several self-tests to FFmpeg and successfully went through the in-some-cases tedious process of fine tuning tests parameters to avoid known and hard to avoid problems, like checksum mismatches due to rounding errors on the myriad of platforms we support.
His work has improved the code coverage of our self tests considerably. He also implemented a missing feature for the ALS decoder that enables floating-point sample decoding. We welcome him to keep maintaining his improvements and hope for great contributions to come. He succeeded in his task, and the FIFO muxer is now part of the main repository, alongside several other improvements he made in the process.
Jai Luthra's objective was to update the out-of-tree and pretty much abandoned MLP Meridian Lossless Packing encoder for libavcodec and improve it to enable encoding to the TrueHD format.
For the qualification period the encoder was updated such that it was usable and throughout the summer, successfully improved adding support for multi-channel audio and TrueHD encoding. Jai's code has been merged into the main repository now. While a few problems remain with respect to LFE channel and 32 bit sample handling, these are in the process of being fixed such that effort can be finally put in improving the encoder's speed and efficiency.
Davinder Singh investigated existing motion estimation and interpolation approaches from the available literature and previous work by our own: Michael Niedermayer, and implemented filters based on this research. These filters allow motion interpolating frame rate conversion to be applied to a video, for example, to create a slow motion effect or change the frame rate while smoothly interpolating the video along the motion vectors.
The dark mode beta is finally here. Change your preferences any time. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. As Mike mentioned, ffmpeg wraps some of these HW-accelerations. But: Be careful and so some benchmarking. I would say no no no except for very high bitrates or very bad qualitybut that's something which dependes on your use-case. GPU-encoding is not a silver-bullet providing only advantages.
Learn more. GPU-accelerated video processing with ffmpeg Ask Question. Asked 2 years, 10 months ago. Active 11 months ago. Viewed 61k times. Paradox 8 8 silver badges 25 25 bronze badges.
Wang Hai Wang Hai 1 1 gold badge 2 2 silver badges 7 7 bronze badges. Yes, you can use cuda cores to encode and decode video, just like you could with just about any programmable processor. Were you planning to write that software yourself?
Well, the name says it's decoding only. So it may help only partially in your case. So you would need to write the CUDA code yourself, or find 3rd party libraries that do it. If you are asking for links for 3rd party libraries, that question is off-topic for SO. Unless you actually want to do the programming work yourself, this question is off-topic for SO. Active Oldest Votes.
Mike Versteeg Mike Versteeg 1, 8 8 silver badges 24 24 bronze badges. NetherGranite 1, 4 4 silver badges 29 29 bronze badges. I have tried ffmpeg with hw acceleratelike the decode and transcode, it runs almost the same speed compared to soft decode on my laptop iU cpu, M gpuwhile with less cpu load. So I want make use of cuda cores.Many platforms offer access to dedicated hardware to perform a range of video-related tasks. Using such hardware allows some operations like decoding, encoding or filtering to be completed faster or using less of other resources particularly CPUbut may give different or inferior results, or impose additional restrictions which are not present when using software only.
Hardware decoders will generate equivalent output to software decoders, but may use less power and CPU to do so. Feature support varies — for more complex codecs with many different profiles, hardware decoders rarely implement all of them for example, hardware decoders tend not to implement anything beyond YUV at 8-bit depth for H. A common feature of many hardware decoders to be able to generate output in hardware surfaces suitable for use by other components with discrete graphics cards, this means surfaces in the memory on the card rather than in system memory — this is often useful for playback, as no further copying is required before rendering the output, and in some cases it can also be used with encoders supporting hardware surface input to avoid any copying at all in transcode cases.
Hardware encoders typically generate output of significantly lower quality than good software encoders like x, but are generally faster and do not use much CPU resource. That is, they require a higher bitrate to make output with the same perceptual quality, or they make output with a lower perceptual quality at the same bitrate.
Things like scaling and deinterlacing are common, other postprocessing may be available depending on the system. Where hardware surfaces are usable, these filters will generally act on them rather than on normal frames in system memory. There are a lot of different APIs of varying standardisation status available.
FFmpeg offers access to many of these, with varying support. Internal hwaccel decoders are enabled via the -hwaccel option. The software decoder starts normally, but if it detects a stream which is decodable in hardware then it will attempt to delegate all significant processing to that hardware.
If the stream is not decodable in hardware for example, it is an unsupported codec or profile then it will still be decoded in software automatically. External wrapper decoders are used by setting a specific decoder with the -codec:v option. These decoders require the codec to be known in advance, and do not support any fallback to software if the stream is not supported. Encoder wrappers are selected by -codec:v.
Encoders generally have lots of options — look at the documentation for the particular encoder for details. Hardware filters can be used in a filter graph like any other filter. Note, however, that they may not support any formats in common with software filters — in such cases it may be necessary to make use of hwupload and hwdownload filter instances to move frame data between hardware surfaces and normal memory.
To enable this you typically need the libvdpau development package in your distribution, and a compatible graphics card. Also, note that with this API it is not possible to move the decoded frame back to RAM, for example in case you need to encode again the decoded frame e. DXVA2 hardware acceleration only works on Windows.
For MinGW64, dxva2api. One way to install mingw-w64 is through a pacman repository, and can be installed using one of the two following commands, depending on the architecture:. They can be used for encoding and decoding on Windows and Linux. In order to enable it in FFmpeg you need:. FFmpeg will look for its pkg-config file, called ffnvcodec. See encoder info as shown above. They differ in how frames are decoded and forwarded in memory.FFmpeg is a free and open-source project consisting of a vast software suite of libraries and programs for handling video, audio, and other multimedia files and streams.
At its core is the FFmpeg program itself, designed for command-line -based processing of video and audio files, and widely used for format transcodingbasic editing trimming and concatenationvideo scalingvideo post-production effects, and standards compliance SMPTEITU. FFmpeg is part of the workflow of hundreds of other software projects, and its libraries are a core part of software media players such as VLCand has been included in core processing for YouTube and the iTunes inventory of files.
On January 10,two Google employees announced that over bugs had been fixed in FFmpeg during the previous two years by means of fuzz testing. In Januarythe ffserver command-line program — a long-time component of FFmpeg — was removed. The project publishes a new release every three months on average. While release versions are available from the website for download, FFmpeg developers recommend that users compile the software from source using the latest build from their source code Git version control system.
Two video coding formats with corresponding codecs and one container format have been created within the FFmpeg project so far.
The two video codecs are the lossless FFV1and the lossless and lossy Snow codec. Development of Snow has stalled, while its bit-stream format has not been finalized yet, making it experimental since The multimedia container format called NUT is no longer being actively developed, but still maintained. Through testing, they determined that ffvp8 was faster than Google's own libvpx decoder.
FFmpeg 3. On March 13,a group of FFmpeg developers decided to fork the project under the name " Libav ". FFmpeg encompasses software implementations of video and audio compressing and decompressing algorithms. These can be compiled and run on diverse instruction sets. Various application-specific integrated circuits ASIC related to video and audio compression and decompression do exist.
Internal hardware acceleration decoding is enabled through the -hwaccel option. It starts decoding normally, but if a decodable stream is detected in hardware, then the decoder designates all significant processing to that hardware, thus accelerating the decoding process. Whereas if no decodable streams are detected as happens on an unsupported codec or profilehardware acceleration will be skipped and it will still be decoded in software.
In addition to FFV1 and Snow formats, which were created and developed from within FFmpeg, the project also supports the following formats:.
FFmpeg GPU Transcoding Examples
Output formats container formats and other ways of creating output streams in FFmpeg are called "muxers". FFmpeg supports, among others, the following:.
FFmpeg supports many pixel formats. FFmpeg supports, among others, the following filters. FFmpeg contains more than codecs,  most of which use compression techniques of one kind or another. Many such compression techniques may be subject to legal claims relating to software patents.
Platform API Availability
From Wikipedia, the free encyclopedia. This article relies too much on references to primary sources. Relevant discussion may be found on the talk page.GPU-accelerated video processing integrated into the most popular open-source multimedia tools. FFmpeg and libav are among the most popular open-source multimedia manipulation tools with a library of plugins that can be applied to various parts of the audio and video processing pipelines and have achieved wide adoption across the world.
Video encoding, decoding and transcoding are some of the most popular applications of FFmpeg. Download FFmpeg main tree : GitHub. For more information on FFmpeg licensing, please see this page. HandBrake is an open-source video transcoder available for Linux, Mac, and Windows.
HandBrake works with most common video files and formats, including ones created by consumer and professional video cameras, mobile devices such as phones and tablets, game and computer screen recordings, and DVD and Blu-ray discs.
The Plex Transcoder uses FFmpeg to handle and translates your media into that the format your client device supports. Please refer to GPU support matrix for specific codec support. Skip to main content. About Contact Forums Blog Search form. Decode Capability Query MoreHigh quality is not always easy to define. I would define high quality as equal or near same quality as the original and this is the goal. Using the preset option delivers quality that easyily surpasses Adobe Media Encoderespecially colorbanding and macroblocks artifacts reduced significantly with ffmpeg when using the h codec with the -crf option.
Booth are encoded with 6 Mbit average bitrate — fot the ffmpeg version, the -crf option was used and for the AME version, the CBR option was used to encode. See the difference on the arm in motion. Parameters -preset slow preset for HQ encoding see x preset profiles below -tune film preset for film content see x tune profiles below -crf 16 constant quality factor lower is better good values for HD are -a aac AAC audio codec is most common for MP4 movie files.
NOTE: Use -crf if bitrate is not so important and the quality factor is more important. Choose -b:v if you need a limitation for the bitrate and size of the video. This way it is possible to process the frames, for example with the -vf option. Quality Using the preset option delivers quality that easyily surpasses Adobe Media Encoderespecially colorbanding and macroblocks artifacts reduced significantly with ffmpeg when using the h codec with the -crf option.
INFO: A new eBook is in the works about video encoding with lots of ffmpeg examples, high quality encoding settings, workflows with Adobe Premiere and many in-depth infos. Categories Post-Production.