如何检查ffmpeg是否使用PHP编码视频? [英] How to check if ffmpeg is done encoding a video with PHP?

查看:167
本文介绍了如何检查ffmpeg是否使用PHP编码视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果使用ffmpeg编码视频,我需要使用特定的代码来检查PHP。我只需要一个简单的真/假检查。如果编码完成,则为真,如果未完成则为false。语言也是PHP,而且我安装了ffmpeg-php。

I need the specific code to check with PHP if it is done encoding a video with ffmpeg. I just need a simple true/false check. True if the encoding is done, and false if it is not done. Also the language is PHP, and I do have ffmpeg-php installed.

更多信息:我在Linux上。

More info: I am on Linux.

代码在

convertToFlv( $input, $output );

function convertToFlv( $input, $output ) {

echo "Converting $input to $output";

$command = "ffmpeg -y -i $input -acodec libfaac -ar 44100 -ab 96k -vcodec libx264 -level 41 -crf 20 -bufsize 20000k -maxrate 25000k -g 250 -r 20 -s 640x480 -coder 1 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -flags2 +brdo+dct8x8+bpyramid -me umh -subq 7 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -rc_eq 'blurCplx^(1-qComp)' -bf 16 -b_strategy 1 -bidir_refine 1 -refs 6 -deblockalpha 0 -deblockbeta 0 $output";

shell_exec( $command );

}


推荐答案

在php exec()中的ffmpeg之后添加另一行代码,以在命令行中运行php页面。

You could add another line of code after the ffmpeg in the php exec() to run a php page in the command line.

使用;结束你的ffmpeg行并键入php,然后输入您的php脚本的绝对位置。您可以添加一个get变量,其中您正在等待转换的视频的ID:

Just end your ffmpeg line with a ";" and type "php" followed by the absolute location of your php script to run. You could add a get variable with the id of the video you are waiting to be converted:

$cmd = "ffmpeg -i[SOURCE FILE] [OUTPUT FILE]; php /public_html/etc/ffmpegComplete.php?videoID=101";

exec( $cmd );

这篇关于如何检查ffmpeg是否使用PHP编码视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