prev/next

Aspect Ratio

Why are my Vp6 Flix Engine dimensions off from what I requested?

The encoder that we choose for this particular encode will automagically change the dimension on your requested encode to the nearest multiple of 16 for both width and height. This is to give you the best possible results for viewing these particular flash files. 

The encoder that we choose for this particular encode will automagically change the dimension on your requested encode to the nearest multiple of 16 for both width and height. This is to give you the best possible results for viewing these particular flash files. 

<-- Hide
tools: email  |  print  |  share  |  click to rate (rated 1 time):
  • BlinkList
  • Del.icio.us
  • Digg
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • Newsvine
  • Reddit
  • Sphinn
  • Technorati
  • Twitter

Suggestions for improving quality with H.264 settings

Since users often will be uploading a wide variety of videos, I generally like to break them down into two types:

Static/Low Action - stable tripod shots, very little background movement, actors standing still 
Active/High Action - panning/jerky camera, lots of action, sports-like movement

A good starting point is to choose a variable bitrate setting equal

 More -->

Since users often will be uploading a wide variety of videos, I generally like to break them down into two types:

Static/Low Action - stable tripod shots, very little background movement, actors standing still 
Active/High Action - panning/jerky camera, lots of action, sports-like movement

A good starting point is to choose a variable bitrate setting equal to the width of the video. So, for example: 640x480 SD at 640 kilobits per sec (kbps), or 1280x720 HD at 1280 kbps. Higher action video may require a slightly higher bitrate to prevent blocking artifacts.

Noise Reduction

Applying some noise reduction is useful to save bits for high detail regions, but be careful not to overdo it. I've seen video samples where whole areas of ocean and grassy fields disappear to achieve a lower bitrate. This of course, falls under artistic preference, but generally I'd rather see a smaller framesize and more detail. At low bitrates, it is increasing important to improve the quality of noisy video sources, such as film containing lots of grain or video shot in low light. The 3D noise reduction in ffmpeg allows control over both luma and chroma values for fine-tuning your output image quality.

	<noise_reduction>4:3:6</noise_reduction> 

luma_spatial – Spatial Luma Strength. Allowed values: [0,255]
chroma_spatial – Spatial Chroma Strength. Allowed values: [0,255]
luma_temp – Temporal Luma Strength. Allowed values: [0,255]

General recommended starting value is 4:3:6. [luma_spatial:chroma_spatial:luma_temp] Noise reduction is also available via our web interface as the High Quality 3D Denoiser option.

 

Single Pass vs. Two Pass

For most purposes 2-pass encoding achieves very good results. It's a tradeoff of diminishing returns, 2-pass gaining perhaps 10% quality bit-for-bit but doubling the encoding time. Do not lower qcomp, CBR is horrible on quality. I'd experiment with values floating between 0.60 and 0.80 if you want more VBR. if qcomp = 1.00 then quantizer is constant for second pass. Real variable bitrate with constant quality. if qcomp = 0.00 then bitrate is constant for second pass. Real constant bitrate with variable quality.

<two_pass>yes</two_pass>

I'd recommend having two sample videos, tell your users to choose Low or High Action content setting, experiment a bit with your B-frames then define two "baseline" settings for each bitrate. For web video it's best to narrow your targets to four different bitrates at most, especially if you are going to be processing thousands of users uploading. Most folks have a slow (up to 240kbits), good (~700kbits), or fast (2mbits and higher) connection. I'd say H.264 over 2mbits is generally overkill for website content. For general purposes, I'd recommend 2-pass and we push a 10 second keyframe interval (300 frames) which may not be appropriate for "high-action" source video.

For more detail on H.264 controls for scenecut thresholds, B-frames, and more, please refer to:

Advanced H.264 Guide http://sites.google.com/site/linuxencoding/x264-ffmpeg-mapping

H.264 parameters for our API http://www.encoding.com/help/article/advanced_configuration_options_for_the_libx264_video_codec

An excellent collection of HD videos at 2mbits/sec can be found at http://californiaisaplace.com/cali/ 

 

16x16 Macroblocks

H.264/AVC does a much more efficient job when the horizontal and vertical framesize dimensions are multiples of 16. Good examples include:

SD (4:3) aspect ratios: 320x240, 432x320, 480x360, 544x400, 640x480, 768x576
HD (16:9) aspect ratios: 432x240, 576x320, 640x360, 720x400, 848x480, 1024x576, 1280x720, 1920x1080

