ffmpeg视频的翻转相关

由于项目上需要使用到ffmpeg做视频处理所以不得不学习一下,同时做一些简单的记录

 一、视频的翻转相关

  水平翻转

  参数说明:-i 指定输入的文件;-vf filter_graph,用来设置: video filters

  原视频:

  

ffmpeg -i test.mp4 -vf "hflip" "C:\Users\amin\Desktop\test2.mp4"

  水平翻转后的:

  

 

   垂直翻转

  

ffmpeg -i test.mp4 -vf "vflip" "C:\Users\amin\Desktop\test2.mp4"

  垂直翻转后的视频

  

 

  指定角度旋转

  transpose:指定旋转的效果

  参数说明:0:逆时针旋转90度并垂直翻转;1:顺时针旋转90度;2:逆时针旋转90度;3:顺时针旋转90度后并垂直翻转

  逆时针旋转90度并垂直翻转

  

ffmpeg -i test.mp4 -vf "transpose=0" "C:\Users\amin\Desktop\test2.mp4"

  结果见下图:

  

 

  顺时针旋转90度

  

ffmpeg -i test.mp4 -vf "transpose=1" "C:\Users\amin\Desktop\test3.mp4"

 

  结果见下图:

   

  逆时针旋转90度

  

ffmpeg -i test.mp4 -vf "transpose=2" "C:\Users\amin\Desktop\test3.mp4"

 

  结果见下图:

   

 

  顺时针旋转90度后并垂直翻转

  

ffmpeg -i test.mp4 -vf "transpose=3" "C:\Users\amin\Desktop\test3.mp4"

 

  结果见下图:

   

 

 

顺时针旋转180度
ffmpeg -i test.mp4 -vf "transpose=1,transpose=1" "C:\Users\amin\Desktop\test2.mp4"
逆时针旋转180度
ffmpeg -i test.mp4 -vf "transpose=2,transpose=2" "C:\Users\amin\Desktop\test2.mp4"

  其他角度旋转 

  PI:指180度  顺时针

  参数说明:PI/2: 90度,注意,视频旋转90度后,原宽高没变,所以显示两侧有黑边       #画面有被隐藏掉的部分

  弧度旋转

  需要注意的是当度数为小数时会出现多边形

ffmpeg -i test.mp4 -vf "rotate=PI/2" "C:\Users\amin\Desktop\test2.mp4"     # 90度

ffmpeg -i test.mp4 -vf "rotate=PI" "C:\Users\amin\Desktop\test2.mp4"    # 180度

ffmpeg -i test.mp4 -vf "rotate=PI/3" "C:\Users\amin\Desktop\test2.mp4"       #60度

ffmpeg -i test.mp4 -vf "rotate=PI/4" "C:\Users\amin\Desktop\test2.mp4"       45 度
 
 

 

  

 

posted @ 2021-12-28 17:36  许光宗  阅读(267)  评论(0编辑  收藏  举报