当前位置:网站首页>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边栏推荐
- 电脑Win7系统桌面图标太大怎么调小
- PAG experience: complete AE dynamic deployment and launch all platforms in ten minutes!
- Find your own value
- 搜索引擎接口
- A laravel background management expansion package you can't miss - Voyager
- In the field of software engineering, we have been doing scientific research for ten years!
- Docker deploy Oracle
- PD virtual machine tutorial: how to set the available shortcut keys in the parallelsdesktop virtual machine?
- 关于后台动态模板添加内容的总结 Builder使用
- Instructions for mictr01 tester vibrating string acquisition module development kit
猜你喜欢

【愚公系列】2022年7月 Go教学课程 005-变量

数据湖(九):Iceberg特点详述和数据类型

leetcode:648. 单词替换【字典树板子 + 寻找若干前缀中的最短符合前缀】

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

2022年13个UX/UI/UE最佳创意灵感网站

Wechat applet - Advanced chapter component packaging - Implementation of icon component (I)

今日睡眠质量记录78分

华为云数据库DDS产品深度赋能

Computer win7 system desktop icon is too large, how to turn it down

#yyds干货盘点# 解决名企真题:交叉线
随机推荐
Leetcode - Sword finger offer 05 Replace spaces
《微信小程序-进阶篇》组件封装-Icon组件的实现(一)
Oracle Linux 9.0 officially released
The world's first risc-v notebook computer is on pre-sale, which is designed for the meta universe!
GAN发明者Ian Goodfellow正式加入DeepMind,任Research Scientist
C# 6.0 语言规范获批
缓冲区溢出保护
Leetcode one question per day (636. exclusive time of functions)
Hangdian oj2092 integer solution
Analysis of arouter
数据湖(九):Iceberg特点详述和数据类型
Data connection mode in low code platform (Part 2)
Decrypt the three dimensional design of the game
Base64 encoding
Demis hassabis talks about alphafold's future goals
多商戶商城系統功能拆解01講-產品架構
A laravel background management expansion package you can't miss - Voyager
ES日志报错赏析-- allow delete
Simple steps for modifying IP of sigang electronic scale
Oracle Linux 9.0 正式发布