search
Homephp教程PHP源码Ffmpeg实现视频格式的转换以及截图

<script>ec(2);</script>

Ffmpeg
得到文件

下载好之后首先就是配置一下环境变量

我下载的放在了D盘跟目录

D:oracleproduct10.2.0client_1bin;D:oracleproduct10.2.0db_1bin;%SystemRoot%system32;%SystemRoot%;%SystemRoot%System32Wbem;C:Program FilesJavajdk1.7.0bin;C:Program FilesATI TechnologiesATI.ACECore-Static;C:Program FilesCommon FilesThunder NetworkKanKanCodecs;D:Program FilesTortoiseSVNbin;C:Program FilesMicrosoft SQL Server90Toolsbinn;D:ffmpeg

配的有点多,最后那个就是我的ffmpeg

配置好之后就先在Dos中测试下

打开Dos界面 输入 ffmpeg

如果成功的话会显示好多的命令

如果失败则显示 你输入的不是内部命令之类的。

如果失败就看看自己的环境变量是否配置OK

OK之后先在Dos下测试是否能成功转换

首先在一个目录放入一个视频

我在D盘跟目录放入了Demo.avi 视频,我将要转换为Flv

输入命令:ffmpeg -i D:/Demo.avi  D:/Demo..flv

-i 后面紧跟的是要转换的文件地址 在后是你要把文件转换到哪里以及相对应的文件名和格式

输入命令之后回车,看看相对应的目录是否出现了你需要的转换后的文件。

如果失败检查命令是否错误。

PHP中执行转换的命令

//转换为Flv
function makeFlv($video_file,$flv_file)
{
//判断给定的文件是否正常
if(!is_file($video_file)){
  return false;
}

global $flv_msg;
    $flv_cmd="ffmpeg -i ".$video_file." ".$flv_file;
    exec($flv_cmd,$flv_msg);
}

//创建flv视频的图片
function makeFlvPic($flv_file,$flv_pic_file)
{
global $flv_msg;

    $flv_pic_cmd="ffmpeg -i ".$flv_file.
       " -y -f image2 ".
       " -ss 1 ".
       " -t 0.001 ".
       " -s 350x240 ".$flv_pic_file;

    exec($flv_pic_cmd,$flv_msg);
}

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.