当前位置:网站首页>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
边栏推荐
- 内部排序——插入排序
- #yyds干货盘点# 解决名企真题:交叉线
- Decrypt the three dimensional design of the game
- PyTorch模型训练实战技巧,突破速度瓶颈
- Search engine interface
- 2022pagc Golden Sail award | rongyun won the "outstanding product technology service provider of the year"
- The longest ascending subsequence model acwing 1014 Mountaineering
- Small game design framework
- 昇腾体验官第五期随手记I
- 电脑Win7系统桌面图标太大怎么调小
猜你喜欢
Because the employee set the password to "123456", amd stolen 450gb data?
Cvpr2022 | backdoor attack based on frequency injection in medical image analysis
LeetCode 648. 单词替换
Simple use of websocket
Base64 encoding
数据湖(九):Iceberg特点详述和数据类型
Instructions for mictr01 tester vibrating string acquisition module development kit
[Yugong series] go teaching course 005 variables in July 2022
一个程序员的水平能差到什么程度?尼玛,都是人才呀...
Navigation - are you sure you want to take a look at such an easy-to-use navigation framework?
随机推荐
Multi merchant mall system function disassembly lecture 01 - Product Architecture
Five pain points for big companies to open source
Find your own value
【愚公系列】2022年7月 Go教学课程 005-变量
低代码平台中的数据连接方式(下)
Substance Painter筆記:多顯示器且多分辨率顯示器時的設置
Cocos creator direction and angle conversion
[Yugong series] go teaching course 005 variables in July 2022
Introduction and use of Kitti dataset
Mrs offline data analysis: process OBS data through Flink job
Es log error appreciation -- allow delete
Navigation — 这么好用的导航框架你确定不来看看?
Pinduoduo lost the lawsuit, and the case of bargain price difference of 0.9% was sentenced; Wechat internal test, the same mobile phone number can register two account functions; 2022 fields Awards an
Differences between cookies and sessions
Demis Hassabis谈AlphaFold未来目标
拼多多败诉,砍价始终差0.9%一案宣判;微信内测同一手机号可注册两个账号功能;2022年度菲尔兹奖公布|极客头条...
Instructions d'utilisation de la trousse de développement du module d'acquisition d'accord du testeur mictr01
JS get the current time, month, day, year, and the uniapp location applet opens the map to select the location
什么是云原生?这回终于能搞明白了!
JS in the browser Base64, URL, blob mutual conversion