Encoding workflow with Handbrake

We’ve had many questions encoding panoramic videos for web publishing. VideoStitch H264 videos that are compatible for web streaming. But as a video stitching engine, it focuses on delivering the best quality output. Once your VideoStitch H264 video is encoded, you can process it to suit your exact needs!

Generally speaking, in a 360 video production workflow, it is preferable to export an high resolution video which preserves image quality, so that it can be recoded for specific publication requirements, or used for further post production. In this tutorial, we will cover using Handbrake to recode VideoStitch output for the web.

Handbrake is a great open source utility that can perform quality encoding in batch. It offers a nice range of presets, queue management, preview facility, allows to fine tune pretty much any coding parameters, and leverage the same encoding engine that’s used by Youtube, Vimeo and others.

We will assume that we using VideoStitch output, stitched at 3840×1920 and 47.952 fps with a bitrate of 75Mbps, and see how to use handbrake to recode it into a 1920×960 video at 23.976 fps ready for publishing on a web server.


handbrake workflow 1


1. Import the videos to recode.

Multiple videos can be imported at once, then selected in the source title ‘combobox’. The chapter option can be ignored, it is usefull only when a source file already contains chapters (eg : DVD/Blu-ray).

2. Set the output file location and name

We can set *.mp4 file extension as the default, and a default output folder can be defined in Handbrake’s preferences : ‘Edit>Options … ‘

3. Chose a preset

Handbrake comes with presets providing typical configurations for H264 encoding. H264 is the de facto standard encoding for web and portable devices. Hence most videos are based on H264 encoding to ensure both the best interoperability and the best quality.

There are presets available for iOS and Android devices compatibility. The ‘Normal’ and ‘High’ presets provide default settings for H264 ‘Main’ and ‘High’ profile.

When chosing a preset, the ouput size, H264 encoding profile and level are set automatically.

4. Enable “Web optimized”

The ‘web optimized’ option ensures that metadata containing informations about the stream are available in the video file header. This is mandatory for http progressive download. Large file size and iPod compatibility aren’t necessary for web publishing.

5. Set the ouput size

Generally speaking, when choosing a video size, it is best to stick with multiples of 16. In VideoStitch, we had chosen an output size that is both a multiple 16 and could be divided evenly to our publication target size.

Set the anamorphic options to ‘none’ and check ‘keep aspect ratio’ to preserve the original VideoStitch output appearance.

Anamorphic options are generally usefull to deal with aspect ratio and pixel aspect ratio (PAR) (eg: for DVD recoding).



We then switch to ‘video’ options to adjust the encoding parameters :

handbrake workflow 2


6. Framerate

Chose constant framerate to ensure a smooth streaming experience and avoid video/audio drift.

The framerate should not exceed 30 fps. When possible, the framerate from the original video should be preserved.

If the framerate has to be changed, a good rule of thumb is to divide it evenly.

For 29,97 fps we can preserve the original framerate. 47,952 fps VideoStitch output can be published with a framerate of 23,976 fps. 100 fps are best recoded to 25 fps.

7. Bitrate / Quality

Enable 2 pass encoding (slower encoding, but provides better results)

We want to use the ‘Average bitrate’ method and set a target bitrate. The « RF » slider is a way to adjust encoding for constant quality without controlling directly the bitrate.

Bitrate is the most critical parameter for web and device publishing. The appropriate bitrate to preserve image quality depends heavily on the motion and amount of detail in our video. But there is no standard or magic formula for our purpose since we also need to take download bandwidth in consideration.

2500 to 3000 Kbps is a good starting point for a 1920×960 video at 25fps.

For a static camera sequence with few motion, the same video could be encoded with as low as 2000 kbps. On a sport/action video, the bitrate should be increased to 3500 Kbps and more.

This bitrate suggestion favors download speed over image quality. In all cases, our target audience internet connection speed is the key and while a video encoded at 5Mbps ( 5000kbps ) or more may be streamed smoothly with the latest fiber optic or 4G mobile connection. A video encoded at 3Mbps ( 3000kbps ) may require buffering when streamed from an older broadband connection.

If we need to reach too high bitrates to preserve the visual quality of our video, the image size should be reduced.


8. Other video settings

x264 tunes are optionnal encoder filters presets.

H264 profiles refer to different coding methods of increasing complexity : Base, Main and High. ‘Base‘ is a simple encoding that results in larger files. ‘High‘ profile includes the most complex tools and thus the most efficient at reducing file size while preserving image quality, but requires more computing power. ‘Main‘ is a good balance between both.

H264 levels are a way to ensure compatibility by indicating decoding capabilities in terms of memory and bitrate. These should not need to be changed unless we target a specific device type. If we are in doubt, chosing auto ensures the most appropriate level to be set automatically.

A video encoded at a certain profile and level can be decoded by devices providing at least the same level of support for that profile. Flash player supports all H264 profiles. For optimal image quality and compression efficiency we can chose the ‘High’ profile preset.

9. Set the GOP size

Last but not least are the advanced settings, in particular a video encoding parameter called GOP.

GOP stands for ‘Group Of Pictures’. In video coding, a group of pictures is a set of successive ‘pictures’ that together allow generating the diplaid frames. A GOP is made of different types of interpolated frames ordered in specific ways depending on the encoder settings, but always starts with a reference frame.


The reference frame is an image that is stored completely (we can think of it as a jpg) and used to estimate other frames in the GOP. It uses significantly more data, increasing the output bitrate compared to the other image types.

When we increase the size of the GOP, the encoder will produce less reference frames, more interpolated frames, resulting in a smaller bitrate. This works especially well for long take videos, and clips that contain few scene changes.

We can override the default GOP size by adding the following parameters in the ‘extra options’ field :


  • keyint sets the desired GOP.
  • min-keyint sets the minimum GOP size. It should be greater than keyint*0,5 + 1.

With these settings, the encoder will set reference frames every 150 frames unless it detects significant scene changes, but will not create a reference frame if the GOP size hasn’t reached 76 frames.

If our video contains frequent scene changes, we can set min-keyint to a lower value, as low as 1 (in this case, every frame is a reference-frame).

A common setting for web publishing is to set GOP size to 3x that of the framerate, especially because reference frames are used for seeking in the video. If the ability to seek precisely in the video isn’t critical, and our video doesn’t contain sudden scene changes, the GOP size could be set up to 250 to enhance the video compression.


Render a preview

handbrake preview


Process, or enqueue multiple encodings

Finally, we can encode our videos by hitting either “start”, or “send to queue”.

Handbrake Queue

We can use the queue to encode again with different settings for different devices (eg: web, iPhone, iPad, Android), and process other videos.


That’s all there is too it. The recoded video is ready to be used on a web server, to be published with krpano or any other solution that uses http progressive download for video streaming. Keep in mind that Handbrake is a flexible encoding tool and is capable of much more than this simple tutorial covers.

We look forward to your feedback. Please feel free to ask Handbrake and video encoding related questions in our support forum, and we will get back to you !


Posted on October 8, 2013 by Nils Duval