PHP support FFmpeg, then use the ffmpeg command to process video, open exec privileges ____php

Source: Internet
Author: User

·· Start talking about my development encountered problems, I use the environment is IIS7.5+PHP5.4+MYSQL, the system is windows! to develop a video upload playback function, need to get video information (wide and high size time, etc. ~), or cut video frames to do cover.

·· Then I want to use ffmpeg processing, I used the thinkphp framework, engaged in a half-day integration of the system is not installed FFmpeg, the original also to install, and found a large circle on the Internet. Try it all over, basically modify php.ini file, add a few DLL file to system file, Php_ffmpeg.dll Add to PHP, still useless, then may be PHP and ffmpeg version does not match, and then find a version of the consistent and try again, or not, I was going to be crazy. Later, I saw the internet said that IIS does not work, because this method is useful for the Apache server. I also installed a XAMPP integrated environment, a small try, or not, because of development problems, or do not want to use Apache, there is no attempt.

Since the integration does not work, then I will use the external command, because this does not need version matching (also do not know is not really need to match), can also achieve my goal, in the online download FFmpeg Win64 installation package (after the article I will put on the required software, there is a need to download), unpack the folder into D : \ffmpeg, as shown in figure:

That's it, the video is my own, and then in the system environment variable path Add bin path D:\ffmpeg\bin, as shown:


This time should be able to use the command line execution, win+r open run, enter CMD carriage return, I use ffmpeg command to intercept the video first frame save Picture: Ffmpeg-i d:\ffmpeg\test.mp4-y-F image2-t 0.001-s 352x240 D:\ffmpeg\abcd.jpg

And then output a lot of things, in the D-disk ffmpeg of the directory, this time a picture of abcd.jpg


It means that the ffmpeg will be installed at this time.

In the end we're going to use this command to execute in the PHP environment, first write a indexs.php file in the root directory

<?php
exec ("dir", $output, $return _val);
Print_r ($output);
Print_r ($return _val);
Enter the indexs.php URL on the Web page. Warning:exec (): Unable to fork, this hint should be no user rights, then open IIS Manager, find the application pool-"Find your corresponding site pool-" Advanced Settings-"

Determine the restart of the IIS server, and then open indexs.php with the Web page, if the output of the array is successful, if prompted: Warning:exec () has been disabled for security reasons

This is PHP does not have the right to execute exec, find the PHP directory under the php.ini file, Safe_mode to turn off, disable_functions the exec removed, it is best to back up the file you modified.

Restart the IIS server to see the output of the data, do not prompt the error indicating success. How to deal with the specific method of video I have not done, this is not difficult to believe, I put a few I want to use the FFmpeg command, if the following need me to write the PHP processing video code, in the following message. (This post does not guarantee that all can succeed, I am also a rookie.) Don't spray ~)

FFmpeg code (I used all the absolute path, the following command I have tested all, to ensure that there is no problem. )

Cut video first frame save picture
ffmpeg-i e:\girl.mp4-y-F image2-t 0.001-s 352x240 e:\a.jpg

converts the first 30 frames of the video into a animated Gif
ffmpeg-i E:\girl.mp4-vframes 100-y-F gif e:\a.gif



intercepts a thumbnail of a specified time,-ss followed by a time unit of seconds
Ffmpeg-i e:\girl.mp4-y-F image2-ss 28-t 0.001-s 350x240 e:\test.jpg


output Video details
ffprobe-v quiet-print_format json-show_format-show_streams e:\girl.mp4

FFmpeg installation files:
http://download.csdn.net/download/ysjyygywfn/9946052

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.