久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

從視頻中提取特定幀的最快方法(PHP/ffmpeg/anythin

Fastest way to extract a specific frame from a video (PHP/ffmpeg/anything)(從視頻中提取特定幀的最快方法(PHP/ffmpeg/anything))
本文介紹了從視頻中提取特定幀的最快方法(PHP/ffmpeg/anything)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有一個網頁,它(除其他外)需要從用戶上傳的視頻中提取特定的幀.用戶在播放器中尋找 .mp4 的特定部分,然后單擊一個按鈕,然后 ajax 調用被觸發到一個 php 腳本,該腳本獲取 .mp4 和視頻中的確切時間,并使用它來提取一個縮略圖"框架.

I have a web page, which (among other things) needs to extract a specific frame from a user-uploaded video. The user seeks to a particular part of a .mp4 in the player, then clicks a button, and an ajax call gets fired off to a php script which takes the .mp4, and the exact time from the video, and uses that to extract a "thumbnail" frame.

我目前的解決方案是使用 php exec 命令:

My current solution is using the php exec command:

exec("ffmpeg -i $videoPath -ss $timeOffset -vframes 1 $jpgOutputPath");

...這很好用,除了它像糖蜜一樣慢.我的猜測是 ffmpeg 對這項工作來說有點太多了,我可能可以通過利用底層庫或其他東西做得更好......但是我對如何做到這一點毫無想法.

...which works just great, except it's as slow as molasses. My guess is that ffmpeg is a little too much for the job, and I might be able to do better by utilizing the underlying libraries or something... however I have zero idea how to do that.

理想情況下,我不想安裝任何需要真正安裝過程"的東西......即,將可執行文件放入帶有我的網絡應用程序的文件夾中很好,但我寧愿不必實際運行安裝人員.此外,該解決方案應該能夠在 mac、linux 和 windows 上運行(盡管 linux 是首要任務).

Ideally I don't want to have to install anything that requires a real "installation process"... i.e., dropping an executable into the folder with my web app is fine, but I'd rather not have to actually run an installer. Also, the solution should be able to run on mac, linux and windows (though linux is the top priority).

我可以做些什么來加快這個過程?

What can I do to speed this process up?

謝謝.

推薦答案

當然,你可以編寫一些 C/C++ 代碼并鏈接到 -lav*,基本上創建了一個 ffmpeg 的簡化版本,僅用于提取幀,甚至可以這樣做它作為一個 php 擴展(我也不會以同一個用戶的身份運行它,更不用說在同一個進程中了).但結果不太可能更快,因為您只會避免一些分叉和設置開銷,但您可能的問題實際上是解碼,這仍然是相同的.

Of course you could code up some C/C++ and link to -lav*, basically creating a simplified version of ffmpeg just for extracting frames, and maybe even do it as a php extension (also I wouldn't run it as the same user, let alone in the same process). But the result is very unlikely to be faster, because you would only avoid some forking and setup overhead, but your likely problem is actually the decoding, which would still be the same.

相反,您應該首先考慮在快速搜索模式(或快速/準確混合模式)下使用 ffmpeg.他們的維基聲明關于快速搜索:

Instead, you should first look into using ffmpeg in fast seeking mode (or fast/accurate hybrid mode). Their wiki states about fast seeking:

需要在-i前指定-ss參數:

ffmpeg -ss 00:03:00 -i Underworld.Awakening.avi -frames:v 1 out1.jpg

ffmpeg -ss 00:03:00 -i Underworld.Awakening.avi -frames:v 1 out1.jpg

此示例將在周圍某處生成一個圖像幀 (out1.jpg)電影開始的第三分鐘.輸入將是使用關鍵幀解析,速度非常快.缺點是它也將在某個關鍵幀完成搜索,不一定位于在指定時間 (00:03:00),所以搜索不會那么準確正如預期的那樣.

This example will produce one image frame (out1.jpg) somewhere around the third minute from the beginning of the movie. The input will be parsed using keyframes, which is very fast. The drawback is that it will also finish the seeking at some keyframe, not necessarily located at specified time (00:03:00), so the seeking will not be as accurate as expected.

快速搜索不太準確,但要快得多,因為 ffmpeg 在搜索期間實際上不需要解碼(大部分)電影,而快速/準確混合模式是很好的折衷方案.閱讀維基頁面了解所有可用選項.

Fast seeking is less accurate, but a damn lot faster, as ffmpeg will not actually need to decode (most of) the movie during the seek, while fast/accurate hybrid mode is good compromise. Read the wiki page for all available options.

10 年 6 月 14 日編輯:

從 FFmpeg 2.1 開始,當使用 ffmpeg 進行轉碼(即不是流復制)時,-ss 現在即使用作輸入選項也是準確的.可以使用 -noaccurate_seek 選項恢復以前的行為.(來源)

As of FFmpeg 2.1, when transcoding with ffmpeg (i.e. not stream copying), -ss is now accurate even when used as an input option. Previous behavior can be restored with the -noaccurate_seek option. (source)

因此,對于 2.1+,在重新編碼時不再需要混合"搜索以獲得準確的結果(并且保存到 .jpeg 是重新編碼).執行通常的快速搜索 (-ss ... -i ...) 而不是慢速搜索 (-i ... -ss ...) 就足夠了).

So with 2.1+, "hybrid" seeking shouldn't be required anymore for accurate results when it comes to re-encodes (and saving to .jpeg is a re-encode). It is enough to do the usual fast seeking (-ss ... -i ...) instead of slow seeking (-i ... -ss ...).

這篇關于從視頻中提取特定幀的最快方法(PHP/ffmpeg/anything)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Action View Helper in Zend - Work around?(Zend 中的動作視圖助手 - 解決方法?)
Is this a good way to match URI to class/method in PHP for MVC(這是將 URI 與 PHP 中用于 MVC 的類/方法匹配的好方法嗎)
Where do I save partial (views) in Zend Framework, to be accessible for all Views in my App?(我在哪里保存 Zend Framework 中的部分(視圖),以便我的應用程序中的所有視圖都可以訪問?) - IT屋-程序員軟件開發技術
Having a single entry point to a website. Bad? Good? Non-issue?(有一個網站的單一入口點.壞的?好的?沒問題?)
Is MVC + Service Layer common in zend or PHP?(MVC + 服務層在 Zend 或 PHP 中常見嗎?)
Hello World example in MVC approach to PHP(PHP MVC 方法中的 Hello World 示例)
主站蜘蛛池模板: av黄色免费 | 亚洲视频中文字幕 | 人人操日日干 | 伊人春色在线观看 | 色小姐综合网 | 五月天婷婷久久 | www.久久久久久久久久久 | 91亚洲国产亚洲国产 | 国产高清视频 | 91精品国产91久久久久久 | 九九亚洲 | 啪啪免费| 激情五月综合 | 视频在线亚洲 | 日韩中文字幕 | 日韩一区二区成人 | 亚洲日韩欧美一区二区在线 | 欧美激情综合网 | 免费一级大片 | 国产一区二 | 日韩激情一区 | av天天干| 成人激情视频网 | 污书屋 | 日本不卡一区二区三区 | 亚洲视频在线观看免费 | 涩爱av一区二区三区 | 亚洲欧美激情视频 | jizz在线看片| 国产成人综合在线 | 午夜私人影院在线观看 | 欧美成人a | 久久精品免费 | 中文字幕在线播放第一页 | 色综合久久久 | 精品无码久久久久久国产 | 国产精品久久av | 成人福利在线 | 99精品一区| 性色视频| 亚洲人a|