We are still actively working on the spam issue.

Difference between revisions of "WebM"

From InstallGentoo Wiki
Jump to: navigation, search
(Edited conversion .bat; added .webm tutorial)
(Major re-organization of content; command-line params tutorial)
Line 9: Line 9:
  
 
... and on a few /jp/ threads.
 
... and on a few /jp/ threads.
 
  
 
== Converting with ffmpeg ==
 
== Converting with ffmpeg ==
Line 15: Line 14:
 
'''Note:''' avconv and ffmpeg are not entirely drop-in replacements. Make sure you know which one you are using.
 
'''Note:''' avconv and ffmpeg are not entirely drop-in replacements. Make sure you know which one you are using.
  
=== Linux and OS X Scripts ===
+
=== Command Line Options ===
  
If you're using OS X or Linux, you probably know how to save and execute these scripts already, but here's a quick overview:
+
Below is an ffmpeg command:
 +
ffmpeg -i input.mp4 -c:v libvpx -b:v 1M -c:a libvorbis output.webm
  
# Create a file, such as <code>~/bin/my_script.sh</code>
+
This may look intimidating but it is not all that bad. Let's look at the different parameters:
# Copy and paste the code into this file with your favorite editor.
+
* '''-i''': Specifies the input file, which you're converting to another format.
# Open a shell. Run the command <code>chmod +x ~/bin/my_script.sh</code>
+
* '''-c:v''' Specifies the video codec to use. webm isn't actually an encoding type unto itself, but an audio/video container, like mkv. Nevertheless, you will almost always use ''libvpx'' for the video.
# The script can now be called as <code>~/bin/my_script.sh some_file.type</code> or if you have your PATH set correctly, <code>my_script.sh some_file.type</code>
+
* '''-b''': Sets the target bitrate. '''-b:v''' sets video bitrate and '''-b:a''' sets audio. Only use this option if you desire a constant bitrate, which will produce a higher quality file. If you are looking for a smaller file size, consider leaving this out.
 +
* '''-c:a''': Specifies the audio codec to use. Some options include libvorbis, libmp3lame, etc. If you are unsure stick with libvorbis.
  
 +
Other popular options:
 +
* '''-threads''': Tells ffmpeg to use multithreading. Enter the number of cores your processor has as a parameter or put 0 to use them all.
 +
* '''-ac''': Sets number of audio channels. You should probably not touch this unless you know what you're doing.
 +
* '''-an''': disable audio recording. Use when converting .gif files to .webm.
 +
* '''-crf''': Sets CRF value. Must be from 4-63. Lower is higher quality. 10 is a nice starting point.
 +
* '''-ss''': Seeks to a position in the file. Useful for cutting out small scenes. Takes time in seconds as a parameter or HH:MM:SS syntax. use '''-to''' to mark the ending position. For example, <code> -ss 00:00:00 -to 00:00:10 </code> converts the first ten seconds of a video to webm.
  
'''Basic .gif to .webm'''
+
=== Premade Scripts ===
#!/bin/bash
 
out=${1%%.gif}.webm
 
ffmpeg -i $1 -c:v libvpx -crf 32 -b:v 300K $out
 
  
 +
If you're that lazy, here's a couple premade scripts for video and gif conversion.
  
'''Basic video to .webm'''
+
==== Windows ====
#!/bin/bash
+
Save these programs as a .bat file and place them in the folder of the video you want to convert.
ffmpeg -i $1 -c:v libvpx -an $1.webm
+
'''Video to WebM'''
 
 
=== Windows ===
 
 
 
After installing ffmpeg/avconv, most of these commands can be saved as .bat files and placed in the folder of the media file you wish to work with. Or you can just run them from the command prompt, assuming you have your PATH set correctly.
 
 
 
'''Basic .gif to .webm'''
 
 
 
 
 
'''Basic video to .webm'''
 
ffmpeg.exe -i "C:\Users\Anon\Input_File.mkv" -ss 30 -t 15 -codec:v vp8 -an "C:\Users\Anon\Output_File.webm"
 
 
 
 
 
'''Heftier video to .webm'''
 
 
  @echo off
 
  @echo off
 
  rem about 3megabyte in bit 3*1024*1024*8*0.95
 
  rem about 3megabyte in bit 3*1024*1024*8*0.95
Line 66: Line 58:
 
  FOR /F "tokens=* delims=0" %%A IN ("%1") DO SET /A s=s+%%A*60*60
 
  FOR /F "tokens=* delims=0" %%A IN ("%1") DO SET /A s=s+%%A*60*60
 
  set /A VSECONDS=s
 
  set /A VSECONDS=s
 +
 +
==== Linux / OS X ====
 +
 +
If you're using OS X or Linux, you probably know how to save and execute these scripts already, but here's a quick overview:
 +
 +
# Create a file, such as <code>~/bin/my_script.sh</code>
 +
# Copy and paste the code into this file with your favorite editor.
 +
# Open a shell. Run the command <code>chmod +x ~/bin/my_script.sh</code>
 +
# The script can now be called as <code>~/bin/my_script.sh some_file.type</code> or if you have your PATH set correctly, <code>my_script.sh some_file.type</code>
  
 
== Other WebM Creation ==
 
