ffmpeg get value from cropdetect(ffmpeg 从cropdetect 中获取值)
问题描述
是否可以在一行中运行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:vto control jpg output quality. A sane range is 2-5 (a lower value is a higher quality).使用
scale过滤器而不是-s;特别是如果您已经在使用过滤器.此外,scale过滤器将允许您设置特定的宽度或高度,并且使用-1它将自动提供正确的值以保留方面.否则,如果您尝试强制使用特定大小,则可能会导致输出被压扁或拉伸.Use the
scalefilter instead of-s; especially if you're already using filters. Also thescalefilter will allow you to set a specific width or height and with-1it 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 中获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:ffmpeg 从cropdetect 中获取值
基础教程推荐
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 如何替换eregi() 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
