Skip to content

Instantly share code, notes, and snippets.

@duracell80
Last active February 23, 2024 03:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save duracell80/168f780b293994578619916644848a07 to your computer and use it in GitHub Desktop.
Save duracell80/168f780b293994578619916644848a07 to your computer and use it in GitHub Desktop.
VR180 Photo Flatten Scripts for Lenovo Mirage Camera
#!/bin/bash
# Feel free to change filename to $1 and implement amd or nvida hwa
# sudo apt install intel-media-va-driver-non-free -- non-free needed to encode
GPU_INTEL=$(ffmpeg -hide_banner -loglevel error -encoders | grep h264_qsv | wc -l)
GPU_DRIVR=$(ffmpeg -hide_banner -loglevel error -h encoder=h264_qsv | grep -i "Supported hardware devices: qsv qsv qsv" | wc -l)
mkdir -p .meta
ffmpeg -y -hide_banner -loglevel error -i 20201015-125525227.vr.jpg -vf "v360=input=hequirect:output=flat:h_fov=120:v_fov=120:pitch=-15:roll=10:yaw=20:w=2880:h=1620" test_pov.jpg &
ffmpeg -y -hide_banner -loglevel error -i 20201015-125525227.vr.jpg -vf "v360=input=hequirect:fisheye:v_fov=120" test_square.jpg &
ffmpeg -y -hide_banner -loglevel error -i 20201015-125525227.vr.jpg -vf "v360=input=fisheye:output=flat:h_fov=120:v_fov=47.5:pitch=0:roll=0,crop=w=3616:h=3016,scale=w=2880:h=2880" test_circle.jpg &
ffmpeg -y -hide_banner -loglevel error -i 20201015-125525227.vr.jpg -vf "v360=input=fisheye:output=flat:h_fov=120:v_fov=47.5:pitch=0:roll=0:w=3840:h=2160,crop=w=1920:h=1080,scale=1920:1080,setsar=1" test_flat.jpg>
for (( C=0; C<=30; C+=1 )); do
FRAME=$(printf "%02d\n" "${C}")
ffmpeg -n -hide_banner -loglevel error -i 20201015-125525227.vr.jpg -vf "v360=input=hequirect:output=flat:h_fov=120:v_fov=120:pitch=0:roll=0:yaw=${C}:w=2880:h=1620" ".meta/test_panright_${FRAME}.jpg"
ffmpeg -n -hide_banner -loglevel error -i 20201015-125525227.vr.jpg -vf "v360=input=hequirect:output=flat:h_fov=120:v_fov=120:pitch=0:roll=0:yaw=-${C}:w=2880:h=1620" ".meta/test_panleft_${FRAME}.jpg"
done
rm -f test_panlist.txt
ls --format=single-column .meta/test_panleft* >> test_panlist.txt
ls --format=single-column .meta/test_panleft* | sort -r >> test_panlist.txt
ls --format=single-column .meta/test_panright* >> test_panlist.txt
ls --format=single-column .meta/test_panright* | sort -r >> test_panlist.txt
sed -i 's/^/file /' test_panlist.txt
if [[ $GPU_INTEL == 1 ]]; then
ffmpeg -y -hide_banner -loglevel error -f concat -safe 0 -i test_panlist.txt -vcodec h264_qsv -preset veryslow -filter_complex "loop=loop=2:size=124:start=0" test_pan.mp4
else
ffmpeg -y -hide_banner -loglevel error -f concat -safe 0 -i test_panlist.txt -vcodec h264_qsv -preset fast -filter_complex "loop=loop=2:size=124:start=0" test_pan.mp4
fi
rm -f test_panlist.txt
#rm .meta/test_panleft*
#rm .meta/test_panright*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment