Avidemux Forum

Participate => User interface and Usability => Topic started by: thomas.rehberg on December 10, 2019, 08:50:48 PM

Title: encoding with intel h264 (HW), any plans for more configuration options ?
Post by: thomas.rehberg on December 10, 2019, 08:50:48 PM
I´m running version 2.7.4 Linux 64bit, and I have a Haswell platform running. When using the intel H264 encoder (which is the ffmpeg vaapi HW encoder) I can open a config dialog, however, very limited options only.
No rate control, lookahead, etc. that one can select here. Disappointing, as my platform is compatible to use the Intel HW encoding (and yes I know it´s not of the same quality as SW encoding, but very fast and CPU friendly).
Are there any plans to add the options that are available just as you would encode at the terminal ?

I would volunteer to play the testbench, but I´m afraid I cannot change the code...
Title: Re: encoding with intel h264 (HW), any plans for more configuration options ?
Post by: eumagga0x2a on December 12, 2019, 12:41:21 AM
Enhancing the FFmpeg VAAPI video encoder plugin is definitely on my wish list, but not a priority.

QuoteI would volunteer to play the testbench

Thanks, I have a testbench sitting on the desk 30 cm away from the keyboard I'm typing on, so this is not a problem.

Quotebut I´m afraid I cannot change the code...

This was exactly how I thought about Avidemux three years ago, starting with zero coding knowledge.
Title: Re: encoding with intel h264 (HW), any plans for more configuration options ?
Post by: thomas.rehberg on December 12, 2019, 04:55:39 PM
ok, so then nothing that I can expect near term.
Could you easily indicate where in the code the gui popup of the codec configuration is located ?
Title: Re: encoding with intel h264 (HW), any plans for more configuration options ?
Post by: eumagga0x2a on December 12, 2019, 07:10:05 PM
It is in ffVAEncConfigure() located at avidemux_plugins/ADM_videoEncoder/ffVaH264/ADM_ffVAEncH264.cpp:346.

You will need to extend the ffvaenc_encoder struct in avidemux_plugins/ADM_videoEncoder/ffVaH264/ffVAEnc_H264.conf and regenerate the .h and the _desc.cpp files by running

../../../cmake/admSerialization.py ffVAEnc_H264.conf

in the ffVaH264 directory. New functionality will probably go into ADM_ffVAEncH264Encoder::configureContext().

For multipass encoding, you might want to look at the implementation in ADM_ffMpeg4.cpp.
Title: Re: encoding with intel h264 (HW), any plans for more configuration options ?
Post by: Bart Z Lederman on January 09, 2021, 02:14:29 PM
I'm a bit confused here.

I see references to various hardware acceleration options and improvements being made to Avidemux, but I don't see any instructions on how to actually access them.

I've done some tests using ffmpeg and the h264_qsv (Intel) codec, and it makes a huge improvement in the time it takes to encode a video (12x or more).  I'd like to use that
with Avidemux, but can't figure out how.  And I also have a system with an Nvidia card
and would like to use the nvenc_h264 codec if possible.

Perhaps I'm missing something "obvious", but could someone point me to instructions on how to do this?  Or perhaps elaborate on the recent news about hardware acceleration enhancements to Avidemux?

Thanks.
Title: Re: encoding with intel h264 (HW), any plans for more configuration options ?
Post by: eumagga0x2a on January 09, 2021, 02:17:53 PM
Which version of Avidemux (it should be the latest git or as close to it as possible) on which operating system are you using? LibVA-based hw acceleration is Linux-only.
Title: Re: encoding with intel h264 (HW), any plans for more configuration options ?
Post by: Bart Z Lederman on January 11, 2021, 10:39:01 AM
I'm using 2.7.6.20187 VC++ 64 bits, Windows 7 Professional 64 bits.  I missed the part about Linux only, I do have a Linux laptop but it's much slower.

Is there support for Nvidia at all?  My secondary PC is Windows 7 64 bits and has an Nvidia 8400 card: but I have not been able to get ffmpeg to use CUDA or Nvidia codecs.  I get an error message, but when I look it up I see nothing helpful.

Any suggestions would be welcome.
Title: Re: encoding with intel h264 (HW), any plans for more configuration options ?
Post by: eumagga0x2a on January 12, 2021, 12:26:23 AM
Quote from: Bart Z Lederman on January 11, 2021, 10:39:01 AMIs there support for Nvidia at all?

Yes, there is, a quite good one if you use a nightly. However...

Quote from: Bart Z Lederman on January 11, 2021, 10:39:01 AMMy secondary PC [...] has an Nvidia 8400 card

