FFmpeg가 성공적으로 설치되었지만 MP4 비디오만 재생합니까?

FFmpeg가 성공적으로 설치되었지만 MP4 비디오만 재생합니까?

CentOs 7 Linux(plesk)에 FFmpeg(mplayer, mencoder, flvtool2, libogg, libvorbis, lame, ffmpeg-devel)를 설치했습니다. 설치 중에 문제가 없습니다.

절대 경로: /usr/bin/에는 ffmpeg, ffprobe, ffplay 및 ffserver 바이너리와 기타 디렉터리 및 파일이 포함되어 있습니다. 그러나 웹사이트에서는 YouTube 또는 MP4 형식의 비디오만 재생합니다.

AVI, MOV 및 WEBm 형식의 비디오를 재생할 수 없는 이유는 무엇입니까?

[root@server ~]# ffplay
ffplay version 3.4.7 Copyright (c) 2003-2019 the FFmpeg developers
  built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-39)
  configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --extra-ldflags='-Wl,-z,relro ' --extra-cflags=' ' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libcdio --enable-libdrm --enable-indev=jack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --disable-encoder=libopus --enable-libpulse --enable-librsvg --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzvbi --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-libmfx --enable-runtime-cpudetect
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100

class Video extends Upload
{
    const SUPPORTED_TYPES = [
        'mov' => 'video/mov',
        'avi' => 'video/avi',
        'flv' => 'video/flv',
        'mp4' => 'video/mp4',
        'mpg' => 'video/mpg',
        'mpeg' => 'video/mpeg',
        'wmv' => 'video/wmv',
        'ogg' => 'video/ogg',
        'ogv' => 'video/ogv',
        'webm' => 'video/webm',
        'mkv' => 'video/mkv'
    ];

    const MP4_TYPE = 'mp4';

    /** @var File */
    private $oFile;

    /** @var string */
    private $sType;

    /** @var string */
    private $sFfmpegPath;

    /** @var array */
    private $aFile;

    /**
     * @param array $aFile Example: $_FILES['video']
     *
     * @throws MissingProgramException If FFmpeg is not installed.
     */
    public function __construct($aFile)
    {
        $this->oFile = new File;
        $this->sFfmpegPath = Config::getInstance()->values['video']['handle.ffmpeg_path'];

        if (!file_exists($this->sFfmpegPath)) {
            $sMsg = t('FFmpeg is not installed on the server or the path cannot be found. Please install and configure the path in "~/YOUR-PROTECTED-FOLDER/app/configs/config.ini" or contact the administrator of the site/server or web hosting by saying the problem.');
            throw new MissingProgramException($sMsg);
        }

        $this->aFile = $aFile;
        $this->sType = $this->aFile['type'];

        /** Attributes from "Upload" abstract class **/
        $this->sMaxSize = Config::getInstance()->values['video']['upload.max_size'];
        $this->iFileSize = (int)$this->aFile['size'];
    }

    /**
     * @return bool
     *
     * @throws TooLargeException If the video file is not found.
     */
    public function validate()
    {
        if (!is_uploaded_file($this->aFile['tmp_name'])) {
            if (!isDebug()) {
                return false;
            } else {
                throw new TooLargeException('Video file could not be uploaded. Possibly too large.');
            }
        } else {
            return in_array($this->sType, self::SUPPORTED_TYPES, true);
        }
    }

    /**
     * @param string $sFile
     *
     * @return bool
     */
    public function save($sFile)
    {
        return move_uploaded_file($this->aFile['tmp_name'], $sFile);
    }

    /**
     * @return string
     */
    public function getFileName()
    {
        return $this->aFile['name'];
    }

    /**
     * Convert video file and the extension video type.
     *
     * @param string $sFile New renamed file name.
     *
     * @return string The new name that you entered in the parameter of this method.
     */
    public function rename($sFile)
    {
        $sParams = ''; // By default, we don't use parameter

        $sType = $this->oFile->getFileExt($sFile); // Get the new format
        if ($sType === self::MP4_TYPE) {
            $sParams = '-c copy -copyts';
        }

        $this->executeCommand('-i', "{$this->aFile['tmp_name']} $sParams $sFile");

        return $sFile;
    }

    /**
     * Generate a thumbnail with FFmpeg.
     *
     * @param string $sPicturePath
     * @param int $iSeconds
     * @param int $iWidth
     * @param int $iHeight
     *
     * @return string The thumbnail file that you entered in the parameter of this method.
     */
    public function thumbnail($sPicturePath, $iSeconds, $iWidth, $iHeight)
    {
        $this->executeCommand(
            '-itsoffset',
            "-$iSeconds -i {$this->aFile['tmp_name']} -vcodec mjpeg -vframes 1 -an -f rawvideo -s {$iWidth}x{$iHeight} $sPicturePath"
        );

        return $sPicturePath;
    }

    /**
     * Gets video duration.
     *
     * @return int Seconds.
     */
    public function getDuration()
    {
        $sTime = $this->executeCommand(
            '-i ',
            "{$this->aFile['tmp_name']} 2>&1 | grep -i 'duration' | cut -d ' ' -f 4 | sed s/,//"
        );

        return Various::timeToSec($sTime);
    }

    /**
     * Get Type Video File.
     *
     * @return string The extension of the video without the dot.
     */
    public function getExt()
    {
        return $this->sType;
    }

    /**
     * Execute a FFmpeg command.
     *
     * @param string $sFlag
     * @param string $sArgument
     *
     * @return void
     */
    private function executeCommand($sFlag, $sArgument)
    {
        exec(
            sprintf(
                '%s %s %s',
                $this->sFfmpegPath,
                $sFlag,
                $sArgument
            )
        );
    }

    /**
     * Remove temporary file.
     */
    public function __destruct()
    {
        // If it exists, delete the temporary video file
        $this->oFile->deleteFile($this->aFile['tmp_name']);
    }
}

답변1

ffmpeg -codecs빌드가 구현하는 모든 코덱을 나열해 보세요 .

출력은 다음 형식입니다.

Codecs:
 D..... = Decoding supported
 .E.... = Encoding supported
 ..V... = Video codec
 ..A... = Audio codec
 ..S... = Subtitle codec
 ...I.. = Intra frame-only codec
 ....L. = Lossy compression
 .....S = Lossless compression
 -------
 D.VI.S 012v                 Uncompressed 4:2:2 10-bit
 D.V.L. 4xm                  4X Movie
 D.VI.S 8bps                 QuickTime 8BPS video
 .EVIL. a64_multi            Multicolor charset for Commodore 64 (encoders: a64multi )

일부가 누락된 경우 잘못된 컴파일 프로세스 때문일 수 있습니다.

관련 정보