How to call ffmpeg in php

(*-*)浩
Release: 2023-02-24 13:00:01
Original
4286 people have browsed it

上传好视频后,PHP后台自动选取视频流中的某一帧作为视频封面。

How to call ffmpeg in php

FFmpeg是一套可以用来记录、转换数字音频、视频,并能将其转化为流的开源计算机程序,功能很强大。(推荐学习:PHP编程从入门到精通

下载FFmpeg(for Windows):http://ffmpeg.zeranoe.com/builds/  (其他版本可上官网上搜:http://ffmpeg.org/),我下的是shared版的,static版本的下载不下来,下载时一直中断。因此不知道两个版本具体差别。

解压,将bin文件夹下的所有文件包括.exe和.dll都拷贝到C:\Windows\System32中。

在php文件中调用system()或exec()方法来实现帧图像的提取。(注意:在php中路径字符串中‘\’需转义:“\\”)

测试用例:

$name = md5(date('YmdHis')).".png";  
$from = "E:\\UPLOAD\\cw\\20150626\\558d0d11ae285.mp4";  
$to = "E:\\UPLOAD\\cover_images\\";  
$str = "ffmpeg -i ".$from." -y -f mjpeg -ss 3 -t 1 -s 740x500 ".$to.$name;  
system($str);
Copy after login

$name = md5(date('YmdHis')).".png";  
$from = "E:\\UPLOAD\\cw\\20150626\\558d0d11ae285.mp4";  
$to = "E:\\UPLOAD\\cover_images\\";  
$str = "ffmpeg -i ".$from." -y -f mjpeg -ss 3 -t 1 -s 740x500 ".$to.$name;  
exec($str);
Copy after login

The above is the detailed content of How to call ffmpeg in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template