問題描述
是否可以在一行中運行cropdetect 和crop 并從視頻中獲取拇指?
Its possible to run cropdetect and crop in one line and get thumbs from video?
像這樣
ffmpeg -ss 1 -i 0.flv -vf cropdetect=24:16:0,crop=w:h:x:y -vcodec mjpeg -vframes 1 -an -f rawvideo -s 240x180 0.jpg
或者可能需要在 2 行中運行,首先運行cropdetect,然后運行crop 并從視頻生成拇指,但這樣我需要從cropdetect 中獲取價值?
Or maybe need to run in 2 line, first run cropdetect and than run crop and generate thumbs from video, but in this way i need to get value from cropdetect?
推薦答案
cropdetect
輸出到控制臺,因此您可以解析輸出,然后將其用作變量:
cropdetect
outputs to the console, so you can parse the output and then use it as a variable:
ffmpeg -i input -t 1 -vf cropdetect -f null - 2>&1 | awk '/crop/ { print $NF }' | tail -1
這將導致類似:
crop=640:480:0:50
然后運行您的實際裁剪命令:
Then run your actual crop command:
ffmpeg -i input -vf $cropvalue,scale=240:-1 -vframes 1 -qscale:v 2 output.jpg
-vcodec mjpeg
、-an
和-f rawvideo
是多余的使用
-qscale:v
控制jpg輸出質量.合理的范圍是 2-5(較低的值表示較高的質量).Use
-qscale:v
to control jpg output quality. A sane range is 2-5 (a lower value is a higher quality).使用
scale
過濾器而不是-s
;特別是如果您已經在使用過濾器.此外,scale
過濾器將允許您設置特定的寬度或高度,并且使用-1
它將自動提供正確的值以保留方面.否則,如果您嘗試強制使用特定大小,則可能會導致輸出被壓扁或拉伸.Use the
scale
filter instead of-s
; especially if you're already using filters. Also thescale
filter will allow you to set a specific width or height and with-1
it will automatically provide the correct value to preserve aspect. Otherwise if you try to force a specific size you can risk a squished or stretched output.顯然我不是 PHP 編碼員,但這至少應該給你一個想法.
Obviously I'm not a PHP coder, but this should give you an idea at least.
這篇關于ffmpeg 從cropdetect 中獲取值的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!