Quest 2 VR180 to LifecastVR 6dof video on Idena IPFS

in #idena3 years ago (edited)

I converted a footage of myself breaking a walnut shot on Oculus Quest 2 cameras to LifecastVR 6-degrees-of-freedom video format and hosted it on Idena's IPFS network.

FFmpeg scripts I put in bat files on a Plutosphere Windows machine:

video to frames:

ffmpeg.exe -i input.mp4 -f lavfi -i \

"color=s=1832x1832,format=yuva420p,geq=lum='p(X,Y)':\

a='if(lte(hypot((X-(W/2))\*(W/(W-100)),Y-(H/2)),(W/2)-50),255,0)',\ -- circular mask

alphaextract" -f lavfi -i "color=color=#000000:s=7328x3664" \ -- background to pad 90 deg to 180

-filter\_complex "[0]select='(isnan(prev\_selected\_t)+gte(t-prev\_selected\_t\,0.06))',\ -- 25 fps

split[f-L][f-R],[f-L]crop=1832:1832:0:25[L],[L][1]alphamerge[L-c-a],\ -- left eye mask

[f-R]crop=1832:1832:1832:25[R],[R][1]alphamerge[R-c-a],\ -- right eye mask

[2][L-c-a]overlay=w/2:h/2[L-o],[L-o][R-c-a]overlay=4580:h/2" \ -- join back together masked eyes

-shortest -vsync vfr .\input-frames\%%06d.png

chose 0.063 ipd in the converter

frames to video:

ffmpeg.exe -f image2 -i .\output-frames\%%06d.png \

-vcodec libx264 -crf 17 -preset veryslow -pix\_fmt yuv420p output.mp4

Then downscaled for mobile on my RPi:

ffmpeg -i walnut-3840p.mp4 -vf "scale=1080:1080" -c:v h264_v4l2m2m -r 30 -crf 17 -preset veryslow -c:a copy walnut-1080p-30fps.mp4

Bundled LifecastVR JS player with Rollup:

created main.js in lifecast_res folder with:

import \* as LifecastVideoPlayer from './LifecastVideoPlayer5.js';

LifecastVideoPlayer.init({\_media\_url: "ipfs hash of the media file"});

then run

rollup main.js --file bundle.js --format iife

changed all the player controls' PNGs to their ipfs hashes

then put the bundle.js as a script in the _body_ of the index.html

Script I use to push to IPFS:

#!/bin/bash

echo -n '{

"method": "ipfs\_add",

"params": [

"0x' >> json ;

xxd -p $1 | tr -d '\n' >> json ; # xxd shows data in hex

echo '",

false

],

"id": 1,

"key": "API key of my Idena node"

}' >> json ;

curl 'http://localhost:9009/' -H 'Content-Type:application/json' --data @json ; # increased upload limit in the source

rm json;

Sort:  

h264_v4l2m2m codec doesn't have a crf option. use bitrate instead: -b:v 8M