...this one doesn't have any encoding support (it may provide decoding support for some codecs including H.264 via VDPAU on Linux). Additionally, very recent NVIDIA drivers are needed for NVENC encoder plugins in Avidemux to work, so that old cards which require legacy driver versions most probably won't help. You need a graphics card starting with the Kepler generation (but please make sure you don't get one with a GK108, GM108 or A100 GPU – those don't have an encoder either).

GTX 1050 might be a balanced choice, albeit really interesting features like AV1 support are not available prior to RTX 30xx (it doesn't matter for Avidemux right now, but may be very relevant in near future).
Title: Re: encoding with intel h264 (HW), any plans for more configuration options ?
Post by: Bart Z Lederman on January 13, 2021, 12:39:56 PM
I've been doing more research.

The one system I have that has the right Intel processor is working well, though the codec is a bit limited in what options it has (compared to Nvidia and AMD).  In this case, it's the actual processor that determines if it has hardware video encoding.  Intel has a list of which processors do this.

https://www.intel.com/content/www/us/en/support/products/81503/graphics/graphics-for-previous-generation-intel-processors/intel-hd-graphics-for-previous-generation-intel-processors.html

Be advised that this web page doesn't work with all browsers, but if it works it lets you search on "Intel Quick Sync Video" (and other qualifiers).

Nvidia also has a web page that lists the base cards that support video encoding:

https://developer.nvidia.com/video-encode-and-decode-gpu-support-matrix-new#Encoder

I'm using this to look for cards that should work in my system.  However, from what I've seen so far, I could buy an entire refurbished PC with Intel core i5 or i7 processor for less than what many Nvidia cards cost!  The only problem is that I'd really like to remain on Windows 7 rather than 10.  (I'm also researching for a friend, he has a tower PC so there are more cards that will work for him, but he really had problems working with Windows 10 on his previous laptops and slates.)

AMD is a write-off.  They don't have any usable information on their web site.  I got a reply from them that says that they just supply the chip sets to other manufacturers, if you want to know if a card does hardware encoding you have to find out who makes the card and ask them. But they don't even say which chip sets actually support hardware encoding.  It's very unfortunate, because I used AMD some time ago on my Macintosh systems, and they have a good reputation, and the AMD codec seems to have as many options as Nvidia: but finding out what card does what is going to be very difficult.

So now it comes down to this: which vendor's hardware encoding is going to get the best support from Avidemux (and other programs).  Handbrake does all three, but it's really not a video editing program.  So if Avidemux has plans to support Nvidia (or Intel or AMD) then that would be my first choice for a graphics card.

As for the driver, that doesn't appear to be as much of a problem.  All three offer 'legacy' drivers.  For Intel, it's built into the processor, so my relatively old PC handles the Intel video codec (h264_qsv) with no problems at all.  The other vendors say they have updated drivers and graphics software for old boards, so it appears that it all depends on the boards / chip sets and the codec.  If h264_amf or h264_nvec works now, it should work on any of the capable boards.  (Of course, someone would have to try it to see if what the vendors say is true ;-)

I hope this helps with figuring out what sort of hardware support is feasible.
Title: Re: encoding with intel h264 (HW), any plans for more configuration options ?
Post by: Bart Z Lederman on January 13, 2021, 12:52:47 PM
I spoke just a little too soon.

I've received a second answer from AMD.

https://www.amd.com/en/products/specifications/graphics

is a selector for their cards.  Way off to the right you can select for various video formats decoding and encoding.  This makes it relatively easy to find cards that will work (I think).

So the question still remains, what hardware will be supported by the hardware?

Thanks for taking the time to look through all of this.
Title: Re: encoding with intel h264 (HW), any plans for more configuration options ?
Post by: eumagga0x2a on January 13, 2021, 02:19:33 PM
Quote from: Bart Z Lederman on January 13, 2021, 12:52:47 PMSo the question still remains, what hardware will be supported by the hardware?

I'm unsure you really meant "hardware" and not "software". Regarding HW accelerated video encoding on Windows with Avidemux right now, I think that I've already answered the question in full: NVIDIA only and only with very recent drivers. Speculating about the future is futile.
Title: Re: encoding with intel h264 (HW), any plans for more configuration options ?
Post by: Bart Z Lederman on January 14, 2021, 04:00:56 PM
Yes, I got that mixed up.  Your interpretation was correct.

The more I look at this, the more arguments that can be made in favor of Nvidia being the hardware to support, at least as a first choice.  One might argue that more people will have Intel as it's built into the processor; but looking at what filters and codecs support Nvidia vs. QSV, Nvidia wins.  There are CUDA aware versions of Yadif and other filters, but not for QSV or AMD.  There are fewer encoding options that can be used for the QSV hardware than for Nvidia, if ffmpeg is anything to go by.

