Skip to content

Instantly share code, notes, and snippets.

@boblemarin
Last active November 5, 2021 11:26
Show Gist options
  • Save boblemarin/c4ff804eca72b577856957313ab9693b to your computer and use it in GitHub Desktop.
Save boblemarin/c4ff804eca72b577856957313ab9693b to your computer and use it in GitHub Desktop.

Workflow actuel :

Sur base d'un rendu en séquence de PNG, l'encodage se fait avec ffmpeg comme suit (30fps):
ffmpeg -framerate 30 -start_number 1 -i %4d.png -c:v libx265 -preset slow -crf 17 -vf "scale=4096x4096" -pix_fmt yuv420p -an -movflags faststart "encoded.mp4"

Ensuite, on fait boucler la vidéo pour avoir une longueur suffisante (ici 16 x)(pas de réencodage) :
ffmpeg -stream_loop 16 -i encoded.mp4 -c copy encoded-looped.mp4

Il suffit enfin d'injecter les métadonnées 360 à l'aide du soft Spatial Media Metadata Injector, ce qui crée le fichier final à injecter dans le casque.

Workflow expérimental pour avoir du son 360

1 : encode png sequence to mp4 video

ffmpeg -framerate 30 -start_number 1 -i %4d.png -c:v libx265 -preset slow -crf 17 -vf "scale=4096x4096" -pix_fmt yuv420p -an -movflags faststart "spatial-video.mp4"

2 : loop video stream (without re-encoding)

ffmpeg -stream_loop 10 -i spatial-video.mp4 -c copy spatial-video-looped.mp4

3 : convert audio to mp4

ffmpeg -i spatial-audio-still.wav -c:a aac -ac 4 -channel_layout 4.0 spatial-audio-still.mp4

4 : loop sound (without re-encoding)

ffmpeg -stream_loop 10 -i spatial-audio-still.mp4 -c copy spatial-audio-looped.mp4

5 : merge audio and video

ffmpeg -i spatial-video-looped.mp4 -i spatial-audio-looped.mp4 -c copy spatial-merged.mp4

Sources :

Official tech info, includes supported resolutions/framerates
https://creator.oculus.com/blog/encoding-high-resolution-360-and-180-video-for-oculus-go/?locale=fr_FR

FFMPEG Cheat sheet, includes some 360 related functions
https://www.vrtonung.de/en/ffmpeg-codes/

Encoding for Oculus Media Studio
http://echeng.com/articles/encoding-for-oculus-media-studio/

Blender exchange on the subject (looks promising)
https://blender.stackexchange.com/a/139874

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment