Creating high quality video is a combination of art and science. Learn the tips from the pros on how to optimize video compression to deliver the best quality at the smallest sizes with Expression Media Encoder, a feature of Microsoft Expression Media.
3. Video and audio in WPF/E
Best practices for processing video and audio
Best practices for Windows Media encoding for WPF/E
Using the Expression Media Encoder
4. It's just Windows Media!
Huge library of existing content already compatible
Existing URLs from Windows Media Services still work
Already supported by many hosting companies
Lots of tools available for different markets
Video codec;
Windows Media Video 7/8/9 and 9 Advanced Profile
Audio codec:
Windows Media Audio quot;Standardquot;
Not Pro, Voice, or Lossless in this version
6. Higher quality video and audio
Fewer bits needed for same quality
Much faster encoding
3x faster for optimum quality on 4-core workstation
15x faster with Tarari card for hardware acceleration
Much better TCO for video hosting
Many more streams off a 2K3 Server than Flash server
Cheaper per GB charges from hosting providers
Mature live streaming/encoding tools
7. Capture
Getting the content in higher quality
Preprocessing
Optimizing the content for the codec itself
8. Capture native bitstream or uncompressed
DV, DVCPRO HD as native bitstream
Other formats as uncompressed
Don’t use DV bridge for analog-digital conversion
DV codec throws out a lot of image data, especially color
Access earliest generation dub as possible
Most VHS tapes didn’t get posted on VHS!
Ripping from DVD also sub-optimal
Best to grab digital export from NLE
9. Everything we do to the video and audio between the
source and the codec
The biggest single factor in good-looking WPF/E video
The best the codec can do is give back what you gave it
For challenging projets, I spend ~80% of my keyboard-
and-mouse time on preprocessing
Once the codec settings are nailed, you're good to go.
10.
11.
12.
13.
14. WPF/E uses progressive video
For 60i/50i, deinterlace to progressive
For video telecined from film, use inverse telecine to restore
24p
If it’s progressive, leave it alone!
<example slide>
15. Video monitors don’t go to edges
Computers do
Crop edge blanking
Asymmetric okay to cut out noise
For low rez, crop to safe area
Crop letterboxing as well
If going to 16x16 resolution, can crop to final aspect ratio
For mixed video/computer playback, matte out noise in
blanking
16.
17. Brightness and Contrast
Computers have broader range — use it
Blacks should look identical to RGB=0,0,0 in browser
Noise Reduction
Make image easier for compressor
Remove grain
Smooth sharp edges
23. Two legitimate modes of delivering web video
Need to know which one will be used before encoding
Progressive should use 2-pass VBR
Streaming should use 2-pass CBR
24. Off a web server
E.g., IIS in Windows 2003 Server
Most efficient with Variable Bit Rate (VBR) encoding
Random access in part of stream already downloaded
Great for movie trailers
25. Files fromWindows Media Services
Included in Windows 2003 Server
Needs Constant Bit Rate (CBR) encoding
Offers random access throughout stream
Reduces need for local caching (big for mobile devices)
Great for movies
26. We measure rates in power-of-ten numbers
K=1000, not 1024
M=1000000, not 1048576
Streaming
Need more sustained bandwidth to user more than data rate
Progressive
A slower connection means user waits longer for playback
But can use high bitrates for short clips
27. WPF/E wants square pixel video
So need to convert to aspect ratio
Example
DV is 720x480
4:3 content becomes 640:480
16:9 content becomes 832x480
Depends somewhat on data rate
200-500 Kbps: 320x240 or 432x240
1-2 Mbps: 640x480 or 832x240
28. 1-pass versus 2-pass
1-pass reads the source in and encodes out at the same time
2-pass does analysis pass first, calculating optimal bit-budget
2-pass is always better if you've got the time
And it’s not 2x slower – the analysis pass runs quite a bit faster
CBR versus VBR
Constant Bitrate
Optimum for streaming – quality varies, bitrate constant
Variable Bitrate
Optimum for progressive download – varies bitrate, quality constant
29. Use frame rate that’s an integer division of source
59.94 to: 59.94, 29.97, 15, 10, 7.5, 6, 5
50 to: 50, 25, 12.5, 10, 5
24 to: 24, 12, 8, 6
For anything over 200 Kbps, can use full frame rate of
source
30. New compression tool targeting .WMV for WPF/E
Bunded with Expression Media Product
Accessible to both designers and video professionals
Offline and Live Encoding
But there's no secret sauce – you're welcome to use any
WMV encoding tool with WPF/E
31.
32. The codec has a bunch of registry key setting to further
optimize encoding
I fear regedit – you can use ―WMV9 PowerToy‖
Lots more options than I’ll discuss today
Link to full documentation at end
Tools will be integrating these controls later this year
34. Current codec can use up to four threads for encoding
Big speed improvement with multiple cores
Auto picks number of threads available
Sees HyperThreading (Pentium 4) as 2 processors
But HT is less of a gain with compression than additional core
Want to have at least 64 pixels high per thread
<128 height: 1-thread
<256 height (so 320x240): 2-threads
256+ height: 4-threads
35. Motion Estimation copies moving elements between
frames
Much more efficient to encode ―motion vector‖ than second
copy of element
Using a larger Motion Search range
Provides better efficiency with faster motion
Slows encoding
Can reduce efficiency with slower motion
36. Available Options:
Macroblock-adaptive
128 pixels horizontally, 64 pixels vertically (default)
256 pixels horizontally, 128 pixels vertically
1024 pixels horizontally, 256 pixels vertically
2056 pixels horizontally, 512 pixels vertically
Each progressive option slowest encoding by ~2x
Macroblock-adaptive slightly faster than 1024x256
Use Macroblock Adaptive for non-realtime encoding
37.
38.
39. Finds where color changes but B&W channel doesn’t
Quality improvements 5-20% (most with colorful content)
Crowd shots, motion graphics helped in particular
Modes:
Macroblock-adaptive with nearest integer chroma (fast, good)
Macroblock-adaptive with true chroma (speed/quality mix)
Luma only (default)
Luma with nearest-integer chroma
Luma with true chroma (best, slowest)
40. Number of bi-directional (B-Frames) between I-Frames
and P-Frames
B-Frames based off previous and next frame
B-Frames typically fewer bits for same quality
No frames are based on B-frame
Don’t insert I-frame for flashes if they land on a B-frame
So dynamically insert B-frames when there are flashes!
Big win for gunfights and discos
1 B-frame optimal for most web encoding
41.
42. Smooths out hard edge blocking artifacts
―In-loop‖ - used as prediction for future frames
Only blurs content where an artifact would appear
Much less noticeable at higher resolutions
Softness better if alternative is artifacts
Increased CPU decoder requirements somewhat
43. Softens edges where motion vectors overlap
Softens image somewhat
But reduces artifacts
Recommendation
On if you see artifacts
Otherwise Off
Also increases decoder complexity some
44. Denoises image before calculating motion vectors
Keeps grain/noise from ―swirling‖
Helps low-bitrate encodes
But can leave ―trails‖
Recommendation
Only use with grainy source, and QA carefully
45. Simple noise reduction filter
Helps when the source is noisy
Not as good as offline noise reducers
Recommendation
Good for realtime encoding in low light
But better to not have noisy source…
46. Blanks Line 21, other noise around edge of frame
Handy for real-time encoding of analog sources
Only use if source has edge noise
47. Specifies up to 16 frames forward for analysis
Only needed in 1-pass encoding
Used to detect scene changes, flash frames
Big improvement for 1-pass CBR encodes
Can dynamically insert B-frames with flashes
Default is Off (Does not look ahead)
Adds to latency for live encoding
~½ second for Lookahead=15 @ 29.97 fps
Slightly slows encoding as Lookahead increases
48. ―Differential Quantization‖
Different macroblocks are compressed different amounts
Compress gradients less, to reduce banding
Recommendation
I and P frames
Using on B-frames wastes bits that will be discarded
Lots of levels available
―Regular‖ good default with most content
49. Like DQuant, optimizes bits based on image
Used in addition to DQuant
Adaptive Dead Zone 1 good default for film content
Experiment carefully with other kinds of sources
50. Highest quality encoding and reasonable performance
Up to 4x slower than default settings
Encoder complexity = 4/80 (second slowest)
Motion Search Level = macroblock adaptive true chroma
Motion Search Range = macroblock adaptive
Motion Match Method = Adaptive SAD/Hadamard
DQuant = Regular
Perceptual Option = Adaptive Dead Zone 1 for film
Force LoopFilter = On
51. Optimized for reliable real-time encoding
Remember dual-duals are almost 4x faster than single core
Motion Search Range = Biggest that doesn’t drop frames
Motion Search Level = Luma + integer chroma
NumBFrames = 1
Force LoopFilter = 1 (on)
Dquant Option = Regular
Perceptual Option = Adaptive Dead Zone 1 for film
Lookahead = 16 (Max – most important single option)
52. 2-day instructor-led training in over 20 US cities
Tools and Technologies Used
Expression Blend and Expression Design
NET Framework 3.0, Windows Presentation Foundation, XAML
Visual Studio 2005
Target Audience
User interface designers with advanced experience with Flash or
Director. Understanding of Visual Studio 2005 or programming skills is not
required.
Prerequisites
Does not require prior experience using Expression Blend or Windows
Presentation Foundation.
We recommend:
Building an understanding of .NET Framework 3.0
Download Expression Blend http://www.microsoft.com/expression
Get inspired! www.seewindowsvista.com
Learn More: http://tinyurl.com/3y6jg7
53. Me:
Ben.Waggoner@microsoft.com
My blog:
http://on10.net/blogs/benwagg/
My class at Stanford
www.digitalmediaacademy.org/courses/video-compression-training.html