Created
March 19, 2021 19:34
-
-
Save greg-randall/96562dcbbfe0c6820ada0eefb894fae8 to your computer and use it in GitHub Desktop.
For generating spinning videos from spherical panoramic images using pano2vr. Sample: https://www.youtube.com/watch?v=l_VrEJUUh64
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <pre><?php | |
| /* | |
| For generating spinning videos from spherical panos using pano2vr: | |
| https://www.youtube.com/watch?v=l_VrEJUUh64 | |
| Fill out the config below. | |
| Run the code, copy and paste the output into a file named "spin.p2vr" or similar. | |
| Make sure your input image is in the same location as your spin.p2vr file. | |
| Open the spin.p2vr file and then hit 'create all' at the bottom right. | |
| .... wait .... it'll probably take a while to generate all the images. | |
| Use ffmpeg or other video software to create a video from the frames. | |
| ffmpeg -i %04d.jpg -crf 17 spin.mp4 | |
| */ | |
| #config | |
| $input_file_name = "input_pano_equirectangular.jpg"; | |
| $resolution = 2000; | |
| $degree_step = 1; //will generate 360 frames when set to 1, which is a pretty smooth | |
| $jpeg_quality = 90; | |
| $leading_zeros = 4; | |
| echo htmlentities("<?xml version='1.0' encoding='utf-8'?> | |
| <!-- Pano2VR project file --> | |
| <pano2vrconfig> | |
| <panorama> | |
| <input> | |
| <patch/> | |
| <filename>$input_file_name</filename> | |
| <type>auto</type> | |
| <hfov>360</hfov> | |
| </input> | |
| <viewingparameter> | |
| <pan/> | |
| <tilt/> | |
| <fov/> | |
| </viewingparameter> | |
| <userdata/> | |
| <hotspots/> | |
| <output>"); | |
| $frame=0; | |
| for($i=0;$i<90;$i+=$degree_step){ | |
| echo htmlentities( generate_entry (0,$i,0,$frame,$resolution,$jpeg_quality,$leading_zeros) ); | |
| $frame++; | |
| } | |
| for($i=90;$i>-90;$i-=$degree_step){ | |
| echo htmlentities( generate_entry (180,$i,-180,$frame,$resolution,$jpeg_quality,$leading_zeros) ); | |
| $frame++; | |
| } | |
| for($i=-90;$i<0;$i+=$degree_step){ | |
| echo htmlentities( generate_entry (0,$i,0,$frame,$resolution,$jpeg_quality,$leading_zeros) ); | |
| $frame++; | |
| } | |
| echo htmlentities(" </output> | |
| <sounds/> | |
| </panorama> | |
| </pano2vrconfig>"); | |
| function zerofill($mStretch, $iLength = 2) | |
| { | |
| $sPrintfString = '%0' . (int)$iLength . 's'; | |
| return sprintf($sPrintfString, $mStretch); | |
| } | |
| function generate_entry ($pan,$tilt,$roll,$frame,$resolution,$jpeg_quality,$leading_zeros){ | |
| $output = "<thumb> | |
| <html> | |
| <enabled>0</enabled> | |
| <filename>output/p1_out.html</filename> | |
| <template>normal.ggt</template> | |
| <values> | |
| <value id=\"bgcolor\">#ffffff</value> | |
| <value id=\"showuserdata\">true</value> | |
| <value id=\"tablebgcolor\">#dddddd</value> | |
| <value id=\"tablebordercolor\">#777777</value> | |
| <value id=\"tabletextcolor\">#000000</value> | |
| <value id=\"textcolor\">#000000</value> | |
| </values> | |
| </html> | |
| <facequality/> | |
| <filename>spin/" . zerofill($frame,$leading_zeros) . ".jpg</filename> | |
| <backgroundColor>#000000,0</backgroundColor> | |
| <nooversampling>0</nooversampling> | |
| <type>mercator</type> | |
| <quality>$jpeg_quality</quality> | |
| <progressivejpeg>0</progressivejpeg> | |
| <width>$resolution</width> | |
| <height>$resolution</height> | |
| <defaultview>0</defaultview> | |
| <pan>$pan</pan> | |
| <tilt>$tilt</tilt> | |
| <roll>$roll</roll> | |
| <fov>70</fov> | |
| <cubefacenaming>_5</cubefacenaming> | |
| </thumb> | |
| "; | |
| return($output); | |
| } | |
| ?></pre> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment