Facebook事實上已開始在平台中支持360度全景視頻的流播,但公司對此並不滿足。其工程師更是基於錐體幾何學設計出了一套全新的視頻編碼,號稱最高能將全景視頻的文件大小減少80%。(VR最新突破:全景視頻壓縮率達80%,即將普及爆發)
1、Facebook開源了其將2:1球模型視頻轉換成立方體模型的代碼
https://github.com/facebook/transform
README:
1 # Transform 2 3 Transform is a video filter that transforms 360 video in equirectangular projection into a cubemap projection 4 5 ## Building 6 7 Transform is implemented as an ffmpeg video filter. To build Transform, follow these steps: 8 9 1. Checkout the source for ffmpeg 10 2. Copy `vf_transform.c` to the libavfilter subdirectory in ffmpeg source 11 3. Edit `libavfilter/allfilters.c` and register the filter by adding the line: `REGISTER_FILTER(TRANSFORM, transform, vf);` in the video filter registration section 12 4. Edit `libavfilter/Makefile` and add the filter to adding the line: `OBJS-$(CONFIG_TRANSFORM_FILTER) += vf_transform.o` in the filter section 13 5. Configure and build ffmpeg as usual 14 15 ## Running 16 17 Check out the options for the filter by running `ffmpeg -h filter=transform` 18 A typical execution would be something like `ffmpeg -i input.mp4 -vf transform=input_stereo_format=MONO:w_subdivisons=4:h_subdivisons=4:max_cube_edge_length=512`
2、facebook/transform代碼實現淺析
2.1、據facebook稱將球模型轉成立方體模型科技減少25%的數據量
2.2、轉換成四棱錐可以減少80%的數據量,但這部分代碼沒有開源。
2.3、現有球模型是怎么展開成2:1的視頻的,以地球儀和世界地圖為例:
2.4、根據其開源代碼在linux下用ffmpeg實現的結果,實現方法參見:Linux下編譯ffmpeg並用GDB調試 以及根據README修改相應源碼
2.5、立方體展開成十字形的結果:
2.6、源碼的轉換核心是坐標之間的轉換,即怎么把球模型上的點和立方體對應以來,其實現方法是給定立方體模型上的坐標,根據坐標算出α和β(可以想成極坐標,水平一圈360度,上下180度);α、β分別除以360度和180度,按比例找出在球上對應的點(在2:1視頻中的像素點)。
2.7、以正前方這個面為例:
2.8、將坐標轉換成在空間內的立方體坐標(qx,qy,qz);qz表示球心(立方體中心)到前方平面的距離
2.9、轉換成(tx,ty,tz)是考慮到視線可能移動,正前方的面也變了,但此處默認(y,p)都為0;故坐標不變
2.10、在立體空間內算出(α,β),α是水平偏向角,范圍:(-180度,180度);β是豎直偏向角,范圍:(-90度,90度)
2.11、算出(α,β)角度,就可以根據比例得到對應在2:1視頻中相應的像素點