在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:ffmpeg-push开源软件地址:https://gitee.com/Bping/ffmpeg-push开源软件介绍:ffmpeg-pushPush video stream to live server with ffmpeg binary Installation 安装composer require bping/ffmpeg-push dev-master usageFirst
Push 推流require __DIR__ . '/trunk/vendor/autoload.php';use FFMpegPush\PushFormat;use FFMpegPush\PushInput;use FFMpegPush\PushOutput;use FFMpegPush\PushVideo; ///** @var $ffprobe FFProbeCommand */ //$ffprobe = FFProbeCommand::create(); //var_dump($ffprobe->format('test.mp4'));// Push Command 推流命令// ffmpeg -re -i \"test/test.mp4\" -c:v copy -c:a copy -f flv rtmp://pili-publish.heliwebs.com $pushUrl = 'rtmp://pili-publish.heliwebs.com'; $pushCmd = PushVideo::create(); // listening the progress of push flow 监听推流进度 $pushCmd->onProgress(function ($percent, $remaining, $rate) { // var_dump(func_get_args()); echo "progress:$percent% remaining:$remaining(s) rate:$rate(kb/s)\n"; }); $pushCmd->setInput( PushInput::create() ->setStartTime(0) ->setInputVideo('res/test.mp4') ) ->setFormat( PushFormat::create() ->setVideoCodec(PushFormat::CODE_V_COPY) ) ->setOutput( PushOutput::create() ->setPushUrl($pushUrl) ); echo $pushCmd->getCommandLine(); // start to push $pushCmd->push(); echo $pushCmd->getErrorOutput(); echo "\n"; echo "Exit Code: " . $pushCmd->getExitCode(); // Stop pushing, asynchronous calls are required 停止推流,需要异步调用 // $pushCmd->stop(); Result |
请发表评论