posts:One-off_Git_daemon: Add post describing ad-hoc usage
[blog.git] / posts / video.mdwn
1 [[!meta  title="Video encoding for the web"]]
2
3 According to [Mark Pilgrim][MP], video embedded in the following
4 manner should work for Firefox 3.5+ and Opera 10.5+ (playing the ogg
5 movie), Safari, iPhones, and Androids (playing the mp4 movie), and
6 Chrome 4+ playing either one.  If you're not running one of those
7 browsers, you can download the video an extermal player (like
8 [VLC][]).
9
10 My digital camera takes movies in
11
12 * Container: mov,mp4,m4a,3gp,3g2,mj2
13 * Video: mjpeg, yuvj420p, 640x480, 10422 kb/s, 30 tbr, 30 tbn, 30 tbc
14 * Audio: pcm_u8, 8000 Hz, 1 channels, s16, 64 kb/s
15
16 Encode your movie with something like (tagging flags removed)
17
18     ffmpeg2theora --endtime 120 --optimize movie.mov
19
20     ffmpeg -i movie.mov -t 120 -acodec libfaac -aq 200 -ac 1 -s
21         640x480 -vcodec libx264 -preset slower -vpre ipod640 -b 800k -bt
22         800k -aspect 640:480 -threads 0 movie.mp4
23
24 For `-vpre`, take a look in `/usr/share/ffmpeg/`, which usually
25 contains a bunch of pre-configured settings.  The parameters for
26 baseling H.264 [should be][H264]:
27
28 * H.264 Baseline: `avc1.42E0xx`, where xx is the AVC level
29 * Low-Complexity AAC: mp4a.40.2
30
31 The `slower` preset used to be a `vpre` file, but [became a `-preset`
32 option][preset-slower] 30 commits before the 0.7.1 release.  The
33 preset options came in [one commit eariler][preset], but this doesn't
34 seem to have percolated through to the `man` page yet.
35
36 You should use ffmpeg2theora v0.26 or greater, as v0.25 has
37 audio/visual syncing issues.
38
39 To embed the movie, include something like:
40
41     <video preloads="none" controls="controls" width="640" height="480">
42       <source src="movie.mp4"
43               type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />
44       <source src="movie.ogv"
45               type='video/ogg; codecs="theora,vorbis"' />
46       <p>Your browser does not support the &lt;video&gt; tag, try
47       downloading the video and playing it in an external player.
48       </p>
49       <img width="600" src="../2011.01.20.12.33.54.jpg" />
50     </video>
51     <p>Download as
52      <a href="movie.ogv">Ogg/Theora/Vorbis</a> or
53      <a href="movie.mp4">Mpeg4/H.264(ConstrainedBaselineProfile)/AAC</a>.
54     <p>
55
56 [MP]: http://diveintohtml5.org/video.html
57 [VLC]: http://www.videolan.org/vlc/
58 [H264]: http://wiki.whatwg.org/wiki/Video_type_parameters
59 [ipod]: http://rob.opendot.cl/index.php/useful-stuff/ipod-video-guide/
60 [preset-slower]: http://git.videolan.org/?p=ffmpeg.git;a=commit;h=14360e078326f482d5ae39fe4d2e6038118c95ed
61 [preset]: http://git.videolan.org/?p=ffmpeg.git;a=commit;h=0140d3f0921e5cbb6ea8706acb0307f7ff57a133