Reference documentation blog.jam00.com/article/inf…

Fmpeg is powerful, but we had to learn how to install it first (on Windows).

Download from ffmpeg.org/download.ht… , the corresponding Windows version

The. Exe file is displayed in the bin directory of the decompressed file. Add the bin directory to the environment variable path, ending with a semicolon. To verify the installation, run CMD and enter ffmpeg-version on the console. The command output is as follows:

Installation successful!

Please install FFMpeg before using the project

Use composer to quickly install > composer require php-ffmpeg/php-ffmpeg

When using ffmpeg, set the absolute path of the ffProbe execution file. I defined some video and audio files for the test

$path = [ 'ffmpeg.binaries' => 'D:\ffmpeg\bin\ffmpeg.exe', 'ffprobe.binaries' => 'D:\ffmpeg\bin\ffprobe.exe', ]; $v1 = './static/common/mv.mp4'; $a1 = './static/common/a1.mp3'; $ffmpeg = FFMpeg::create($path); $video = $ffmpeg->open($v1); $frame = $video->frame(Coordinate\TimeCode::fromSeconds(2)); How many seconds / / extracted $frame - > save ('. / uploads/uid2 / image/image. JPG "); $video = $ffmpeg->open($v1); $audio_format = new Audio\Mp3(); $video->save($audio_format, './uploads/uid2/audio/audio.mp3'); Libfdk_aac $video = $ffmpeg->open($v1); $watermarkPath = './static/common/water.jpg'; $absolute = ['x' => 50,'y' => 100]; $relative = [ 'position' => 'relative', 'bottom' => 50, 'right' => 50]; $video->filters()->watermark($watermarkPath, $relative); $video->save(new Video\X264('aac'), './uploads/uid2/video/1080_new.mp4'); / / note: // Relative (relative)/absolute (absolute, default) // Relative (relative, default) $video = $ffmpeg->open($v1); $video = $ffmpeg->open($v1); $format = new Video\X264('aac'); $format->setKiloBitrate(1000)->setAudioChannels(2)->setAudioKiloBitrate(256); $format->on('progress', function ($video, $format, $percentage) {echo "$percentage % progress "; }); $video->save($format, './uploads/uid2/video/1080_new.avi'); $ffprobe = ffprobe ::create($path); $videoInfo = $ffprobe->format($v1); $duration = $ffprobe->format($v1)->get('duration',100); $duration = $ffprobe->format($v1)->get('duration',100); echo "<pre>"; print_r($videoInfo); echo "</pre>"; Echo 'duration: '.$duration; $audio = $ffmpeg->open($a1); $format = new Audio\Flac(); $format->on('progress', function ($audio, $format, $percentage) {echo "$percentage % progress "; }); $format->setAudioChannels(2)->setAudioKiloBitrate(256); $audio->save($format, './uploads/uid2/audio/1080_new.flac'); $audio = $ffmpeg->open($a1); $waveform = $audio->waveform(640, 120, array('#00FF00')); $waveform->save('./uploads/uid2/audio/image.png'); // Must be saved in PNG formatCopy the code