2017-09-12 49 views
0

当运行此脚本,将图像保存到文件:如何使用avconv和php与exec显示流的屏幕截图?

<?php 

    $url = "rtmp://109.71.162.112:1935/live/sd.jasminchannel.stream"; 
    exec('avconv -i "'.$url.'" -ss 00:00:01 -t 1 -r 1 -f image2 "screenshot.jpg" 2>&1', $output, $status); 

    header("Content-type: image/png"); 
    readfile("screenshot.jpg"); 

我想这是在屏幕上回(飞意味着,写变量,无需而不是保存到文件,并随后阅读,显示,删除此文件):

<?php 

    $url = "rtmp://109.71.162.112:1935/live/sd.jasminchannel.stream"; 
    exec('avconv -i "'.$url.'" -ss 00:00:01 -t 1 -r 1 -f image2 $variable 2>&1', $output, $status); 

    header("Content-type: image/png"); 
    echo $variable; 

我该怎么做?

回答

0

我认为这将解决您的问题:

<?php 

    $url = "rtmp://109.71.162.112:1935/live/sd.jasminchannel.stream"; 
    header("content-type: image/jpeg"); 
    echo passthru('avconv -i "'.$url.'" -ss 00:00:01 -t 1 -r 1 -f image2 pipe:.jpg 2>/dev/null'); 

这是未经测试,但它应该工作。我一直工作在一个类似的问题在: https://gist.github.com/megasaturnv/a42ed77d3d08d0d3d91725dbe06a0efe

,并在标签图像: https://gist.github.com/megasaturnv/6e5965732d4cff91f2e976e7a39efbaa