我正在使用 insta 360 x3,並且希望在不使用 Linux 上的工作室工具的情況下自動匯出影片。
這是相機中影片格式的螢幕截圖(Insta360 x3 相機螢幕截圖):
我正在使用 ffmpeg 使用以下命令解開視訊來源:(摘自這個 stackoverflow 答案)
ffmpeg -y -i input.lrv -vf v360=dfisheye:e:yaw=-90 -c:v libx265 -b:v 40000k -bufsize 5000k -preset ultrafast -c:a copy -t 10 test.mkv
該命令有效,並且做得不錯,但其中一個鏡頭的視野更高,輪廓模糊。這會產生以下圖像:
ffmpeg 指令後 Insta360 x3 相機截圖的影像:
有沒有辦法更改 ffmpeg 命令以將兩個鏡頭重疊幾個像素以消除模糊,或裁剪掉重疊的視野?
答案1
您使用的命令使用預設參數,這意味著它假設您的相機的 FOV=180 並且完全水平。
經過一些實驗這個網站我發現實際FOV是193°;但這還不夠:當然不可能將相機保持完全水平,因此您必須補償俯仰和滾動。
我得到的最終命令是:
ffmpeg -i dfisheye.jpg -filter_complex "[0:v]v360=input=dfisheye:output=equirect:pitch=-22:roll=-20:ih_fov=193:iv_fov=193[out_v]" -map "[out_v]" out.gif
或者,使用您的語法:
ffmpeg -y -i input.lrv -vf v360=dfisheye:e:pitch=-22:roll=-20:ih_fov=193:iv_fov=193 -c:v libx265 -b:v 40000k -bufsize 5000k -preset ultrafast -c:a copy -t 10 test.mkv
我得到的圖像是:
注意不要混淆視場角和視場角和視場角和視場角。
請注意,一旦您找到適合相機的FOV,所有照片的FOV將保持不變,但每張照片的PICTH和ROLL將不同;考慮一下完美水平的照片適合這樣的網格:
未補償俯仰和滾動的圖像:
答案2
此腳本不會修正鏡頭暗角變暗的縫合邊緣。將輸出檔案變更NEW.mp4
為照片副檔名NEW.jpg
不會在不刪除的情況下傳遞照片libx264 -preset ultrafast
。
H值是影片的高度。您需要設定輸入影片的高度。 FOV 應設定為您的相機 FOV。
C值是兩個影像重疊處混合的像素數。
@echo off
REM split the input and pitch one to level them - hstack the two streams to the output
set "FOV=189.1" :: Horizontal and vertical field of view of the fisheye lenses in degrees, normal 189.1
set "H=1920" ::Height of video
set "C=2" :: Width of interpolation band in degrees, must be smaller or equal than (FOV-180 ), normal is 2
set "RL=0" ::Roll (neg cockwise/counter clockwise pos) angle to change perspective in Left Equirectangular image
set "PL=0" ::Pitch (pos down/up neg) angle degrees to boundary to change perspective in Left Equirectangular image
set "YL=0" ::Yaw (pos left/right neg) angle degrees to change perspective in Left Equirectangular image, normal is -1
set "RR=0" ::Roll (neg cockwise/counter clockwise pos) angle to change perspective in Right Equirectangular imag, normal 1
set "PR=0" ::Pitch (pos down/up neg) angle degrees to boundary to change perspective in Right Equirectangular image
set "YR=0" ::Yaw (pos left/right neg) angle degrees to change perspective in Right Equirectangular image MUST NOT BE POSITIVE AS GREATER THAN 180 NOT POSSIBLE
REM Create the mergemap file
ffmpeg -f lavfi -i nullsrc=size=%H%x%H% -vf "format=gray8,geq='clip(128-128/%C%*(180-%FOV%/(%H%/2)*hypot(X-%H%/2,Y-%H%/2)),0,255)',v360=input=fisheye:output=e:ih_fov=%FOV%:iv_fov=%FOV%" -frames:v 1 -y mergemap.png
REM Convert file Dual_Feye to equirectangular projection
ffmpeg -i %1 -i %FF%mergemap.png -lavfi "[0]format=rgb24,split[a][b];[a]crop=ih:iw/2:0:0,v360=input=fisheye:output=e:ih_fov=%FOV%:iv_fov=%FOV%:yaw=%YL%:pitch=%PL%:roll=%RL%[c];[b]crop=ih:iw/2:iw/2:0,v360=input=fisheye:output=e:yaw=180+%YR%:pitch=%PR%:roll=%RR%:ih_fov=%FOV%:iv_fov=%FOV%[d];[1]format=gbrp[e];[c][d][e]maskedmerge" -c:v libx264 -preset ultrafast -q:v 1 -y NEW.mp4