Xabe.FFmpeg icon indicating copy to clipboard operation
Xabe.FFmpeg copied to clipboard

Support for libx265?

Open OFark opened this issue 4 years ago • 5 comments

I can see you're still updating this project. Can I ask if the libx265, nvenc_hevc, hevc_qsv, etc codecs are going to be supported?

OFark avatar Jul 31 '20 14:07 OFark

Hi @OFark I think you could achive that by using SetCodec method, ConvertWithHardware.

tomaszzmuda avatar Aug 05 '20 19:08 tomaszzmuda

Right now I can do hardware h264 encoding like this:

videoStream.SetCodec(VideoCodec.h264_nvenc);
IConversion conversion = FFmpeg.Conversions.New();
conversion.AddStream(videoStream)
conversion.UseHardwareAcceleration(HardwareAccelerator.cuvid, VideoCodec.h264_cuvid, VideoCodec.h264_nvenc);

This should have done the same for h265:

videoStream.SetCodec(VideoCodec.h265_nvenc);
IConversion conversion = FFmpeg.Conversions.New();
conversion.AddStream(videoStream)
conversion.UseHardwareAcceleration(HardwareAccelerator.cuvid, VideoCodec.hevc_cuvid, VideoCodec.hevc_nvenc);

The following are missing from VideoCodec: decoders: hevc_qsv, hevc_cuvid encoders: hevc_nvenc hevc_qsv

I believe they have to be added to this file: https://github.com/tomaszzmuda/Xabe.FFmpeg/blob/master/src/Xabe.FFmpeg/Streams/VideoStream/VideoCodec.cs

esmorun avatar Feb 07 '21 21:02 esmorun

I can indeed confirm that adding the following lines to VideoCodec.cs and compiling my own NuGet-package allowed me to successfully do a hardware hevc encode:

        ///<summary>
        ///      hevc_cuvid
        ///</summary>
        hevc_cuvid,

        ///<summary>
        ///      hevc_nvenc
        ///</summary>
        hevc_nvenc,

        ///<summary>
        ///      hevc_qsv
        ///</summary>
        hevc_qsv

I tried to do a Commit 31b6b752 but I'm not sure if I'm doing it correctly :P

esmorun avatar Feb 07 '21 23:02 esmorun

Audio encoder libfdk_aac is also missing, it is different from the standard aac encoder.

And I think libtheora is different from theora and should be added as well :)

esmorun avatar Feb 07 '21 23:02 esmorun

Hey, Feel free to create Pull Request with that. You have a possibility to use overloaded method UseHardwareAcceleration(string hardwareAccelerator, string decoder, string encoder, int device = 0). To commit anything to this repository you have to fork it first, push changes to your branch on your fork and next create Pull Request with that changes.

tomaszzmuda avatar Feb 08 '21 21:02 tomaszzmuda