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 度

浙公網安備 33010602011771號