Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
BPing committed Jul 6, 2017
1 parent 335c2ca commit 7008225
Showing 1 changed file with 34 additions and 11 deletions.
45 changes: 34 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,42 @@ use FFMpegPush\PushInput;
use FFMpegPush\PushOutput;
use FFMpegPush\PushVideo;

///** @var $ffprobe FFProbeCommand */
//$ffprobe = FFProbeCommand::create();
//var_dump($ffprobe->format('test.mp4'));

// 推流
// 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();
// 监听推流进度
$pushCmd->onProgress(function ($percent,$remaining,$rate) {
// var_dump(func_get_args());
echo "progress:$percent% remaining:$remaining(s) rate:$rate(kb/s)\n";
});
$pushinfo = $pushCmd->setInput(PushInput::create()->setInputVideo('test/test.mp4'))
->setFormat(PushFormat::create())
->setOutput(PushOutput::create()->setPushUrl($pushUrl))
->push();
$pushUrl = 'rtmp://pili-publish.heliwebs.com';
$pushCmd = PushVideo::create();
// 监听推流进度
$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();

// 开始推流
$pushCmd->push();

echo $pushCmd->getErrorOutput();
echo "\n";
echo "Exit Code: " . $pushCmd->getExitCode();

// 停止推流,需要异步调用
// $pushCmd->stop();
Expand Down

0 comments on commit 7008225

Please sign in to comment.