I found a refurbished Nvidia card on Amazon at a less-than-exorbitant price.  It's on the Nvidia supported list, so I took a chance and ordered one.  Since I chose free shipping it will be a while before I get it; at least a week.  I will report back when I have results.
Title: Re: encoding with intel h264 (HW), any plans for more configuration options ?
Post by: eumagga0x2a on January 14, 2021, 04:28:23 PM
Quote from: Bart Z Lederman on January 14, 2021, 04:00:56 PMThere are fewer encoding options that can be used for the QSV hardware than for Nvidia, if ffmpeg is anything to go by.

Avidemux is just a shell around FFmpeg with regard to HW accelerated encoding via NVENC. I don't think that it will be any different for QSV if QSV turns out to be viable.
Title: Re: encoding with intel h264 (HW), any plans for more configuration options ?
Post by: Bart Z Lederman on January 15, 2021, 11:53:44 AM
Quote from: eumagga0x2a on January 14, 2021, 04:28:23 PM
Quote from: Bart Z Lederman on January 14, 2021, 04:00:56 PMThere are fewer encoding options that can be used for the QSV hardware than for Nvidia, if ffmpeg is anything to go by.

Avidemux is just a shell around FFmpeg with regard to HW accelerated encoding via NVENC. I don't think that it will be any different for QSV if QSV turns out to be viable.

I was entering a reply and must have accidentally pressed a function key or something.  I will try again.

Most of the commands that need to be passed to h264_qsv are the same as for libx264.  There aren't as many options, but I think the average user isn't going to use many of the options in libx264.  The work to call h264_qsv can probably be shared with h264_nvidia and h264_amf.

Information about h264_qsv is scattered about, but I've collected enough to switch over what I've been doing directly in ffmpeg to use QSV, and will be quite happy to share all of it.

For as simple example, I have a TV recording box that records off-the-air broadcast tv and puts it into MTS format, which can't be played by all devices.  If the broadcast signal is less than perfect then there are defects in the recording that need to be fixed.  So I run them through ffmpeg which will fix most of the problems, and then I can view them.  I might also run them through Avidmux to edit them.

The basic command to do this is:

ffmpeg -i "input.mts" -c:a aac -b:a 128k -ar 48000  ^
-preset veryfast -profile:v high -level 4.1  ^
-vf "yadif=0:0:0" -crf 20 "output.mp4"

To use QSV acceleration:

ffmpeg -i "input.mts"  -c:a aac -b:a 128k -ar 44100 ^
-c:v h264_qsv -preset veryslow -profile:v high -bsf:v h264_metadata=level=41 ^
-vf "yadif=0:0:0" -q:v 20 "output.mp4"

The only changes are -q:v instead of -crf and removing the decimal point for the level.

I've also found that in most cases I can leave the choice of quality and level to the codec to decide: it's only when I want to watch the video on a Blu-Ray player using a drive in the USB port that I have to limit the level to 4.1.

I will write up a complete list of everything I've found so far about switching to QSV and post it, hopefully later today (my time) so that others won't have to search the internet to get the bits and pieces.

Supporting h264_nvec and h264_amf look like they will be a little easier because they support more options than qsv.  But, as I said, I've found you can leave most choices on what to do to the codec and a lot of options aren't needed.
Title: Re: encoding with intel h264 (HW), any plans for more configuration options ?
Post by: Bart Z Lederman on January 15, 2021, 02:11:59 PM
There are a number of options that differ between the various encoders.  Some I would classify as being rather "esoteric".  Most users probably won't ever use them (if my experience is anything to go by).

These are the ones I think are significant.

-preset

libx264 goes from ultrafast to placebo
h264_qsv goes from veryfast to veryslow
h264_nvenc goes from fast to slow plus a variety of other settings like hp, lossless,
          low latency, etc.

-profile

libx264, QSV and NVENC have baseline main high
h264_nvec also has high444
h264_amf has main high constrained_baseline constrained_high
libx264 can be modified with --tune . I don't see this in the other codecs.

-crf

I only see this in libx264.  The other codecs apparently need -quality or -q:v

In my tests so far, for the most part letting h264_qsv choose the quality
and bitrate has been working well. 

As I mentioned before, letting it chose the profile and level based on the size
and nature of the video also works well unless you need to constrain the limit
to run on a particular device.

