FFmpeg using--php to convert video, capture video, and JW player player controls

Source: Internet
Author: User

Reprint: http://blog.csdn.net/zm2714/article/details/7916440

A project for a friend involves uploading a video, converting a video, and automatically capturing one of the uploaded video content as a thumbnail image. This article records some of the knowledge and lessons learned in the process of completing this project.

Upload the video this piece of time not to say, in the project about uploading this piece of the issue of the progress bar, always feel not perfect. Although this piece of content has been resolved, uploading large files is still not enough in some respects to meet the requirements of 100%. Have time to tidy up this piece. In this article, because it is to organize the content of the project, so about the upload aspect of the area.

Automatic conversion of uploaded videos

In this project, the first I was to judge the progress of this piece on the server side, the ideal state is the upload display upload progress, upload success, the progress bar content changed to: Is converting video, please later .... But sometimes the progress bar does not reach 100% when it snaps to a value until the video is converted successfully. So, I will judge the progress of this piece into the local JS processing. In summary, after the video upload is successful, the video is converted. Convert Video Section Code

$id =checknum (getform ("id"), 0,-1);
$file =getform ("file");
$ext =getform ("ext");
if ($id >0) {
$path =$_moqian_video_path. $id;
$path =$_moqian_video_path.$_session[' MM ' [' Sid '];
$path =rtnrealpath ($path);//Returns an absolute path, such as D:/wwwroot/test/upload/...../
if ($ext! = ' flv ') {
EXEC ('.. \cmd\ffmpeg.exe-i '. $path. $file. '. $ext. '-ab 56-ar 22050-b 500-r 15-s 650*480 '. $path. $file. FLV ', $out, $status);
Unlink ($path. $file. '. '. $ext);//Delete the original file
if ($status ==0) {
echo "Success";
echo "0";//Failure
echo ' success ';

Commands for converting video

EXEC ('.. \cmd\ffmpeg.exe-i '. $path. $file. '. $ext. '-ab 56-ar 22050-b 500-r 15-s 650*480 '. $path. $file. FLV ', $out, $status);
$status is the result state of the execution. A value of 0 indicates that the conversion succeeded or the conversion failed.

Ffmpeg.exe Convert Video Parameters command please Baidu. Here are a few questions to say

1, there are many versions of Ffmpeg.exe online, after testing, many can not be used. I am here to provide download of the Ffmpeg.exe and related files I am using.
2, ffmpeg conversion Video parameters Considerations

After many tests found
$a = '. /aaa/ffmpeg.exe ';//This way is wrong! cannot use "/"
$a = ' D:\wwwroot\dingji\flv\ffmpeg.exe ';//This way is wrong! cannot use "absolute physical path"
$a = ' \api\ffmpeg.exe ';//error cannot start with \
The call to the Ffmpeg.exe file cannot use the above path, the correct usage is as follows:
$a = ' aaa\ffmpeg.exe ';//success (subordinate directory of current directory)
$a = '. \api\ffmpeg.exe ';//success (parent directory or other directory of the current directory)
$b = ' D:\wwwroot\dingji\flv\1.flv ';//absolute path
$cmd = $a. '-I.. /api/a.avi -ab 56-ar 22050-b 500-r 15-s /1f.flv';
EXEC ($cmd);

The blue section above can be either an absolute path or a relative path. Test "forward slash" and "backslash" on Windows.

Not to be continued ...

FFmpeg using--php to convert video, capture video, and JW player player controls

Related Article

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.