Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parsing for Gopro *.360 format #12

Open
smathermather opened this issue Nov 20, 2021 · 1 comment
Open

Add parsing for Gopro *.360 format #12

smathermather opened this issue Nov 20, 2021 · 1 comment

Comments

@smathermather
Copy link
Contributor

GoPRO .360 format is weird. Fortunately, David at Trekview did the homework in this 4 part series:
https://www.trekview.org/blog/2021/reverse-engineering-gopro-360-file-format-part-1/
https://www.trekview.org/blog/2021/reverse-engineering-gopro-360-file-format-part-2/
https://www.trekview.org/blog/2021/reverse-engineering-gopro-360-file-format-part-3/
https://www.trekview.org/blog/2021/reverse-engineering-gopro-360-file-format-part-4/

The TL;DR is that it is a cube format already, but split into 2 video channels, with some (36 pixels) overlap between the cube faces in order to allow for blending.
image

@smathermather
Copy link
Contributor Author

smathermather commented Nov 20, 2021

An easy way to solve this is with the imagemagick python API replicating (and modifying for resolution of our 1/2 resolution data) this bit of work from here:

# Track 1
# convert -crop 1376x1344+0+0 track0/img1.jpg pre_cubefaces/left_img1.jpg
convert -crop 688x672+0+0 track0/img1.jpg pre_cubefaces/left_img1.jpg

# convert -crop 1344x1344+1376+0 track0/img1.jpg final_cubefaces/forward_img1.jpg
convert -crop 672x672+688+0 track0/img1.jpg final_cubefaces/forward_img1.jpg

# convert -crop 1376x1344+2720+0 track0/img1.jpg pre_cubefaces/right_img1.jpg
convert -crop 688x672+1360+0 track0/img1.jpg pre_cubefaces/right_img1.jpg

# Track 2
# convert -crop 1376x1344+0+0 track1/img1.jpg -rotate pre_cubefaces/bottom_img1.jpg
convert -crop 688x672+0+0 track1/img1.jpg -rotate pre_cubefaces/bottom_img1.jpg

# convert -crop 1344x1344+1376+0 track1/img1.jpg -rotate final_cubefaces/back_img1.jpg
convert -crop 672x672+688+0 track1/img1.jpg -rotate final_cubefaces/back_img1.jpg

# convert -crop 1376x1344+2720+0 track1/img1.jpg pre_cubefaces/top_img1.jpg
convert -crop 688x672+1360+0 track1/img1.jpg pre_cubefaces/top_img1.jpg


# convert -crop 688x1344+0+0 pre_cubefaces/left_img1.jpg precut_cubefaces/left_l_img1.jpg
convert -crop 344x672+0+0 pre_cubefaces/left_img1.jpg precut_cubefaces/left_l_img1.jpg

# convert -crop 688x1344+688+0 pre_cubefaces/left_img1.jpg precut_cubefaces/left_r_img1.jpg
convert -crop 344x672+344+0 pre_cubefaces/left_img1.jpg precut_cubefaces/left_r_img1.jpg

#convert -size 1344x1344 xc:transparent PNG32:precut_cubefaces/left_l_r_img1.png
convert -size 672x672 xc:transparent PNG32:precut_cubefaces/left_l_r_img1.png

convert precut_cubefaces/left_l_r_img1.png precut_cubefaces/left_l_img1.jpg -geometry +0+0 -composite PNG32:precut_cubefaces/left_l_r_img1.png
convert precut_cubefaces/left_l_r_img1.png precut_cubefaces/left_r_img1.jpg -geometry +640+0 -composite PNG32:precut_cubefaces/left_l_r_img1.png

convert -size 672x672 xc:transparent PNG32:precut_cubefaces/left_l_r_img1.png
convert precut_cubefaces/left_l_r_img1.png precut_cubefaces/left_l_img1.jpg -geometry +0+0 -composite PNG32:precut_cubefaces/left_l_r_img1.png

#convert precut_cubefaces/left_l_r_img1.png precut_cubefaces/left_r_img1.jpg -geometry +640+0 -composite PNG32:precut_cubefaces/left_l_r_img1.png
convert precut_cubefaces/left_l_r_img1.png precut_cubefaces/left_r_img1.jpg -geometry +320+0 -composite PNG32:precut_cubefaces/left_l_r_img1.png

###################################
# We don't need the rest of these steps...  #
###################################

##############################################
# But we do need the missing alpha compositing step...  #
##############################################



# convert -size 4032x2688 xc:transparent PNG32:img1_cubemap.png
convert -size 2016x1344 xc:transparent PNG32:img1_cubemap.png

# top row
convert img1_cubemap.png pre_cubefaces/left_img1.jpg -geometry +0+0 -composite PNG32:img1_cubemap.png
convert img1_cubemap.png cubefaces/forward_img1.jpg -geometry +1344+0 -composite PNG32:img1_cubemap.png
convert img1_cubemap.png cubefaces/right_img1.jpg -geometry +2688+0 -composite PNG32:img1_cubemap.png
# bottom row
convert img1_cubemap.png cubefaces/bottom_img1.jpg -geometry +0+1344 -composite PNG32:img1_cubemap.png
convert img1_cubemap.png cubefaces/back_img1.jpg -geometry +1344+1344 -composite PNG32:img1_cubemap.png
convert img1_cubemap.png cubefaces/top_img1.jpg -geometry +2688+1344 -composite PNG32:img1_cubemap.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant