donkey111111 2012-01-10 00:53
浏览 45
已采纳

抓取框架而不下载整个文件?

Is this possible using php + ffmpeg?

ffmpeg-php has the ability to:

Ability to grab frames from movie files and return them as images that can be manipulated using PHP's built-in image functions. This is great for automatically creating thumbnails for movie files.

I just don't want to download the whole file before doing so. So lets say i want to grab a frame @ 10% of the movie:

First lets get the size of remote file:

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_HEADER, true); 
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
curl_setopt($ch, CURLOPT_URL, $url); //specify the url
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 
$head = curl_exec($ch);

$size = curl_getinfo($ch,CURLINFO_CONTENT_LENGTH_DOWNLOAD);

Then it's quite easy to download only 10% of the .flv or .mov file using curl.

But the framegrab trick using ffmpeg-php probably won't work because the file probably is corrupted?

Any other ideas?

  • 写回答

1条回答 默认 最新

  • dqf67993 2012-01-12 18:23
    关注

    Yes I believe this will work. For video files as long as you do have the start of the file, processing like this should be possible. (If you only had, for example, a chunk of the file from the middle, it probably wouldn't work.)

    On the command line I downloaded the first part of an .FLV file with Curl, then grabbed frames using ffmpeg and it worked correctly. Doing the same in PHP should work as well.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 vscode的问题提问
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM