当前位置:网站首页>Use ffmpeg to rotate, flip up and down, and flip horizontally

Use ffmpeg to rotate, flip up and down, and flip horizontally

2022-07-05 06:30:00 Third master takes you to fly

brief introduction : In the use of ffmpeg do .h264 After coding, you may use vlc When playing, the image is vertically reversed . Probable cause :RGB There are two ways to store images : One is to scan from top to bottom ; The other is scanning from bottom to top .OpenCV Scanning from top to bottom ,ffmpeg It may also be a top-down storage method , and OpenGL/Unity The frame buffer data in may be scanned from bottom to top , This leads to the problem of vertical flipping of the image .

Vertical rotation :

ffmpeg -i  Original video .mp4 -vf vflip -y  Flip left and right .mp4

Flip left and right horizontally :

ffmpeg -i  Original video .mp4 -vf hflip -y  Flip left and right .mp4

The picture rotates clockwise 90 degree :

ffmpeg -i  Original video .mp4 -vf transpose=1  along 90 degree .mp4

The picture rotates counterclockwise 90°:

ffmpeg -i  Original video .mp4 -vf transpose=2  The inverse 90 degree .mp4

The processing method of pictures is consistent with that of videos , Switch the corresponding type to picture .

ffmpeg -i  Original picture .png -vf vflip -y   Flip up and down .png
ffmpeg -i  Original picture .png -vf hflip -y   Flip left and right .png
ffmpeg -i  Original picture .png -vf transpose=1  along 90 degree .png
ffmpeg -i  Original picture .png -vf transpose=2  The inverse 90 degree .png

Final execution result :

 picture

WeChat official account : Play with test development
Welcome to your attention , Common progress , thank you !

 Insert picture description here

原网站

版权声明
本文为[Third master takes you to fly]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140605248810.html