Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Jan Ozer
www.streaminglearningcenter.com
jozer@mindspring.com/
276-238-9135
Agenda
z Generic encoding concepts
z Understanding H.264 encoding parameters
z Producing H.264 video for computers and devices
z Comparing the H.264 codecs
z Settings for common encoders
z Bonus subject: Producing for YouTube
1
Generic Encoding Parameters
z Terms and techniques
z Constant and variable bit rate encoding
z Delivery options
z Streaming
z Progressive download
z Multiple data rate delivery
300 kbps
2
Constant vs Variable Bit Rate
z Constant Bit Rate (CBR)
z One bit rate applied to entire video,
irrespective of content
z Pros: Easy and fast
z Cons: Doesnt optimize quality
3
When Should I Use VBR/CBR?
z Consider VBR when:
z Clips are longer than 60 seconds too short, no
difference
z Producing for progressive download
4
How do I Produce the Best
Quality CBR?
5
Delivery options
z Delivery options
z Streaming
z Progressive download
z Adaptive bitrate streaming
z HTTP vs. proprietary
Defining streaming
z What people think it is
z Video that plays immediately when you click and
smoothly to the end
z What it really is
z Video distributed via a streaming server
z May or may not be cached locally
z Whats a streaming server?
z Software other than web server dedicated solely
to distributing streaming video
z Flash Media Server, Wowza Media Server
6
Defining Progressive Download
z What people think it is
z trailers that take hours to download but then play
smoothly because theyre cached on your hard
drive.
z What it really is
z Video distributed from a web server rather than a
streaming server
z Video is typically stored locally (as in
progressively downloaded to hard drive)
z Most internet video is distributed via progressive
download (YouTube, ESPN, CNN, etc)
7
Delivery Mode Key Points
z If progressive
z May be some specific encoding requirements
(Fast Start for QuickTime, MOOV atom for Flash
z Produce at streaming rates to ensure responsive
user experience (most web sites)
z Or, produce at higher bit rates to ensure high
quality video
z Movie trailer scenario
z Usually encode with variable bit rate encoding (for
best quality)
Considering a Streaming
Server?
Pros Cons
z More secure stream z Cost
(not cached)
z Complexity
z Bandwidth negotiation
(dynamic streaming)
z Enables DRM
z More efficient
streaming (video doled
out rather than burst)
z Better statistics
8
Adaptive Bitrate Streaming
H.264
z Concept
z Customize file for viewer device and bandwidth
z Adapt to changing conditions
z Requires some intelligent component (server or player)
z Multiple options
z Adobes Dynamic Streaming (RTMP)
z Move Networks Adaptive Streaming (HTTP)
z Microsofts Smooth Streaming (HTTP)
z Apples HTTP Live Streaming
z H.264 Scalable Video Coding - HTTP (not here yet)
z Adobe HTTP streaming
9
HTTP Pros and Cons
z Pros: z Cons
z Fewer firewall issues z Less secure (cached
z Takes advantage of local locally)
caching z Initially less featured than
z More efficient, so s/b RTMP/RTSP
cheaper z Pause, seek, replay
10
Availability
z Dynamic Streaming
z Now (VP6 and H.264)
z Smooth Streaming
z Now Silverlight 3 player (for H.264 compatibility)
z Adaptive Streaming (Move)
z VP6/7 today, H.264 coming
z Apple Live Streaming (primarily relevant for iPhone)
z Now
z HTTP to Flash
z First half of 2010
z Scalable Video Coding
z Down the road (1-2 years out)
About H.264
z Introduction to H.264
z Basic H.264 encoding parameters
z Producing H.264 for computer playback
z Producing H.264 for devices
z Comparing the H.264 encoders
z Producing H.264
11
What is H.264?
12
H.264 Royalties Free TV
z One of two royalty options:
z (i) a one-time payment of $2,500 per AVC
transmission encoder (for each AVC encoder
used by Licensee in transmitting AVC video or
z (ii) annual fee per Broadcast Market
z $2.5K/year/market - 100K - 500K households,
z $5K/year/market - 500K 1M households
z $10K/year/market 1 M+
Impact
z Internet unique views of all H.264 video
z If under 100K, probably no royalty
z If > 100K, probably royalty
z Different internet sites might generate royalty
obligation
z Pod casts are definitely covered
z Intranet same deal, separate market
z If under 100K, probably no royalty
z If > 100K, probably royalty
z Either way:
z VC-1 same structure (and duplicative)
13
What is an MP4 file (and what
are the variants)?
14
Whats the Point?
z Typical encoding tool
gives you several H.264
encoding options
z Here we explain these
options, so you can
understand how to set
them later
15
What are H.264 Profiles?
z Define a set of coding tools or algorithms
that can be used in generating a bitstream
Which Profile?
16
Which Profile?
z Critical to know your target profile before
encoding
z Device - iPod/iPhone - Always Baseline
z Computer playback - typically High
z QuickTime
z Flash - should be compatible with all relevant
profiles
z Silverlight ditto
z As youll see YouTubes 720p H264
implementation uses the High Profile
17
H.264 Levels
z Primarily an issue when encoding for devices
z Must ensure that encoding parameters are within target
level (most templates do this); otherwise video wont play.
z For computer playback,
z All H.264 players can play ALL levels of ALL supported
profiles so not a playback-related issue
z The major concern is the playback performance of viewers
computer, not the level
z If level too low for selected encoding
parameters, just raise the level (Episode
does this automatically) to equal or
exceed parameters
Entropy Encoding
18
CABAC vs CAVLC Quality
CABAC vs CAVLC
Performance
Playback 720p files CABAC CAVLC
19
Reality Check - YouTube 720P
z High Profile
z CABAC
z 2 B-frames (not shown
in chart from another
analysis tool)
z 3 Reference frames
(ditto)
20
Deep Dive into H.264
Parameters
z Caveats:
z Presented differently by each encoding tool
z Only have time to cover most critical parameters
z To understand your encoder
z Read manual/help file to understand parameters
and their trade-offs; generally
z Encoding time vs. quality
z Complexity (and maybe encoding time) vs. quality
z Use MainConcept's reference encoder to
illustrate
General Options
z Frame coding
(progressive)
z Key frame interval
z 300
z Scene change
detection
z Bitrate
z CBR
z Insert data rate
21
What are I, B and P Frames?
z I-Frame - encoded
without reference to
other frames (also
called Key Frames)
z P - looks backward to
I and P frames
(predictive)
z B - looks forward and backward to previous I and P
frames (Bi-directional interpolated)
z No frames refer to B-Frame (most of the time)
22
What do I Need to Know About B
Frames?
z The most efficient frame
z So improves quality (comparisons to come)
z Hardest to decode
z Decoder has to have all referenced frames
in memory to decode B-frame
z Frame usually delivered out of order, which
also complicates playback
B-frames - Yes/No
23
B-frames - Yes/No
B-frames - Yes/No
z Noticeable quality improvement
z 5-10% increase in decompression CPU load
z Recommend
z Say YES to B-frames
z 2-3 is a good number for real world video
z Experiment with higher numbers with animations
24
Typical B-Frame Encoding
Parameters
Stream Structure
z B-Slices as references?
z Use B-frames as references for
B&P frames
z Also called B-frame pyramidwhen
enabled as reference for B-frames
z Impact
z Potential quality improvement (more
redundancies)
z Potential increase in encoding time
z Potential increase in decode
complexity (more frames in RAM)
25
More B-frame Options
z Adaptive B-frame placement
z Overrides B-frame quantity
when necessary to improve
quality
z Like scene change
z Always enable
z Separate presentation of
Reference B-Pictures and
Pyramid B-frame encoding
z Never got cohesive explanation
z Say yes for max quality
Stream Structure
z Multiple Slices
z Divides image up into slices
z Benefit
z May speed encode on MP
systems
z May speed decode on MP
systems
z Downside
z May limit quality because limits
searches within slices
z My take generally 1 or 0
(depending upon the tool)
26
Search/Prediction Related
z In general, these manage the
trade-off between search
accuracy (and quality) and
search time
z Can improve quality
z Minimal (if any) impact on
required decompression
Search Shape
z Search shape is the size of
the macro block used for
searching redundancies
z 8x8 is slower but more
accurate than 16x16,
potentially delivering better
quality
z Use 8x8 unless in a huge
hurry
27
Sub-pixel Mode
z Sub-pixel mode
z Dictates depth of search
shape
z Full is faster but less accurate
z Quarter is slower but may
improve quality
z Use Quarter unless in a real
hurry
28
Other Search-Related Options
z Rate distortion manages
quality/data rate trade-off
z Fast - heuristic optimization
thats faster, but can cause
quality loss
z Complex is slower, with better
quality
z Fast Intra/Inter Decisions
z Speed/quality trade-offs in
decision metrics
29
Hadamard Transformation
Deblocking Filter/Other
z Deblocking filter
z Minimizes blockiness, but extends encoding time and can
slow decompression
z Recommend - always enable (assume on by default with tools
that dont show this option)
z Encoding Speed vs. quality
z How encoder vendors combine multiple options into one
slider
z Varies by encoder/codec
30
H.264 Encoding Summary
z Profiles/Levels
- dictated by target
z Entropy Encoding - typically
CABAC
z Not available for Baseline
z B-frames - Use when available
z Not available for Baseline
31
Flash and H.264
z Flash Player 9 Update 3 contained:
z Software H.264 decoder (Baseline/Main/High profiles)
z Not DivX, H.263 or Sorenson
z AAC decoder
z No special encoding requirements for the Flash Media
Server
z Flash player can play mp4, m4v, m4a, mov and .3gp
files
z Evolving best practice - FLV for VP6 and F4V for H.264
32
Producing for Silverlight 3
z File requirements
z Self-contained .mp4 (including .f4v and .m4a) and
.mov file formats
z Simple, Main, and High 4:2:0 profiles (progressive
only)
z AAC-LC audio mono or stereo (HE AAC will play back
with lower fidelity, as in QuickTime)
z Local files or http progressive download.
z Or, sliced another way, Silverlight 3 will play
pretty much all MPEG-4 files that would play
back well in both QuickTime and Flash.
http://blogs.iis.net/benwagg/archive/2009/03/18/silverlight-3-beta-what-s-new-for-media.aspx
33
H.264 Playback - SD File
34
H.264 Playback 1080p File
35
My Take on H.264 Quality
z H.264 produces better quality than VP6 or
VC-1
z If converting from either codec, you can use
the same encoding parameters with:
z No loss in quality
z No increase in required CPU on playback station
36
Bits Per Pixel
z In general
z .1 or lower should be fine
z .15 is very conservative; beyond that is a waste
z The larger the resolution, the lower you can go
z .1 @ 320x240 could be dicey
z .1 @ 720p should be fine
z Formula
z Data rate / (pixels x frame rate)
mediainfo.sourceforge.net/en
37
Producing for Computers
z Mind your format specific parameters
z Choose profile, resolution and other
parameters that ensure smooth playback on
your target
z Or, offer multiple files and let viewer decide which
to download
z In general, if youre converting over from another
codec, H.264 will be similar in quality and required
playback horsepower to other codecs
38
iPod Specs
Original iPod iPod Nano iPod Classic iPod Touch/
(pre-5g) iPhone
Device resolution 320x240 320x240 320x240 480x320
Aspect Ratio 4:3 4:3 4:3 16:9-ish
Video codec H.264 H.264 H.264 H.264
Data rate 768 kbps 2.5 Mbps 2.5 Mbps 2.5 Mbps
Resolution 320x240 640x480 640x480 640x480
Frame rate 30 fps 30 fps 30 fps 30 fps
Profile Baseline Profile Baseline Profile Baseline Profile Baseline Profile
to Level 1.3 up to Level 3.0 up to Level 3.0 up to Level 3.0
Audio codec AAC-LC AAC-LC AAC-LC AAC-LC
Data rate 160 kbps 160 kbps 160 kbps 160 kbps
Audio parameters 48 kHz, stereo 48 kHz, stereo 48 kHz, stereo 48 kHz, stereo
Formats m4v/mp4/mov m4v/mp4/mov m4v/mp4/mov m4v/mp4/mov
39
Encoding Parameters - Video
Size Frame Codec Aspect Data Rate Extension Key
Rate H.264/ 4:3/ 16:9 mov/m4v/mp4 Frame
MPEG-4
Small 320x240 4 - 15f 22/2 20/5 (2 605K average 2/13/10 94 average
(25/44) 21 - 30f letterbox)
Large 640x360+ 1-15f 18/1 13/6 1.281 mbps 2/11/5 121 average
(19/44) 4-24f average
14-30f
low - 813K low - 32
hi - 2 mbps hi - 300
40
Errors that Prevented
Playback
z Main or High Profile - 5
z Exceed data rate - 4 (high of 6.5 mbps)
z Exceed resolution - 2
41
Center-Cut - Screencam
Oprah - logo cut off, but shot with 4:3 safe zones
42
When Producing 16:9 Video
z Shoot for center cut display (like Oprah)
z Or, instruct viewers to change default
playback parameters from center cut to
letterbox
z Videos > Settings > Fit to Screen > Off
Recommended Encoding
Parameters
320x240 640x4801
1 From Compressor
43
Comparing the H.264 Codecs
z Test description
z Apple, Dicas (Episode Pro), Main Concept
(Carbon Coder/Squeeze)
z Two files
z SD - 640x480@30 fps, 468/32, 2-pass VBR, highest
supported profile/quality options
z HD - 1280x720@30 fps, 800/128, 2-pass VBR,
highest supported profile/quality options
Test Description
z Still image quality
z Grab frames and compare
z Motion quality
z Compare quality during real time playback
z Look for motion artifacts like banding and
mosquitoes
z Smoothness
z Whether codec/encoder dropped frames at
selected parameters
44
HD Samples
HD Samples
45
HD Samples
HD Test Results
Still Quality 3 2 1
Motion Quality 2 1 1
Smoothness 1 1 1
Total 6 4 3
46
HD Test Analysis
z Difference between Dicas and Main Concept
is commercially irrelevant
z Viewers wouldnt notice absent side--by-side
comps (which, of course, they never have)
z Apples is much more significant
z Avoid if seeking highest quality at lowest bitrate
z At about 2.5 mbps, the quality is nearly the
equivalent of the others
SD Comparisons
z Still
z Motion
z Results
z Summary
47
SD Samples
SD Samples
48
SD Samples
z As does skating
SD Test Results
Still Quality 2 1 1 1
Motion Quality 2 1 1 1
Smoothness 1 1 1 1
Total 6 3 3 3
49
SD Test Analysis
z No meaningful difference between Dicas and
Main Concept in SD clips
z Apple again lagging
z Though fine for low volume SD production where
data rate isnt critical
50
Settings for Common
Encoders
z Apple Compressor
z Adobe Media Encoder CS3
z Sorenson Squeeze
z Telestream Episode Pro
z Inlet Fathom
Apple Compressor -
Compression Settings
Compression Type:
Choose codec here
Key Frames:
-Choose Automatic to
select scene change
detection
Frame Reordering:
- Uncheck for Baseline
Profile
- Check for Main with 1 B
frame
51
Apple Compressor - Streaming
Related Settings
Streaming:
- None - disc based playback
- Fast start - Compressed
Header - web, no streaming
server
- Hinted Streaming: QuickTime
Streaming Server
Click here:
To open this:
Format:
- FLV/F4V for Flash
Format:
-- H.264 for devices
52
AME - QuickTime Video
Codec:
- H.264
53
AME - Device
Format:
- Choose H.264
Profile/Level:
Bitrate settings
54
AME - Device - Audio
Choose AAC:
Choose bitrate
55
AME - Flash - Format
Format:
-Choose FLV|FV4
Profile/Level:
Set to desired parameters
56
AME - Flash - Audio
Codec:
Choose AAC
z Template screen
z Format choices on
top
z Audio on the left
z Video on the right
57
Sorenson Squeeze - Basics
Format Constraints:
Stream Type:
- Hint or not hint
Codec:
Multiple H.264/MPEG-4
codecs; MainConcept is the
best (and the default in 5.0)
58
Sorenson Squeeze - H.264
controls
Profile:
- Baseline/Main/High
Interlace Mode:
-Progressive (field order
grays out)
Encoding Effort:
Next slide
B-frames:
3 maximum
Best: 63.23 to encode 1 minute file Fast: 48:34 to encode 1 minute file
59
Sorenson Squeeze
Audio Codec:
Other parameters:
As normal
Episode Pro
z Output format
z Video settings
z Audio settings
z Switch using
tabs atop the
Job Batch
Window
60
Episode - Output Format
z MP4 or MOV?
z Both play in QuickTime Player
z Both play in Flash Player
z MP4 plays in more devices (e.g.
Zune)
z Recommend MP4
Episode - General
Natural and forced
ten seconds recommended
Recommended
technique unless
streaming (CBR)
B-frames 2-3
recommended
61
Episode - Profile and Quality
Display aspect ratio
use 1:1
Profile (Main or High
unless device)
Encoding
Entropy Encoding speed
(CABAC unless - settings
device) over 50
generally
show little
Use 2-pass unless improvement
draft work -I use 90
Blu-ray or
set top options Auto level
62
Episode - Audio
Channels: Choose
Inlet Fathom
z Provides full
control over
virtually all H.264
parameters
z No abstraction,
so great ability to
customize
encoding
parameters
63
Rhozet Carbon Coder
z Same paradigm
z Direct access to
critical parameters
z Minimal
abstraction
64
YouTubes Delivery Options
z The problem - no docs
z What they are
z Upload requirements
65
Accessing HQ Mode
z Upload file with resolution of 480x360 or
higher
z Still 10 minute limit, which means max per second
data rate of 13 mbps
z New 1 GB limit for uploaded file
http://www.pcmag.com/article2/0,2817,2330990,00.asp
Accessing HD Mode
z Upload file with resolution of 720p
z Higher resolutions didnt convert to 720p
z Still 10 minute limit, which means max per second
data rate of 13 mbps
z New 1 GB limit for uploaded file
http://www.streaminglearningcenter.com/articles/18/1/YouTube-does-720P-HD-using-H264/Page1.html
66
Questions?
z Thanks for coming
67