How to create a WebM video file?

FfmpegWebm

Ffmpeg Problem Overview


After looking around the web, I found no way to generate a WebM video. I see drivers for Windows and QuickTime, but no evidence that the most common utility FFmpeg is being supported.

Is there any open source converter that produces WebM?

Ffmpeg Solutions


Solution 1 - Ffmpeg

You can use ffmpeg to convert to WebM. Make sure to compile it with the --enable-libvpx and --enable-libvorbis flags (see FFmpeg compile guides), or visit the FFmpeg Download page for links to builds that include support. After that, you can use the following command (I'm using input.flv as my example input file):

ffmpeg -i input.flv -vcodec libvpx -acodec libvorbis output.webm

For additional information, see the FFmpeg vpx (WebM) Encoding Guide.

Solution 2 - Ffmpeg

ffmpeg -i input.mp4 -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis output.webm

By default the CRF value can be from 4–63, and 10 is a good starting point. Lower values mean better quality.

Solution 3 - Ffmpeg

I set this up recently, but it's kind of a pain. Here's what I had to do:

First, build ffmpeg from source to include the libvpx drivers (even if your using a version that has it, you need the newest ones (as of this month) to stream webm because they just did add the functionality to include global headers). I did this on an Ubuntu server and desktop, and this guide showed me how - instructions for other OSes can be found here.

Once you've gotten the appropriate version of ffmpeg/ffserver you can set them up for streaming, in my case this was done as follows.

On the video capture device:

ffmpeg -f video4linux2 -standard ntsc -i /dev/video0 http://<server_ip>:8090/0.ffm
  • The "-f video4linux2 -standard ntsc -i /dev/video0" portion of that may change depending on your input source (mine is for a video capture card).

Relevant ffserver.conf excerpt:

Port 8090
#BindAddress <server_ip>
MaxHTTPConnections 2000
MAXClients 100
MaxBandwidth 1000000
CustomLog /var/log/ffserver
NoDaemon

<Feed 0.ffm>
File /tmp/0.ffm
FileMaxSize 5M
ACL allow <feeder_ip>
</Feed>
<Feed 0_webm.ffm>
File /tmp/0_webm.ffm
FileMaxSize 5M
ACL allow localhost
</Feed>

<Stream 0.mpg>
Feed 0.ffm
Format mpeg1video
NoAudio
VideoFrameRate 25
VideoBitRate 256
VideoSize cif
VideoBufferSize 40
VideoGopSize 12
</Stream>
<Stream 0.webm>
Feed 0_webm.ffm
Format webm
NoAudio
VideoCodec libvpx
VideoSize 320x240
VideoFrameRate 24
AVOptionVideo flags +global_header
AVOptionVideo cpu-used 0
AVOptionVideo qmin 1
AVOptionVideo qmax 31
AVOptionVideo quality good
PreRoll 0
StartSendOnKey
VideoBitRate 500K
</Stream>

<Stream index.html>
Format status
ACL allow <client_low_ip> <client_high_ip>
</Stream>
  • Note this is configured for a server at feeder_ip to execute the aforementioned ffmpeg command, and for the server at server_ip so server to client_low_ip through client_high_ip while handling the mpeg to webm conversation on server_ip (continued below).

This ffmpeg command is executed on the machine previously referred to as server_ip (it handles the actual mpeg --> webm conversion and feeds it back into the ffserver on a different feed):

ffmpeg -i http://<server_ip>:8090/0.mpg -vcodec libvpx http://localhost:8090/0_webm.ffm

Once these have all been started up (first the ffserver, then the feeder_ip ffmpeg process then then the server_ip ffmpeg process) you should be able to access the live stream at http://:8090/0.webm and check the status at http://:8090/

Hope this helps.

Solution 4 - Ffmpeg

For Linux: Open source software available to use vp8 and vp9 codec for linux is Arista for the gnome desktop. Google: Arista Transcoder

For Windows & Linux: Miro Video Converter is also free and open source with a very slick GUI. You can check it out at: Google: mirovideoconverter

FFMPEG is a command line tool and I found it to be the most up-to-date in keeping up with the webmd project. Don't forget to look at the vp8 encoding options provided by the webmproject site https://sites.google.com/a/webmproject.org/wiki/ffmpeg. You should also take a look at the VPX Encoding Guide: https://trac.ffmpeg.org/wiki/vpxEncodingGuide

Another post mentioned vpxenc.exe However, vpxenc.exe needs to be compiled by source.

FFMEG Example Uses: Replace {NPUT} and {OUTPUT} to the file location. On Windows 7 I had to use the power shell (Start > Accessories > Windows Power Shell > Power Shell) and provide the full location for ffmpeg, input and output. Note the parameter -vcodec libvpx uses VP8 by default. To use VP9 replace with -vcodec libvpx-vp9

WedmbSD

ffmeg.exe -i {INPUT} -s hd480 -vcodec libvpx -g 120 -lag-in-frames 16 -deadline good -cpu-used 0 -vprofile 0 -qmax 63 -qmin 0 -b:v 768k -acodec libvorbis -ab 112k -ar 44100 -f webm {OUTPUT}

Solution 5 - Ffmpeg

FFmpeg. MP4 to WebM. To have lipsync and high-quality

$ ffmpeg -i input.mp4 -b:v 1M -q:v 10 -vcodec libvpx -acodec libvorbis output.webm
ffmpeg version 2.8.6-1ubuntu2 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.3.1 (Ubuntu 5.3.1-11ubuntu1) 20160311
  configuration: --prefix=/usr --extra-version=1ubuntu2 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'SPBFRE_01.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42mp41
    creation_time   : 2015-05-29 14:49:20
  Duration: 00:01:41.61, start: 0.000000, bitrate: 9452 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 9132 kb/s, 50 fps, 50 tbr, 50k tbn, 100 tbc (default)
    Metadata:
      creation_time   : 2015-05-29 14:49:20
      handler_name    : ?Mainconcept Video Media Handler
      encoder         : AVC Coding
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 317 kb/s (default)
    Metadata:
      creation_time   : 2015-05-29 14:49:20
      handler_name    : #Mainconcept MP4 Sound Media Handler
File 'output.webm' already exists. Overwrite ? [y/N] y
[libvpx @ 0x132af40] v1.5.0
Output #0, webm, to 'output.webm':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42mp41
    encoder         : Lavf56.40.101
    Stream #0:0(eng): Video: vp8 (libvpx), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 1000 kb/s, 50 fps, 1k tbn, 50 tbc (default)
    Metadata:
      creation_time   : 2015-05-29 14:49:20
      handler_name    : ?Mainconcept Video Media Handler
      encoder         : Lavc56.60.100 libvpx
    Stream #0:1(eng): Audio: vorbis (libvorbis), 44100 Hz, stereo, fltp (default)
    Metadata:
      creation_time   : 2015-05-29 14:49:20
      handler_name    : #Mainconcept MP4 Sound Media Handler
      encoder         : Lavc56.60.100 libvorbis
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> vp8 (libvpx))
  Stream #0:1 -> #0:1 (aac (native) -> vorbis (libvorbis))
