Ffmpeg converts video formats and screenshots-PHP source code

Source: Internet
Author: User
Ec (2); after the Ffmpeg file is downloaded, configure the environment variables. I downloaded the environment variables on the D Drive and Directory D: oracleproduct10.2.0client _ 1bin; D: oracleproduct10.2.0db _ 1bin; % SystemRoot % system32; % SystemRoot % System32Wbem; C: ProgramFilesJavajdk1. script ec (2); script

Ffmpeg
Get File

After the download, configure the environment variables.

I downloaded the ddisk and directory.

D: oracleproduct10.2.0client _ 1bin; D: oracleproduct10.2.0db _ 1bin; % SystemRoot % system32; % SystemRoot % System32Wbem; C: Program FilesJavajdk1.7.0bin; C: Program FilesATI javasiesati. ACECore-Static; C: Program FilesCommon FilesThunder NetworkKanKanCodecs; D: Program FilesTortoiseSVNbin; C: Program FilesMicrosoft SQL Server90Toolsbinn; D: ffmpeg

There are a lot of configuration items. The last one is my ffmpeg.

After the configuration, test it in Dos.

Open the Dos interface and enter ffmpeg.

If the command succeeds, many commands will be displayed.

If it fails, it indicates that you have not entered any internal commands.

If it fails, check whether your environment variable is configured OK.

Then, test whether the conversion is successful under Dos.

First, put a video in a directory.

I put the Demo. avi Video in drive D and directory, and I will convert it to Flv

Enter the command: ffmpeg-I D:/Demo. avi D:/Demo... flv

-I is followed by the file address to be converted, followed by the path to which you want to convert the file and the corresponding file name and format.

Enter the command and press enter to check whether the converted file exists in the corresponding directory.

If the command fails, check whether the command is correct.

Execute the conversion command in PHP

// Convert to Flv
Function makeFlv ($ video_file, $ flv_file)
{
// Determine whether the specified file is normal
If (! Is_file ($ video_file )){
Return false;
}

Global $ flv_msg;
$ Flv_cmd = "ffmpeg-I". $ video_file. "". $ flv_file;
Exec ($ flv_cmd, $ flv_msg );
}

// Create a flv video image
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 );
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.