In 4:2:0 H.264/AVC coding, each block contains 4 luminance samples (Y), 1 blue sample (Cb), and 1 red sample (Cr). Modern video decoding chips (GPUs) are optimized for playback of 16x16 macroblocking.

 

Keyframes and GOPs

Low action scenes generally handle more bidirectional (B-frames) better since they don't have to track interframe motion as aggressively. Higher action content will require more keyframes (I-frames) to keep the picture from breaking apart. Longer GOPs with more B-frames also require more buffering by the playback GPU to recursively track the motion for each macroblock. Fortunately, x264 offers very good scene detection, which is why for most applications, we set keyframes to 300.

H.264/AVC sample for modern mobiles (30 fps with a 10 second GOP)

	<framerate>30</framerate>
	<keyframe>300</keyframe>

For older computers, and early generations of iPod and Blackberry phones, the chips might not have enough processing power and memory to successfully buffer longer GOPs. Keep your bitrates low, try lower framerates, and shorter GOPs.

H.264/AVC sample for older mobiles (15 fps with a 4 second GOP)

	<framerate>15</framerate>
	<keyframe>60</keyframe>

More information about GOPs available on wiki http://en.wikipedia.org/wiki/Group_of_pictures

 

Turbo Mode

NOTE: For bigger or longer HD encoding jobs, turbo mode is absolutely recommended since you will see speed gains in the neighborhood of 3x faster vs. normal mode. Please be aware turbo is running on more powerful encoders, so it costs an extra $1 per gigabyte.

<turbo>yes</turbo>

 

<-- Hide
tools: email  |  print  |  share  |  click to rate (rated 10 times):
  • BlinkList
  • Del.icio.us
  • Digg
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • Newsvine
  • Reddit
  • Sphinn
  • Technorati
  • Twitter

How do I control Aspect Ratio?

In some cases you may need to encode a video with strictly defined width or height, while preserving the source video aspect ratio. We usually handle this automatically, with the keep aspect ratio option via our web UI or flagging it in XML

 <keep_aspect_ratio>yes</keep_aspect_ratio> 

If you turn it off, it will stretch the video image to fill

 More -->

In some cases you may need to encode a video with strictly defined width or height, while preserving the source video aspect ratio. We usually handle this automatically, with the keep aspect ratio option via our web UI or flagging it in XML

<keep_aspect_ratio>yes</keep_aspect_ratio>

If you turn it off, it will stretch the video image to fill whatever output framesize you have chosen. With it on, if source and output framesizes have different dimensions, it will letterbox or pillarbox the output. Apple has an excellent article that explains this at  http://support.apple.com/kb/HT2320

 

Floating Output Framesize

Let's say you know you want your video to exactly match your source aspect ratio but wish to lock the vertical resolution to 320 pixels. You can use a zero value to float the horizontal, using a value of 0x360 for the output size. The same can be done in reverse. If you used a value of 640x0, it would lock the width to 640 pixels wide and float the height of the output video.

<size>0x320</size><!--locking height to 320-->
<size>640x0</size><!--locking width to 640-->

 

Manual Override For Output Aspect Ratio

Setting correct aspect ratio is a big deal, since many broadcast formats use proprietary aspect ratio flags which often are not recognized by third-party systems. QuickTime flags like PAR (pixel aspect ratio) and DAR (display aspect ratio) have been the primary offenders, since most professional editing systems use various QuickTime codecs as their edit format. This setting allows you to lock the output aspect ratio to achieve the best results. NOTE: You will probably want to turn keep aspect ratio off, so you scale the entire video image.

In the web UI, choose a value for set aspect ratio as follows:

For NTSC Standard Definition, use 4:3 or 1.33
For HD or Widescreen Video, use 16:9 or 1.77

For XML to our API, these are good examples:

<set_aspect_ratio>4:3</set_aspect_ratio>
<set_aspect_ratio>1.33</set_aspect_ratio>
<set_aspect_ratio>16:9</set_aspect_ratio>
<set_aspect_ratio>1.77</set_aspect_ratio>
<keep_aspect_ratio>no</keep_aspect_ratio><!--OPTIONAL to prevent letterboxing-->

 

For more detailed information regarding aspect ratios, please see wiki at http://en.wikipedia.org/wiki/Aspect_ratio_%28image%29

<-- Hide
tools: email  |  print  |  share  |  click to rate (rated 3 times):
  • BlinkList
  • Del.icio.us
  • Digg
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • Newsvine
  • Reddit
  • Sphinn
  • Technorati
  • Twitter