== Other WebM Creation ==
Line 73: Line 74:
 
#https://trac.ffmpeg.org/wiki/vpxEncodingGuide
 
#https://trac.ffmpeg.org/wiki/vpxEncodingGuide
 
#WebM of a WebM tutorial: https://rbt.asia/boards/g/img/0411/75/1396646705233.webm
 
#WebM of a WebM tutorial: https://rbt.asia/boards/g/img/0411/75/1396646705233.webm
#
+
#http://www.webmproject.org/docs/encoder-parameters/
 +
#http://wiki.webmproject.org/ffmpeg
 +
#N0Lif3's Windows tutorial: https://www.youtube.com/watch?v=WeM3SUp-HRg

Revision as of 19:53, 5 April 2014

WebM support is (hopefully) the newest addition to 4chan. This wiki page is meant to serve as an instructional tool to help you get started converting your content to WebM for posting.

WebM {is being, was} tested in these threads:

... and on a few /jp/ threads.

Converting with ffmpeg

Note: avconv and ffmpeg are not entirely drop-in replacements. Make sure you know which one you are using.

Command Line Options

Below is an ffmpeg command:

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

This may look intimidating but it is not all that bad. Let's look at the different parameters:

  • -i: Specifies the input file, which you're converting to another format.
  • -c:v Specifies the video codec to use. webm isn't actually an encoding type unto itself, but an audio/video container, like mkv. Nevertheless, you will almost always use libvpx for the video.
  • -b: Sets the target bitrate. -b:v sets video bitrate and -b:a sets audio. Only use this option if you desire a constant bitrate, which will produce a higher quality file. If you are looking for a smaller file size, consider leaving this out.
  • -c:a: Specifies the audio codec to use. Some options include libvorbis, libmp3lame, etc. If you are unsure stick with libvorbis.

Other popular options:

  • -threads: Tells ffmpeg to use multithreading. Enter the number of cores your processor has as a parameter or put 0 to use them all.
  • -ac: Sets number of audio channels. You should probably not touch this unless you know what you're doing.
  • -an: disable audio recording. Use when converting .gif files to .webm.
  • -crf: Sets CRF value. Must be from 4-63. Lower is higher quality. 10 is a nice starting point.
  • -ss: Seeks to a position in the file. Useful for cutting out small scenes. Takes time in seconds as a parameter or HH:MM:SS syntax. use -to to mark the ending position. For example, -ss 00:00:00 -to 00:00:10 converts the first ten seconds of a video to webm.

Premade Scripts

If you're that lazy, here's a couple premade scripts for video and gif conversion.

Windows

Save these programs as a .bat file and place them in the folder of the video you want to convert. Video to WebM

@echo off
rem about 3megabyte in bit 3*1024*1024*8*0.95
set /A MAXSIZE=23907532
set WIDTH=720
ffmpeg -i %1 2> webm.tmp
for /F "tokens=1,2,3,4,5,6 delims=:., " %%i in (webm.tmp) do (
    if "%%i"=="Duration" call :calcLength %%j %%k %%l %%m
)
del webm.tmp
SET /a BITRATE=%MAXSIZE%/%VSECONDS%
ffmpeg -y -i %1 -threads 0 -sn -an -c:v libvpx -b:v %BITRATE% -vf scale=-1:%WIDTH% -quality best -cpu-used 0 -slices 8 -auto-alt-ref 1 -f webm -pass 1 NUL
ffmpeg -y -i %1 -threads 0 -sn -an -c:v libvpx -b:v %BITRATE% -vf scale=-1:%WIDTH% -quality best -cpu-used 0 -slices 8 -auto-alt-ref 1 -f webm -pass 2 "%~n1.webm"
del ffmpeg2pass-0.log > NUL
goto :EOF
:calcLength
FOR /F "tokens=* delims=0" %%A IN ("%3") DO SET /A s=%%A
FOR /F "tokens=* delims=0" %%A IN ("%2") DO SET /A s=s+%%A*60
FOR /F "tokens=* delims=0" %%A IN ("%1") DO SET /A s=s+%%A*60*60
set /A VSECONDS=s

Linux / OS X

If you're using OS X or Linux, you probably know how to save and execute these scripts already, but here's a quick overview:

  1. Create a file, such as ~/bin/my_script.sh
  2. Copy and paste the code into this file with your favorite editor.
  3. Open a shell. Run the command chmod +x ~/bin/my_script.sh
  4. The script can now be called as ~/bin/my_script.sh some_file.type or if you have your PATH set correctly, my_script.sh some_file.type

Other WebM Creation

Please see Reccomended_software for a list of good software for handling video files such as WebM.

Sources and Resources

  1. https://trac.ffmpeg.org/wiki/vpxEncodingGuide
  2. WebM of a WebM tutorial: https://rbt.asia/boards/g/img/0411/75/1396646705233.webm
  3. http://www.webmproject.org/docs/encoder-parameters/
  4. http://wiki.webmproject.org/ffmpeg
  5. N0Lif3's Windows tutorial: https://www.youtube.com/watch?v=WeM3SUp-HRg