Creating and Using WebM Videos for Online Mathematics Courses
Table of Contents
1 Information
1.1 Contact Information
- Scott Randby
- The University of Akron
- srandby@uakron.edu
1.2 Web Site Information
2 Introduction
2.1 The WebM container format
- WebM is a video container format that was designed for web videos.
- The WebM container format is an open and royalty-free format released under a BSD license.
- The WebM file structure is based on the Matroska container format. A container holds the various streams make up a video.
- Video streams are encoded with the VP8 video codec.
- Audio streams are encoded with the Vorbis audio codec.
- A codec is a program that can encode or decode a digital stream of data.
- When a WebM video is viewed, the program playing the video decodes the audio and video streams using the VP8 and Vorbis codecs.
- http://www.webmproject.org/
- http://www.webmproject.org/about/
- http://www.webmproject.org/about/faq/
- http://www.webmproject.org/about/faq/#licensing
- http://www.webmproject.org/license/
- http://www.webmproject.org/license/software/
- http://www.webmproject.org/license/bitstream/
- http://www.webmproject.org/license/additional/
2.2 Why use the WebM format for videos?
- WebM videos may be played in browsers that support the HTML5
<video>
tag and the WebM format. - Firefox, Google Chrome, and Opera all support the WebM format.
- It is easy to post WebM videos on any website using the
<video>
tag.- There is no need to use a special service like YouTube in order to post a WebM video.
- It is easy for a viewer to download a WebM video.
- Adobe Flash and special plugins are not required by viewers of a WebM video.
- The WebM format is open and royalty-free.
2.3 Software
- FFmpeg may be used to do the following:
- capture a desktop video stream and encode it using the H.264/MPEG-4 AVC codec,
- capture an audio stream and encode it using the Vorbis codec,
- re-encode a video stream using the VP8 codec, and
- bundle a VP8 encoded video stream and a Vorbis encoded audio stream into a WebM container.
- FFmpeg is a versatile program that contains a huge number of features for recording, converting, and streaming audio and video.
- Xournal journaling software may be used to write the notes that appear in a video.
- There are numerous other programs that may be used in a video. For instance, Sage may be used for demonstrations.
- The program
mkvmerge
may be used to edit a video.- http://www.bunkus.org/videotools/mkvtoolnix/
- The GUI interface is
mmg
.
3 FFmpeg and MKVToolNix
3.1 Compile FFmpeg
- Follow the instructions given at https://trac.ffmpeg.org/wiki/UbuntuCompilationGuide.
- Install autoconf,
automake
,build-essential
,libtool
,libx11-dev
,libxext-dev
,libxfixes-dev
,pkg-config
,texi2html
, andzlib1g-dev
if they aren't already installed.- These packages are necessary in order to build FFmpeg.
- Install audio and video dependencies.
- The audio and video dependencies are
libass-dev
,libgpac-dev
,libsdl1.2-dev
,libtheora-dev
,libva-dev
,libvdpau-dev
, andlibvorbis-dev
. - Some of these packages may not be necessary for some setups.
- The library
libvorbis-dev
contains the Vorbis audio codec that must be used to encode audio streams for WebM videos.
- The audio and video dependencies are
- Install Yasm and
libx264
- Video captured from the desktop will be initially encoded using the H.264/MPEG-4 Advanced Video Codec. The
libx264
library contains that codec. - http://en.wikipedia.org/wiki/H.264/MPEG-4_AVC
- http://datatracker.ietf.org/doc/rfc6184/
- Video captured from the desktop will be initially encoded using the H.264/MPEG-4 Advanced Video Codec. The
- Install
libvpx
.- Video streams of WebM videos must be encoded by the VP8 codec. The
libvpx
library contains that codec.
- Video streams of WebM videos must be encoded by the VP8 codec. The
- Install FFmpeg.
- Make sure to enable
libvorbis
,libx264
,libvpx
,gpl
,nonfree
, andx11grab
. - Enabling the
x11grab
option permits grabbing of the x11 desktop.
- Make sure to enable
- Guides for other operating systems are given at https://trac.ffmpeg.org/wiki/CompilationGuide.
3.2 Install MKVToolNix editing tools
- http://www.bunkus.org/videotools/mkvtoolnix/downloads.html#ubuntu
- The package includes
mkvmerge
. - The purpose of these tools is to edit MKV videos.
4 Make an MKV video
4.1 The MKV container format
- The first step is to capture a high quality video stream and a high quality audio stream.
- Capturing and converting the video stream using the VP8 codec takes time and a lot of processing power. The first step will encode the video stream using the H.264/MPEG-4 AVC codec and the audio stream using the Vorbis codec, and the second step will re-encode the video stream using the VP8 codec and put both streams into a WebM container. The audio stream does not need to be re-encoded since WebM audio streams are encoded by the Vorbis codec.
- The captured video and audio streams are bundled together in an MKV file.
- MKV videos use the Matroska multimedia container standard. This is an open and free container format that is used to hold video, audio, and subtitle tracks.
- The video stream is encoded using the Advanced Video Codec (AVC) otherwise known as H.264/MPEG-4 AVC.
- The audio stream is encoded using the Vorbis codec.
- http://www.matroska.org/
- http://www.matroska.org/technical/whatis/index.html
- http://corecodec.com/products/matroska
4.2 The video capture command
ffmpeg -f x11grab -s 1366x768 -r 24 -i :0.0 -f alsa -i pulse -acodec libvorbis -vcodec libx264 -g 24 out.mkv
4.3 Video stream
-f x11grab -s 1366x768 -r 24 -i :0.0
- This portion sets up the video input.
-f
is "force input file format."- x11grab: Grab the X11 display with ffmpeg.
-s
is "set frame size"- Change the frame size to the size of the screen. My screen size is 1366x768.
-r
is "set frame rate" in frames per second.- The standard frame rate is 24 frames per second. Lower frame rates make smaller videos of lesser quality.
-i
is "input file."- 0.0 is display.screen number of the X11 server, it is the same as the DISPLAY environment variable.
- The X11 display will be used as the video input stream.
- Check the value of the DISPLAY variable:
echo $DISPLAY
4.4 Audio stream
-f alsa -i pulse
- This portion sets up the audio input
-f alsa
- Forces ffmpeg to use ALSA (the Advanced Linux Sound Architecture) for the audio source.
-i pulse
- Use the output from the PulseAudio sound server as the audio input stream.
4.5 Audio encoding
-acodec libvorbis
- Set the audio codec to use to encode the audio input.
- The audio of a WebM file is encoded with the Vorbis audio codec (ogg format).
4.6 Video encoding
-vcodec libx264
- Set the video codec used to encode the video input.
- The video stream is encoded using the Advanced Video Codec (AVC) otherwise known as H.264/MPEG-4 AVC.
4.7 Keyframes
-g 24
- Sets the keyframe interval at the standard rate of 24 frames per second.
- A keyframe is a frame of a video that contains all of the data necessary for that frame. Frames that are not keyframes borrow data from the nearest keyframe when the frame is displayed.
- Low keyframe rates make smaller video files but also degrade the quality of the video and make searching the video more difficult.
5 Editing
5.1 Edit the MKV video
- The GUI interface to
mkvmerge
(mmg
) may be used to edit an MKV video by splitting and merging. - Use Kdenlive for more sophisticated editing.
6 Conversion
6.1 Convert the MKV video to WebM
- The second step is to encode the captured audio and video streams using the VP8 and Vorbis codecs and then put them into a WebM container. Actually, the audio stream was encoded using the Vorbis codec when it was captured.
- We will use a 2-pass encoding process.
- In pass 1, the statistics of the video are written to a log file.
- The audio may be deactivated during pass 1.
- The -an option disables audio recording
- The libvpx library contains the VP8 codec used to encode the video stream.
- In pass 2, the log file is used to generate the video at the requested bitrate.
- Video bitrate
- The video bitrate is the amount of data in one second of video.
-b:v 1000k
- Sets the video bitrate at 1000k per second.
- Change the bitrate to control the size/quality tradeoff.
- What does bitrate mean?
- What bitrate should a video use?
- What is bitrate?
- Understanding video bitrates
6.2 The conversion process
cd
to the proper folder.- Pass 1:
ffmpeg -i input.mkv -an -vcodec libvpx -b:v 1000k -pass 1 output.webm
- Pass 2:
ffmpeg -i input.mkv -vcodec libvpx -b:v 1000k -pass 2 output.webm
7 Posting
7.1 Posting the WebM video
- The following HTML code may be used to embed a video on a webpage.
<video id="lesson-video-tag" src="video.webm" controls preload="metadata"> Your browser does not support the <code>video</code> tag. </video>
- The
controls
option shows the playback and other controls. - Most up-to-date browsers support the
<video>
tag. - Firefox, Google Chrome, and Opera support the WebM format.
- Sample WebM video post