Today, I have read the blog of Praveen (http://www.j4v4m4n.in/2010/05/26/webm-support-for-fedora-13/) about how he added support for webm in Fedora13 (for ffmpeg). Though I heard about Google releasing VP8 codec as Free Software, I never thought of downloading a .webm file( What’s the use of it , if you can’t play it ). However, after downloading the ‘bigbrotherstate.webm” file from Praveen’s blog, I have tried to play it in my favorite media player, ‘mplayer’ and failed.
maxin@maxin-laptop:~$ mplayer /home/maxin/Downloads/bigbrotherstate.webm
MPlayer SVN-r29237-4.4.1 (C) 2000-2009 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.
Playing /home/maxin/Downloads/bigbrotherstate.webm.
Exiting… (End of file)
———————–
It’s all very well having latest o2 Mobile Broadband or a computer with a lightning fast processor, if your mplayer doesn’t work, none of that is quite as good. This is how I fixed my problem:
Then I started my night long effort by tinkering with the mplayer source and VP8 patches and finally made it working in Ubuntu Linux.
Mplayer playing the “bigbrotherstate.webm”

webm in mplayer
I have created a log file for this activity: Here it goes:
As per the project (http://www.webmproject.org/code/build-prerequisites/), the VP8 Codec SDK (libvpx) has build dependency on Yasm assember for optimized building on x86 (32 and 64 bit).
At first, get the Yasm assembler from (http://www.tortall.net/projects/yasm/wiki/Download)
wget http://www.tortall.net/projects/yasm/releases/yasm-1.0.1.tar.gz
tar zxvf yasm-1.0.1.tar.gz
cd yasm-1.0.1
./configure
make
sudo make install
Now, go for the libvpx and build it.We can download the libvpx source from webm project page:http://code.google.com/p/webm/
wget http://code.google.com/p/webm/downloads/detail?name=libvpx-0.9.0.tar.bz2
tar jxvf libvpx-0.9.0.tar.bz2
cd libvpx-0.9.0
./configure
make
sudo make install
There comes the mammoth task of downloading the patches for adding webm support to mplayer :mplayer-vp8-encdec-support-r1.tar.bz2
wget http://code.google.com/p/webm/downloads/detail?name=mplayer-vp8-encdec-support-r2.tar.bz2
tar jxvf mplayer-vp8-encdec-support-r1.tar.bz2
ls
allcodecs-register_VP8.diff
avcodec-AVCodecContext_add_VP8_specifics.diff
avcodec-minor_version_bump.diff
avcodec-VP8_CODEC_ID.diff
avformat-minor_version_bump.diff
ffmpeg-only
libavcodec-build_VP8.diff
libavcodec-new_options.diff
libvpxdec.diff
libvpxenc.diff
Makefile-avcodec-add_webm_demux.diff
Makefile-avformat-add_webm_demux.diff
matroska-add_V_VP8.diff
matroskadec-add_webm.diff
matroskaenc-add_webm.diff
mplayer-only
riff-VP80_fourcc.diff
Hmm.. a number of files to fight with
Anyways, get the latest mplayer source:
svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer
cd mplayer
patch -p1 <../../mplayer-vp8-encdec-support/libvpxdec.diff
patching file libvpxdec.c
Index: allcodecs.c
===================================================================
— allcodecs.c (revision 23341)
+++ allcodecs.c (working copy)
@@ -349,6 +349,7 @@
REGISTER_DECODER (LIBSPEEX, libspeex);
REGISTER_ENCODER (LIBTHEORA, libtheora);
REGISTER_ENCODER (LIBVORBIS, libvorbis);
+ REGISTER_ENCDEC (LIBVPX_VP8, libvpx_vp8);
REGISTER_DECODER (LIBVPX, libvpx);
REGISTER_ENCODER (LIBX264, libx264);
REGISTER_ENCODER (LIBXVID, libxvid);
maxin@maxin-laptop:~/Downloads/mplayer/svn/mplayer/libavcodec$ patch -p1 <../../../mplayer-vp8-encdec-support/libavcodec-new_options.diff
patching file options.c
maxin@maxin-laptop:~/Downloads/mplayer/svn/mplayer/libavcodec$ patch -p1 <../../../mplayer-vp8-encdec-support/libvpxenc.diff
patching file libvpxenc.c
maxin@maxin-laptop:~/Downloads/mplayer/svn/mplayer/libavcodec$ patch -p1 <../../../mplayer-vp8-encdec-support/libvpxenc.diff
patching file libvpxenc.c
maxin@maxin-laptop:~/Downloads/mplayer/svn/mplayer/libavcodec$ patch -p1 <../../../mplayer-vp8-encdec-support/Makefile-avcodec-add_webm_demux.diff
patching file Makefile
Hunk #1 succeeded at 512 with fuzz 1 (offset 14 lines).
maxin@maxin-laptop:~/Downloads/mplayer/svn/mplayer/libavformat$ patch -p1 <../../../mplayer-vp8-encdec-support/Makefile-avformat-add_webm_demux.diff
patching file Makefile
Hunk #1 succeeded at 257 (offset 2 lines).
maxin@maxin-laptop:~/Downloads/mplayer/svn/mplayer/libavformat$ patch -p1 <../../../mplayer-vp8-encdec-support/Makefile-avformat-add_webm_demux.diff
patching file Makefile
Hunk #1 succeeded at 257 (offset 2 lines).
Index: matroskadec.c
===================================================================
— matroskadec.c (revision 23341)
+++ matroskadec.c (working copy)
@@ -36,7 +36,9 @@
#include “isom.h”
#include “rm.h”
#include “matroska.h”
-#include “libavcodec/mpeg4audio.h”
+#if CONFIG_MATROSKA_DEMUXER
+ #include “libavcodec/mpeg4audio.h”
+#endif
#include “libavutil/intfloat_readwrite.h”
#include “libavutil/intreadwrite.h”
#include “libavutil/avstring.h”
@@ -824,7 +826,7 @@
/*
* Autodetecting…
*/
-static int matroska_probe(AVProbeData *p)
+static int ebml_probe(AVProbeData *p, const char probe_data[], const int probe_data_size)
{
uint64_t total = 0;
int len_mask = 0×80, size = 1, n = 1, i;
@@ -848,15 +850,13 @@
/* Does the probe data contain the whole header? */
if (p->buf_size < 4 + size + total)
return 0;
-
- /* The header should contain a known document type. For now,
- * we don’t parse the whole header but simply check for the
- * availability of that array of characters inside the header.
- * Not fully fool-proof, but good enough. */
- for (i = 0; i < FF_ARRAY_ELEMS(matroska_doctypes); i++) {
- int probelen = strlen(matroska_doctypes[i]);
- for (n = 4+size; n <= 4+size+total-probelen; n++)
- if (!memcmp(p->buf+n, matroska_doctypes[i], probelen))
+ /* The header must contain the document type from the demuxer
+ * specific probe function. For now, we don’t parse the whole
+ * header but simply check for the availability of that array
+ * of characters inside the header. Not fully fool-proof, but
+ * good enough. */
+ for (n = 4+size; n <= 4+size+total-(probe_data_size-1); n++)
+ if (!memcmp(p->buf+n, probe_data, probe_data_size-1))
return AVPROBE_SCORE_MAX;
}
@@ -864,6 +864,23 @@
return AVPROBE_SCORE_MAX/2;
}
+/*
+ * Autodetecting…
+ */
+static int matroska_probe(AVProbeData *p)
+{
+ static const char probe_data[] = “matroska”;
+ return ebml_probe(p, probe_data, sizeof(probe_data));
+}
+#if CONFIG_WEBM_DEMUXER
+static int webm_probe(AVProbeData *p)
+{
+ static const char probe_data[] = “webm”;
+ return ebml_probe(p, probe_data, sizeof(probe_data));
+}
+#endif
+
+
static MatroskaTrack *matroska_find_track_by_num(MatroskaDemuxContext *matroska,
int num)
{
@@ -1117,11 +1134,12 @@
static int matroska_aac_sri(int samplerate)
{
- int sri;
-
+ int sri = 0;
+#if CONFIG_MATROSKA_DEMUXER
for (sri=0; sri<FF_ARRAY_ELEMS(ff_mpeg4audio_sample_rates); sri++)
if (ff_mpeg4audio_sample_rates[sri] == samplerate)
break;
+#endif
return sri;
}
@@ -1146,6 +1164,7 @@
/* First read the EBML header. */
if (ebml_parse(matroska, ebml_syntax, &ebml)
|| ebml.version > EBML_VERSION || ebml.max_size > sizeof(uint64_t)
+ || strcmp(ebml.doctype, s->iformat->name)
|| ebml.id_length > sizeof(uint32_t) || ebml.doctype_version > 2) {
av_log(matroska->ctx, AV_LOG_ERROR,
“EBML header using unsupported features/n”
@@ -1274,11 +1293,13 @@
ff_get_wav_header(&b, st->codec, track->codec_priv.size);
codec_id = st->codec->codec_id;
extradata_offset = FFMIN(track->codec_priv.size, 18);
+#if CONFIG_MATROSKA_DEMUXER
} else if (!strcmp(track->codec_id, “V_QUICKTIME”)
&& (track->codec_priv.size >= 86)
&& (track->codec_priv.data != NULL)) {
track->video.fourcc = AV_RL32(track->codec_priv.data);
codec_id=ff_codec_get_id(codec_movvideo_tags, track->video.fourcc);
+#endif
} else if (codec_id == CODEC_ID_PCM_S16BE) {
switch (track->audio.bitdepth) {
case 8: codec_id = CODEC_ID_PCM_U8; break;
@@ -1881,6 +1902,7 @@
return 0;
}
+#if CONFIG_MATROSKA_DEMUXER
AVInputFormat matroska_demuxer = {
“matroska”,
NULL_IF_CONFIG_SMALL(“Matroska file format”),
@@ -1892,3 +1914,19 @@
matroska_read_seek,
.metadata_conv = ff_mkv_metadata_conv,
};
+#endif
+
+#if CONFIG_WEBM_DEMUXER
+AVInputFormat webm_demuxer = {
+ “webm”,
+ NULL_IF_CONFIG_SMALL(“WebM file format”),
+ sizeof(MatroskaDemuxContext),
+ webm_probe,
+ matroska_read_header,
+ matroska_read_packet,
+ matroska_read_close,
+ matroska_read_seek,
+ .metadata_conv = ff_mkv_metadata_conv,
+};
+#endif
+
————————————————
No need to apply riff patch:
XXXX patch -p1 < ../../../mplayer-vp8-encdec-support/riff-VP80_fourcc.diff
maxin@maxin-laptop:~/Downloads/mplayer/svn/mplayer/etc$ patch -p1 <../../../mplayer-vp8-encdec-support/mplayer-only/codecs_conf-VP8.diff
patching file codecs.conf
Hunk #1 succeeded at 2183 with fuzz 2 (offset 241 lines).
maxin@maxin-laptop:~/Downloads/mplayer/svn/mplayer/libmpdemux$ patch -p1 < ../../../mplayer-vp8-encdec-support/mplayer-only/demux_mkv-V_VP8__webm_doctype.diff
patching file demux_mkv.c
patching file matroska.h
maxin@maxin-laptop:~/Downloads/mplayer/svn/mplayer/libavcodec$ patch -p1 <../../../mplayer-vp8-encdec-support/avcodec-AVCodecContext_add_VP8_specifics.diff
patching file avcodec.h
Hunk #1 succeeded at 2665 (offset 6 lines).
Index: configure
===================================================================
— configure (revision 31226)
+++ configure (working copy)
@@ -300,6 +300,7 @@
–disable-libschroedinger-lavc disable Dirac in libavcodec (Schroedinger
decoder) [autodetect]
–disable-libvpx-lavc disable libvpx in libavcodec [autodetect]
+ –disable-libvpx-vp8-lavc disable VP8 in libavcodec [autodetect]
–disable-libnut disable libnut [autodetect]
–disable-libavutil_a disable static libavutil [autodetect]
–disable-libavcodec_a disable static libavcodec [autodetect]
@@ -695,6 +696,7 @@
_libdirac_lavc=auto
_libschroedinger_lavc=auto
_libvpx_lavc=auto
+_libvpx_vp8_lavc=auto
_libnut=auto
_lirc=auto
_lircc=auto
@@ -1141,6 +1143,8 @@
–disable-libschroedinger-lavc) _libschroedinger_lavc=no ;;
–enable-libvpx-lavc) _libvpx_lavc=yes ;;
–disable-libvpx-lavc) _libvpx_lavc=no ;;
+ –enable-libvpx-vp8-lavc) _libvpx_vp8_lavc=yes ;;
+ –disable-libvpx-vp8-lavc) _libvpx_vp8_lavc=no ;;
–enable-libnut) _libnut=yes ;;
–disable-libnut) _libnut=no ;;
–enable-libavutil_a) _libavutil_a=yes ;;
@@ -7624,6 +7628,45 @@
fi
echores “$_libvpx_lavc”
+
+echocheck “libvpx_vp8″
+if test “$_libvpx_vp8_lavc” = auto; then
+ _libvpx_vp8_lavc=no
+ if test “$_libavcodec_a” != yes; then
+ res_comment=”libavcodec (static) is required by libvpx_vp8, sorry”
+ else
+ cat > $TMPC << EOF
+#define HAVE_STDINT_H 1
+#include <vpx/vpx_decoder.h>
+#include <vpx/vp8dx.h>
+#include <vpx/vpx_encoder.h>
+#include <vpx/vp8cx.h>
+int main(void)
+{
+ vpx_codec_dec_init(NULL,&vpx_codec_vp8_dx_algo,NULL,0);
+ vpx_codec_enc_init(NULL,&vpx_codec_vp8_cx_algo,NULL,0);
+ return 0;
+}
+EOF
+ _inc_vpx_vp8=
+ _ld_vpx_vp8=-lvpx
+ cc_check $_inc_vpx_vp8 $_ld_vpx_vp8 &&
+ _libvpx_vp8_lavc=yes &&
+ extra_cflags=”$extra_cflags $_inc_vpx_vp8″ &&
+ extra_ldflags=”$extra_ldflags $_ld_vpx_vp8″
+ fi
+fi
+if test “$_libvpx_vp8_lavc” = yes ; then
+ def_libvpx_vp8_lavc=’#define CONFIG_LIBVPX_VP8 1′
+ _libavencoders=”$_libavencoders LIBVPX_VP8_ENCODER”
+ _libavdecoders=”$_libavdecoders LIBVPX_VP8_DECODER”
+ codecmodules=”libvpx_vp8 $codecmodules”
+else
+ def_libvpx_vp8_lavc=’#define CONFIG_LIBVPX_VP8 0′
+ nocodecmodules=”libvpx_vp8 $nocodecmodules”
+fi
+echores “$_libvpx_vp8_lavc”
+
echocheck “libnut”
if test “$_libnut” = auto ; then
cat > $TMPC << EOF
—————————————
Now Compile mplayer:
./configure –enable-libvpx-vp8-lavc
make
Finally… after 5 hours of fight with the includer files and Makefiles and modifying some files (sorry.. in half sleep), I got .webm support working with mplayer…
Now, my newly built mplayer can play .webm files.. Yooo.. hoooo…
Thanks to Praveen for inspiration and .webm file.
Finally, see mplayer in action.
./mplayer /home/maxin/Downloads/bigbrotherstate.webm
Hoping to submit the modified patches after re-creating the patches against the latest mplayer source code from SVN. I will be pushing the modified source code to my blog-site.
Update: The modified tar file is available under the following URL:
http://rapidshare.com/files/398835122/mplayer-with-webm.tar.gz.html
4 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.
ffmpeg with webm compiled in DEB package
http://www.megaupload.com/?d=YTSYPOE2
Hello, Is is possible to share the source code of mplayer as tar file ? I am trying to apply the patches to the latest mplayer sourec code and its not working. Also I understand that mplayer latest code already has webm integarted but could not compile it.