ffmpeg-php、PHPでビデオとサウンドを操作する

これまでのところ、私はPHPを使った画像操作に手を出していました。 この言語でビデオを使用することは私には実行不可能に思えました。 それでも...

 
ffmpeg-php 追加できるPHP拡張機能です ビデオとサウンドの操作と制御専用のAPI。 この高レベルAPIは、ファイルから情報を抽出するためのシンプルで理解しやすい関数へのアクセスを提供します。

これらの方法により、画像などの特定の「フレーム」を復元できます。 これらは、GDライブラリを使用して操作できます。
ffmpeg-phpは完璧です ビデオからサムネイルを作成する、またはメタデータ(期間、ビットレートなど)の抽出を自動化します。
作成することも可能です アニメーションGIF いくつかのフレームを抽出することによって。

$ ffmpeg = 'encoderffmpeg'; //ffmpeg.exeファイルへの相対パスを入れます$ second = 15; //スクリーンショットを取得する時間を指定します(簡単にランダムに生成できます)$ image = 'thumbnails / sample.jpg'; //出力ファイルを定義します//最後にコマンドをアセンブルして実行します$ command = "$ ffmpeg -itsoffset- $ second -i $ video -vcodec mjpeg -vframes 1 -an -f rawvideo -s150×84 $ image"; exec($コマンド);

メソッドの例を次に示します。

getDuration()。 「getFrameCount:」。 $ ffmpegInstance-> getFrameCount()。 「getFrameRate:」。 $ ffmpegInstance-> getFrameRate()。 「getFilename:」。 $ ffmpegInstance-> getFilename()。 「getComment:」。 $ ffmpegInstance-> getComment()。 「getTitle:」。 $ ffmpegInstance-> getTitle()。 「getAuthor:」。 $ ffmpegInstance-> getAuthor()。 「getCopyright:」。 $ ffmpegInstance-> getCopyright()。 「getArtist:」。 $ ffmpegInstance-> getArtist()。 「getGenre:」。 $ ffmpegInstance-> getGenre()。 「getTrackNumber:」。 $ ffmpegInstance-> getTrackNumber()。 「getYear:」。 $ ffmpegInstance-> getYear()。 「getFrameHeight:」。 $ ffmpegInstance-> getFrameHeight()。 「getFrameWidth:」。 $ ffmpegInstance-> getFrameWidth()。 「getPixelFormat:」。 $ ffmpegInstance-> getPixelFormat()。 「getBitRate:」。 $ ffmpegInstance-> getBitRate()。 「getVideoBitRate:」。 $ ffmpegInstance-> getVideoBitRate()。 「getAudioBitRate:」。 $ ffmpegInstance-> getAudioBitRate()。 「getAudioSampleRate:」。 $ ffmpegInstance-> getAudioSampleRate()。 「getVideoCodec:」。 $ ffmpegInstance-> getVideoCodec()。 「getAudioCodec:」。 $ ffmpegInstance-> getAudioCodec()。 「getAudioChannels:」。 $ ffmpegInstance-> getAudioChannels()。 「hasAudio:」。 $ ffmpegInstance-> hasAudio(); ?> 

ffmpeg-phpはサポートします 多数のフォーマット (mpeg、avi、wmv、mov、mp3、wma、…)。

例として、Vimeo.comはffmpeg-phpを使用してサムネイルを作成します。 したがって、このAPIは堅実であると考えることができます。

ffmpeg-phpをダウンロード

また、読み