当前位置:网站首页>Ffmpeg --- image processing
Ffmpeg --- image processing
2022-07-07 14:48:00 【mytzs123】
explain : In the following test command image_source Is the input file to be processed ,out_source It is the output file after processing
1. Picture compression :ffmpeg It can perfectly compress pictures to generate new pictures , And you can set the compression level
ffmpeg -i image_source -q compress_level out_source
#compress_level: The compression level is a positive integer , The higher the value, the higher the compression level
2. Constrain proportional compression
ffmpeg You can compress the picture to a specified size
ffmpeg -i image_source -vf scale=width:height out_source
#width Is the width of the compressed picture
#height Is the height of the compressed picture
# When width or height One of the values is -1 It will keep the original image size ratio compressed
3. Image clipping
ffmpeg You can specify the cropping position and size of the image
ffmpeg -i image_source -vf crop=width:height:from_x:from_y out_source
#width Is the width of the image to be cropped
#height Is the height of the image to be cropped
#from_x It is the beginning of cutting X Position of the shaft
#from_y It is the beginning of cutting Y Position of the shaft
# If you don't specify from_x and from_y Means to crop from the center of the original picture
4. Add watermark image
ffmpeg You can add watermarks to pictures , You can set the size of the watermark image 、 Location and transparency
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 Is the watermark image address
#logo_width Is the width of the watermark image
#logo_height Is the height of the watermark image
#opacity_num For the transparency of watermark image
#from_x Is the beginning of the watermark X Position of the shaft
#from_y Is the beginning of the watermark Y Position of the shaft
5. Add text watermark
ffmpeg You can add text watermarks to pictures , You can set the font 、 Color 、 Size 、 Written content 、 Text location
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 Is the font path , This item must be set, otherwise there will be an error that the font cannot be found ;
# Set the absolute path for the font path and pay attention to the escape of the positive and negative slashes of the path ( for example C\\:/Windows/Fonts/simhei.ttf)
#font_color For the color of the font
#font_size Is the size of the font
#message_info Watermark text content
#from_x Is the beginning of the watermark X Position of the shaft
#from_y Is the beginning of the watermark Y Position of the shaft
# If the watermark content is Chinese, you need to set the Chinese font, otherwise the text will display garbled
6. Rotate the picture by the specified angle
ffmpeg You can rotate the picture according to the specified angle to generate a new picture
ffmpeg -i image_source -vf rotate=route_num*PI/180 -y out_source
#route_num Is the angle to rotate
# When route_num Greater than 0 Rotate clockwise when , When route_num Less than 0 Rotate counterclockwise when
7. Image rotation special simple command
The above command can theoretically complete all image rotation operations , but ffmpeg There is still a special simple rotating life
ffmpeg -i image_source -vf transpose=route_number -y out_source
#route_number=0 Clockwise rotation 90 Degrees mirror left and right again
#route_number=1 Clockwise rotation 90 degree
#route_number=2 Counter clockwise rotation 90 degree
#route_number=3 Counter clockwise rotation 90 Degrees mirror left and right again
8. The picture is mirrored left and right
ffmpeg -i image_source -vf hflip out_source
9. Mirror the picture up and down
ffmpeg -i image_source -vf vflip out_source
边栏推荐
- 什么是云原生?这回终于能搞明白了!
- 比尔·盖茨晒48年前简历:“没你们的好看”
- 激光雷达lidar知识点滴
- Pandora IOT development board learning (HAL Library) - Experiment 12 RTC real-time clock experiment (learning notes)
- Nllb-200: meta open source new model, which can translate 200 languages
- 解析PHP跳出循环的方法以及continue、break、exit的区别介绍
- JS get the current time, month, day, year, and the uniapp location applet opens the map to select the location
- Full details of efficientnet model
- PD virtual machine tutorial: how to set the available shortcut keys in the parallelsdesktop virtual machine?
- Oracle non automatic submission solution
猜你喜欢
Five pain points for big companies to open source
Ian Goodfellow, the inventor of Gan, officially joined deepmind as research scientist
CPU与chiplet技术杂谈
leetcode:648. Word replacement [dictionary tree board + find the shortest matching prefix among several prefixes]
OAuth 2.0 + JWT 保护API安全
今日睡眠质量记录78分
Full details of efficientnet model
Substance Painter笔记:多显示器且多分辨率显示器时的设置
大厂做开源的五大痛点
Today's sleep quality record 78 points
随机推荐
Beginner JSP
⼀个对象从加载到JVM,再到被GC清除,都经历了什么过程?
数据湖(九):Iceberg特点详述和数据类型
「2022年7月」WuKong编辑器更版记录
MRS离线数据分析:通过Flink作业处理OBS数据
Substance painter notes: settings for multi display and multi-resolution displays
Leetcode one question per day (636. exclusive time of functions)
LeetCode每日一题(636. Exclusive Time of Functions)
多商戶商城系統功能拆解01講-產品架構
【历史上的今天】7 月 7 日:C# 发布;Chrome OS 问世;《仙剑奇侠传》发行
Attribute keywords serveronly, sqlcolumnnumber, sqlcomputecode, sqlcomputed
Leetcode——236. The nearest common ancestor of binary tree
Data connection mode in low code platform (Part 2)
Mlgo: Google AI releases industrial compiler optimized machine learning framework
2022pagc Golden Sail award | rongyun won the "outstanding product technology service provider of the year"
EfficientNet模型的完整细节
Mmkv use and principle
JS in the browser Base64, URL, blob mutual conversion
Demis Hassabis谈AlphaFold未来目标
C 6.0 language specification approved