protonemedia / laravel-ffmpeg

This package provides an integration with FFmpeg for Laravel. Laravel's Filesystem handles the storage of the files.
https://protone.media/en/blog/how-to-use-ffmpeg-in-your-laravel-projects
MIT License
1.62k stars 193 forks source link

Why it's not possible to convert .mp4 with "X265"? #507

Open Diogo2550 opened 10 months ago

Diogo2550 commented 10 months ago

I added the value "libx265" to the return array of the "X264" class and it was possible to convert to X265. Is there any reason why this functionality is not present?

imrantune commented 4 months ago

@Diogo2550 , you might want to give this a try:

<?php

namespace YOURNAMESPACE;

use FFMpeg\Format\Video\X264;

/**
 * A custom class for encoding videos with the H.265 (x265) codec, based on the X264 class.
 */
class X265 extends X264
{
    /**
     * Constructor to set audio and video codecs.
     *
     * @param string $audioCodec The audio codec to use. Defaults to 'aac'.
     * @param string $videoCodec The video codec to use. Defaults to 'libx265' for H.265 encoding.
     */
    public function __construct($audioCodec = 'aac', $videoCodec = 'libx265')
    {
        parent::__construct($audioCodec, $videoCodec);
    }

    /**
     * Get the available video codecs, in this case, only 'libx265'.
     *
     * @return array An array containing the available video codecs.
     */
    public function getAvailableVideoCodecs()
    {
        return array('libx265');
    }
}

Now, to use this custom class, you can instantiate it with the desired codecs like so: new X265('aac','libx265');