Press [q] to stop, [?] for help
frame=  755 fps= 10 q=0.0 size=    1987kB time=00:00:15.12 bitrate=1076.5kbits/s 

Solution 6 - Ffmpeg

MiroVideoConverter is a nice cross-platform and open-source wrapper around ffmpeg, which, in particular, supports converting to WebM.

Solution 7 - Ffmpeg

I wasn't sure if my copy of FFMPEG supports WebM, so first I converted my MPEG4 video to raw video using FFMPEG.

Then I used the vpxenc.exe provided with the WebM project's SDK to convert this to WebM.

Link to the SDK download: http://code.google.com/p/webm/downloads/list

Download, extract and look in the "bin" folder. There are some sample apps there. A decoder is also provided.

Command I used to convert raw video to WebM:

vpxenc.exe -w 720 -h 480 --rt -o v1.webm v1.yuv

HTH

Solution 8 - Ffmpeg

Try it with avconv:

avconv -i inmovie.mp4 -flags global_header -strict experimental outmovie.webm

Solution 9 - Ffmpeg

Another option if you're looking for an easy graphical way to accomplish this is [HandBrake][handbrake:home] (although HandBrake does come in a [commandline flavor][handbrake:cli] as well, in case you're scripting the process, or maybe just prefer the commandline). Like the ffmpeg that others have suggested here, HandBrake is available on Linux, Mac, and Windows, so it won't matter what operating system you're using. The process and interface will be almost exactly the same.

Now, the .webm container is basically just a Matroska file, but what really makes it webm is the streams it contains. According to the [WebM Project][webm:container], the video stream must be either VP8 or VP9, and the audio stream must be either Vorbis, or Opus, so when using HandBrake, you'll need to make sure you're setting those options properly.

