当前位置:网站首页>FFmpeg----图片处理
FFmpeg----图片处理
2022-07-07 12:45:00 【mytzs123】
说明:下面测试命令中image_source 是要处理的输入文件,out_source是处理完成之后的输出文件
1.图片压缩:ffmpeg可以很完美的压缩图片生成新图片,并可以设置压缩等级
ffmpeg -i image_source -q compress_level out_source
#compress_level:压缩等级为正整数,数值越大压缩等级越高2.约束比例压缩
ffmpeg可以将图片压缩成指定的尺寸
ffmpeg -i image_source -vf scale=width:height out_source
#width为压缩后的图片宽度
#height为压缩后的图片高度
#当width或height其中有一个数值为-1时将保持原来图片尺寸比例压缩3.图片裁剪
ffmpeg可以指定图片裁剪位置和裁剪的图片尺寸
ffmpeg -i image_source -vf crop=width:height:from_x:from_y out_source
#width是要裁剪出的图片的宽度
#height是要裁剪出的图片的高度
#from_x是裁剪的起始X轴的位置
#from_y是裁剪的起始Y轴的位置
#如果不指定from_x和from_y表示从原始图片中心位置开始裁剪4.添加水印图片
ffmpeg可以为图片添加水印,可以设置水印图片的大小、位置和透明度
ffmpeg -i image_source -vf movie=logo_source,scale=logo_width:logo_height,lut=a=val*opacity_num[watermask];[in][watermask] overlay=from_x:from_y[out] -y out_source
#logo_source为水印图片地址
#logo_width为水印图片的宽度
#logo_height为水印图片的高度
#opacity_num为水印图片的透明度
#from_x为水印的起始X轴的位置
#from_y为水印的起始Y轴的位置5.添加文字水印
ffmpeg可以为图片添加文字水印,可以设置字体、颜色、尺寸、文字内容、文字位置
ffmpeg -i image_source -vf drawtext=fontfile=font_ttf_path:fontcolor=font_color:fontsize=font_size:text=message_info:x=from_x:y=from_y out_source
#font_ttf_path为字体路径,此项必须设置否则会出现字体无法找到的错误;
#字体路径要设置绝对路径并且要注意路径正反斜线转义(例如C\\:/Windows/Fonts/simhei.ttf)
#font_color为字体的颜色
#font_size为字体的大小
#message_info为水印文字内容
#from_x为水印的起始X轴的位置
#from_y为水印的起始Y轴的位置
#如果水印内容是中文需要设置中文字体否则会文字显示乱码6.图片旋转指定的角度
ffmpeg可以将图片按照指定的角度旋转生成新图片
ffmpeg -i image_source -vf rotate=route_num*PI/180 -y out_source
#route_num是要旋转的角度
#当route_num大于0的时候顺时针旋转,当route_num小于0的时候逆时针旋转
7.图片旋转特殊简便命令
上面的命令理论上可以完成所有的图片旋转操作,但ffmpeg仍然存在特殊简便旋转命
ffmpeg -i image_source -vf transpose=route_number -y out_source
#route_number=0顺时针旋转90度再左右镜像
#route_number=1顺时针旋转90度
#route_number=2逆时针旋转90度
#route_number=3逆时针旋转90度再左右镜像
8.图片左右镜像
ffmpeg -i image_source -vf hflip out_source
9.将图片上下镜像
ffmpeg -i image_source -vf vflip out_source边栏推荐
- 《微信小程序-进阶篇》组件封装-Icon组件的实现(一)
- Data Lake (IX): Iceberg features and data types
- 低代码平台中的数据连接方式(下)
- Huawei cloud database DDS products are deeply enabled
- 因员工将密码设为“123456”,AMD 被盗 450Gb 数据?
- Half an hour of hands-on practice of "live broadcast Lianmai construction", college students' resume of technical posts plus points get!
- Simple use of websocket
- Leetcode——344. Reverse string /541 Invert string ii/151 Reverse the word / Sword finger in the string offer 58 - ii Rotate string left
- Es log error appreciation -- allow delete
- 【历史上的今天】7 月 7 日:C# 发布;Chrome OS 问世;《仙剑奇侠传》发行
猜你喜欢

全球首款 RISC-V 笔记本电脑开启预售,专为元宇宙而生!

The world's first risc-v notebook computer is on pre-sale, which is designed for the meta universe!

The longest ascending subsequence model acwing 1014 Mountaineering

Base64 encoding

《微信小程序-进阶篇》组件封装-Icon组件的实现(一)

内部排序——插入排序

Webrtc audio anti weak network technology (Part 1)

EfficientNet模型的完整细节

GAN发明者Ian Goodfellow正式加入DeepMind,任Research Scientist

STM32CubeMX,68套组件,遵循10条开源协议
随机推荐
Leetcode——236. The nearest common ancestor of binary tree
2022pagc Golden Sail award | rongyun won the "outstanding product technology service provider of the year"
The longest ascending subsequence model acwing 482 Chorus formation
课设之百万数据文档存取
数据湖(九):Iceberg特点详述和数据类型
找到自己的价值
Wechat applet - Advanced chapter component packaging - Implementation of icon component (I)
Use case diagram
LeetCode 648. Word replacement
Es log error appreciation -- allow delete
PAG experience: complete AE dynamic deployment and launch all platforms in ten minutes!
The longest ascending subsequence model acwing 1014 Mountaineering
缓冲区溢出保护
Selenium Library
一文读懂数仓中的pg_stat
Leetcode - Sword finger offer 05 Replace spaces
昇腾体验官第五期随手记I
一文读懂数仓中的pg_stat
比尔·盖茨晒48年前简历:“没你们的好看”
全球首款 RISC-V 笔记本电脑开启预售,专为元宇宙而生!