These are the qualifiers listed for the encoders.  I've run into some 'higher level'
qualifiers that seem to be handled differently between codecs. libx264 seems to
hide it's qualifiers in a separate document.  Common qualifiers like -b -minrate
and -maxrate appear to work the same in libx264 and h264_qsv (though frankly,
I don't think they work very well in either library).

Filters like yadif, crop, -ss, scale, etc. are independent of the encoder, though
there are some filters like yadif that also come in a hardware-aware version.

Perhaps the best way to proceed is for you folks to tell me what qualifiers are
important and I'll test them for QSV.  In a week or so I'll also be able to test
Nvidia (I hope).
Title: Re: encoding with intel h264 (HW), any plans for more configuration options ?
Post by: Bart Z Lederman on January 17, 2021, 03:48:59 PM
I used ffmpeg -help to extract the information for the libx264, h264_amd (AMD), h264_nvec (Nvidia), and H264_qsv (Intel) encoders.  I've combined the information into a spreadsheet (csv and LibreOffice ods) file.  I believe this makes it easier to compare the various encoder options.

What would be the best way to make this available to everyone?
Title: Re: encoding with intel h264 (HW), any plans for more configuration options ?
Post by: Bart Z Lederman on August 13, 2021, 06:13:11 PM
I apologize for not being here for a while, it's a lot longer than I realized. I've been doing a lot with hardware accelerated encoding and filtering, and I've been trying to obtain more information on this subject in other forums (and receiving mostly abuse for my efforts).

I know now quite a bit more on the subject and would like to share it.

First, and possibly most important: if you can only support one architecture it should be Intel Quick Sync (QSV) for several reasons.

First: there are literally millions of computers in use today that have QSV, though many people don't know it.  It's built in to the processor, you don't have to buy anything extra.  This also includes "low power" processors built into laptops (I found out I have one such system).  To use Nvidia / CUDA or AMD you need to have add a graphics card; not all of them support hardware acceleration, and you can't upgrade all systems because there might not be enough power, or enough slots. And if you have a laptop you may not be able to upgrade at all.

Next, there are many more filter options available for Intel / QSV than for Nvidia / Cuda.  The vpp_qsv filter alone can do a lot of processing that would take multiple filters otherwise, and it will do things no Cuda filter can do.  In addition, for what the accelerated filters can't do you have to use the "standard" filters. Mixing Intel and "standard" filters requires no effort at all, you just use whatever filters you want.  Mixing "standard" and Cuda filters is very far from obvious, and you have to specify uploading every frame to the hardware, use the Cuda filter, download every frame back, and then use a "standard" filter or filters.  Once you know the secret magic formula to do this it will work, but there is extra overhead for uploading and downloading frames. I've also found the information from Nvidia to be very poor, often misleading, and sometimes wrong.  I've had to search and experiment to get things to work at all, and the Nvidia "support" forum was no help.

I did get a little bit of support form Intel (after a long discussion), and I have relatively complete information on the vpp_qsv filter.

Tests I've done show that doing decoding and encoding makes the process go very much faster than the default CPU processing.  I've seen speed-ups as great as 30 times faster, and speed-ups of 5 to 20 times are common. Plus, with the work being done by the GPU the CPU is freed up to do other work.  Using the hardware accelerated filter doesn't add a lot of speed, but it does reduce the CPU load.

Switching over to QSV is now quite simple know that I know how it's done, and I will be happy to share everything I know with everyone.  Just let me know where you want to see it.

Right now I'm using Avidemux mostly as a way to find the cut points, size of cropping, etc., so I can set up ffmpeg commands to do the actual work.  The speed advantage really is amazing.  I want to do everything I can here to help other people speed up their video processing after spending a month with people in other forums saying I'm unreasonable for asking where to find documentation on QSV and Cuda.
Title: Re: encoding with intel h264 (HW), any plans for more configuration options ?
Post by: eumagga0x2a on August 13, 2021, 06:55:10 PM
On Linux, we use QSV accelerated encoding for H.264 and HEVC via FFmpeg + libva (and also directly, but for H.264 and with very limited configuration only). Zero hassle. libva offers also a few filters, but currently only resizer and deinterlacer are implemented (I think it is all my hardware is able to do).

For Windows, it would be necessary to find a way to cross-compile shared FFmpeg libs with QSV support.

Due to architectural limitations, we always have to download and re-upload decoded pictures to the GPU which severely limits performance compared to FFmpeg which is able to pass hardware surfaces from decoder through filters to hw accelerated encoder seamlessly.
Title: Re: encoding with intel h264 (HW), any plans for more configuration options ?
Post by: Bart Z Lederman on August 20, 2021, 10:05:47 AM
I'm a little surprised you're finding issues with QSV on Linux with ffmpeg.  I will have to do some more testing there.

There are at least two people who are building ffmpeg with QSV (and Nvidia and AMD) support for the Windows version which is available from the ffmpeg.org web site.  I've never had to build my own version to get QSV support.  Again, I will have to do more testing on Linux, but the version I installed through the normal Linux install procedure pulled a version of ffmpeg with QSV already built in from the repository.  My quick tests so far indicate that the decoder and encoder work the same as on Windows, with the same command line.

My understanding from previous messages in this forum is that Avidemux passes commands to ffmpeg, which does the work; so I would think that getting it to take advantage of QSV would not take much effort.  The biggest bonus is in having the codec decode and encode the video, and I have found that to be quite easy. It involves some fixed text on the command line, and restricting some of the options: for example, the QSV encoder does not have an "ultrafast" preset, but does have "superfast" through "very slow". (And changing -crf to -q:v .)

Uploading and downloading to the GPU has never been needed for any of my QSV and Nvidia tests for hardware accelerated decoding or encoding.  This has only been needed when using an enhanced filter, and only for Nvidia: and using enhanced filters is a secondary benefit that can be deferred, or not done at all. 
Title: Re: encoding with intel h264 (HW), any plans for more configuration options ?
Post by: eumagga0x2a on August 20, 2021, 12:45:11 PM
Quote from: Bart Z Lederman on August 20, 2021, 10:05:47 AMI'm a little surprised you're finding issues with QSV on Linux with ffmpeg.

The issues are with us, not with ffmpeg (at least not the issues). For optimal performance when no filtering by other means than VA-API is involved, hardware surfaces holding decoded pictures need to be passed between hw decoder and hw encoder. We cannot do this at the current stage.

On Windows, the only currently available in Avidemux hw acceleration interface for video decoding is DXVA2, well aged, which can't exchange hw surfaces even between decoder and video display.

Quote from: Bart Z Lederman on August 20, 2021, 10:05:47 AMMy understanding from previous messages in this forum is that Avidemux passes commands to ffmpeg

No, this is wrong. We don't use ffmpeg command-line utility, we use some of the libraries, patched and configured to our needs.
Title: Re: encoding with intel h264 (HW), any plans for more configuration options ?
Post by: spiceagent11 on November 23, 2021, 05:45:10 PM
Perhaps I'm missing something "obvious", but could someone point me to instructions on how to do this?  Or perhaps elaborate on the recent news about hardware acceleration enhancements to Avidemux?
https://vidmateapp.win (https://vidmateapp.win) | Bluestacks 3 (https://bluestacks.red/bluestacks-3-download/) | moviesrush (https://vidmateapp.win/moviesrush/)
Title: Re: encoding with intel h264 (HW), any plans for more configuration options ?
Post by: eumagga0x2a on November 24, 2021, 10:19:52 PM
Quote from: spiceagent11 on November 23, 2021, 05:45:10 PMPerhaps I'm missing something "obvious", but could someone point me to instructions on how to do this?

For now, in order to be able to use hardware H.264 and HEVC encoders on Intel, the instructions are as simple as installing Linux and using a Linux build of Avidemux (if it needs to be an official appImage, then please the one from the "appImage4Buster" directory of the nightly server).

There hasn't been any progress on Windows yet, i.e. on Windows, Avidemux offers hardware-accelerated encoders only for users of recent NVIDIA graphics cards.
Title: Re: encoding with intel h264 (HW), any plans for more configuration options ?
Post by: butterw on July 06, 2022, 08:42:24 PM
12th gen Intel processors (and high-end 11th gen) feature igpus (ex: uhd 730) with a very good hardware encoder for h265 + also an av1 hw-decoder.

Hopefully Avidemux can make use of qsv at some point on Windows.

Hardware encoders are likely the future for codecs more complex than h264, at least for most users.
Title: Re: encoding with intel h264 (HW), any plans for more configuration options ?
Post by: butterw on May 31, 2023, 10:49:18 AM
Any update on the state of qsv support in Avidemux ?

I have Intel i3-12100.

I'm currently using x265-slow CRF=25 (on Win10) to encode, but will looking into h265 hardware encoding in the future.

The standalone encoder tools tend to use qsvenc by rigaya rather than ffmpeg from what I've seen. Possibly because it allows the more advanced options to achieve best quality or maybe because it is easier to configure, I don't know.






Title: Re: encoding with intel h264 (HW), any plans for more configuration options ?
Post by: eumagga0x2a on June 03, 2023, 04:18:01 PM
Unfortunately no progress, not even started. Didn't have time and physical resources for coding at all for quite a long period of time while problems in Avidemux kept piling up due to changes in FFmpeg and in Qt.