So, to encode a video to webm, naturally, you'll need to select a video, so let's do that first. In the toolbar across the top of the HandBrake window, the first option says "Open Source". It doesn't refer to the nature of the software (even though it is actually Open Source software), but rather it refers to opening a source of video using your operating system's standard file requester window which you've probably seen more than once already. Click that button, and navigate to a video on your system which you'd like to encode to a webm file.

Now that you've got a file selected, a few bits of the interface update with some new information, and you can start to select options for your conversion. There's a buncha interesting choices, but for this answer we'll focus on the ones related to the question of "How to create a webm video file?" rather than go over each option in detail. You can always read the [HandBrake Documentation][handbrake:docs] if you're interested in more details.

  • On the first page of options that you see after starting HandBrake, about halfway down, you see "Format:" with an option for "MPEG-4" or "Matroska". This chooses the container. For webm, you'll want "Matroska".
  • Above that you'll see a bar of option buttons that switches between various pages. You can set a variety of nifty options there, but the one we want next is "Video", so click that and look for "Video Encoder:" which you'll set to either "VP8" or "VP9" depending on your preference and use-case. VP9 is newer and compresses better, but requires a bit more CPU work for both encoding and playback, so keep that in mind.
  • Last, but not least, let's look at the "Audio" options. Because you chose a video, there should be at least one (possibly more than one) audio stream in the "Track List" box on the "Audio" page. The left side of that audio track lists what format the track is currently (Something like English (AC3)(5.1 ch)(48khz) Bitrate: 448kbps for example). The right side of the -> there lists what format you're converting to from what's on the left. That's where we need to ensure either Vorbis or Opus.
  • Click the little pencil icon at the far right of the audio track you're encoding, and you'll get a new window on your screen where you can choose which track to encode and more importantly, the encoder details. Be sure the encoder is set to either Vorbis or Opus (Opus is newer and overall better than Vorbis, so probably the one you want to choose nearly every time), and choose 128, 160, or 192 for the bitrate for most normal purposes. You can go higher or lower, but know that higher will increase the size of the audio track without much (if any) noticeable improvement in audio quality, and much lower you may start to actually notice degradation in your audio track. The "Mix" setting will be personal preference, depending on source material and your needs for the output. Sample rate should generally be set to 48. "Gain" and "DRC" are if your audio track is too quiet, and if there's a really huge difference between loud and soft levels throughout the track. Click "OK" on that window to lock in your choices.
  • At the bottom of the window, you see "Save As:" with a filename, and "To:" with a folder. "To:" is where you can choose where you want the file(s) saved at, and "Save As:" is where you choose what to name the file you're creating. Make sure that if you're trying to create a .webm file, that your filename actually ends with .webm, or you're just creating a Matroska file with webm streams. (Totally valid, but some less sophisticated software might get confused if it expects webm and the file is named as something.mkv despite them being the same thing, just with a different filename.)

At this point you should be ready to click "Start Encoding" in the toolbar to immediately begin the encode, or "Add to Queue" if you're encoding many videos and want to just start a list and do them all one after another automagically. And now you just wait. It can take a while, so be patient. It'll let you know when it's done.

[handbrake:home]: https://handbrake.fr/ "HandBrake Home" [handbrake:docs]: https://handbrake.fr/docs/en/1.3.0/ "HandBrake Documentation" [handbrake:cli]: https://handbrake.fr/docs/en/1.3.0/cli/command-line-reference.html "HandBrakeCLI Reference" [webm:container]: https://www.webmproject.org/docs/container/ "WebM Container"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMarneauView Question on Stackoverflow
Solution 1 - FfmpegmatzahboyView Answer on Stackoverflow
Solution 2 - FfmpegIvan KaratayevView Answer on Stackoverflow
Solution 3 - FfmpegCoryGView Answer on Stackoverflow
Solution 4 - FfmpegDiazView Answer on Stackoverflow
Solution 5 - Ffmpeguser285594View Answer on Stackoverflow
Solution 6 - FfmpegNickolayView Answer on Stackoverflow
Solution 7 - FfmpegKapil PendseView Answer on Stackoverflow
Solution 8 - FfmpegAftershockView Answer on Stackoverflow
Solution 9 - FfmpegSpam HaterView Answer on Stackoverflow