Daala Quickstart Windows

From XiphWiki
Revision as of 14:52, 18 September 2015 by Tdaede (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This is a simple guide to getting the code and encoding a simple video within Windows.

There is also a Daala Quickstart page for Linux/MacOS.

If you wish to use Cygwin to compile Daala within Windows, there is a guide at Daala and Cygwin.

You can also use mingw64 to compile Daala on Windows. To do so, follow the Daala Quickstart guide for Unix operating systems.

Note that using MSVC to build Daala will result in a slower binary, due to the lack of MSVC compatible CPU detection [1]. Patches welcome!


The VS solution files were created using Visual Studio 2008 Team System and Visual Studio 2010 Ultimate.
Even though the provided solutions might work with the express versions of VS, this has not been tested.

Installation Procedure

  • Clone the Daala.git repository (this can take several minutes)
   git clone https://git.xiph.org/daala.git

Make sure you run git clone operations on the same machine you intend to use the code on.
Checking out a copy on Windows and then trying to use it on Linux will not work, as executable permissions and line-endings will not be set properly.

  • Unpack libogg into a folder named ogg.
  • Unpack wxWidgets into a folder named wxWidgets.

Your folder structure should now look like this:

   <your folder>\daala
   <your folder>\ogg
   <your folder>\wxWidgets

Building the executables

  • Open the file Daala_static.sln located at daala\win32\Visual Studio\VS20xx folder.
  • Build the solution.

This will generate 3 executables and 3 static libraries:

  • analyser.exe
  • encoder_example.exe
  • decoder_example.exe
  • LibDaalaBase.lib
  • libdaaladec.lib
  • libdaalaenc.lib

Encoding a Video

Test Media

Get a sample video or two in .y4m format from media.xiph.org.
These videos are relatively large and will take a long time to encode.

There are subsets of 1-second-long videos for faster encoding:

Xiph also maintains a set of still-image collections in .y4m format:

  • Subset 1 (50 images, small training set)
  • Subset 2 (50 images, small testing set)
  • Subset 3 (1000 images, large training set)
  • Subset 4 (1000 images, large testing set)

Using the encoder

Encode the video:

   ./examples/encoder_example -v 30 video.y4m -o video.ogv


  • -v ??? specifies the amount of compression (currently from 0 to 511, where 0 is lossless, 511 is very lossy)
  • video.y4m is the input video you want to encode
  • -o video.ogv is the name of the encoded video file to output.

Use encoder_example.exe -h for the in-built help.

Decoding/Playing a Video

Play the video in a window:

   ./examples/player_example video.ogv

For information on the controls available while playing, run

   ./examples/player_example --help

If you want to use a different player, you can decode the video back to .y4m with

   ./examples/dump_video video.ogv -o decoded_video.y4m

Or you can pipe the raw video stream directly to the player of your choice:

   ./examples/dump_video video.ogv | mpv -

Many other players can play back these .y4m files, and other tools can convert them to various other formats.

Using batch files to encode/decode a video at different compression levels

Save the following 2 batch files to your daala\win32\Visual Studio\VS20xx\Release directory.(you can also use Debug, but the Release executables will be MUCH faster)

This is where the encode_example.exe and decode_example.exe files should be after you successfully build the Daala_static.sln solution (see notes above).

To use the below batch files, drag-and-drop a couple of y4m video or image files onto EncodeDecode.bat and go grab a coffee, 'cause video encoding/decoding takes a while!


::Drag-and-drop .y4m files onto this .bat file to auto-process them!

::turn off auto command-outputting
@echo off

::if we have no input files, go to the :end pointer
if [%~1]==[] (
	echo No input files given!
	goto end

::make an out folder to keep our files in
if not exist out mkdir out

::store the path to this batch file
set batchLocation=%~dp0

::this marks the start of our input-file loop

::loop the commands after the "do" using a compression factor %%i
::starting at 0 (daala lossless quality), in increments of 20, up to 511 (max daala lossy compression)
	::write the current compression factor into a log file (>> appends to file, > truncates data in file then writes to it)

	::call = call another bit of code, but return to this file when done!
	::timecmd = time how long the following command takes
	::encoder_example.exe = encode using daala!
	::-v %%i = using this amount of compression
	::"%~1" = the input file's name and extension, double quotes guard against spaces in name
	::-o "%~n1%%i.ogv" = output the daala-encoded video to this file
	::dp within %~dp1 = grab input file drive and path only
	::n within %~n1 = grab input file name only

	::x (within %~x1) = grab input file extension only
for /l %%i in (0,20,511) do (
	echo Encoding %~n1 using -v %%i... >> out\Log.txt

	call "%batchLocation%timecmd" "%batchLocation%encoder_example.exe" -v %%i "%~1" -o "%~dp1out\%~n1_%%i.ogv" >> out\Log.txt

	echo Decoding %~n1, which was encoded using -v %%i... >> out\Log.txt

	call "%batchLocation%timecmd" "%batchLocation%decoder_example.exe" "%~dp1out\%~n1_%%i.ogv" -o "%~dp1out\%~n1_%%i%~x1" >> out\Log.txt
::shift the files in our input file list, file %~2 becomes %~1

::if we have another file, go to the :inputFileLoop label to encode it!
if not [%~1]==[] goto inputFileLoop


::when all the above encodes/decodes are done, don't close the command window!


:: this code was obtained from https://stackoverflow.com/questions/673523/how-to-measure-execution-time-of-command-in-windows-command-line

@echo off

:: start timing!
set start=%time%

:: runs your command
cmd /c "%*"

:: stop timing!
set end=%time%

:: spawn variables to hold start- and end-date parts
set options="tokens=1-4 delims=:."

for /f %options% %%a in ("%start%") do (
	set start_h=%%a
	set /a start_m=100%%b %% 100
	set /a start_s=100%%c %% 100
	set /a start_cs=100%%d %% 100

for /f %options% %%a in ("%end%") do (
	set end_h=%%a
	set /a end_m=100%%b %% 100
	set /a end_s=100%%c %% 100
	set /a end_cs=100%%d %% 100

:: calculate duration in different units
set /a hours=%end_h%-%start_h%
set /a mins=%end_m%-%start_m%
set /a secs=%end_s%-%start_s%
set /a cs=%end_cs%-%start_cs%

if %hours% lss 0 set /a hours = 24%hours%
if %mins% lss 0 set /a hours = %hours% - 1 & set /a mins = 60%mins%
if %secs% lss 0 set /a mins = %mins% - 1 & set /a secs = 60%secs%
if %cs% lss 0 set /a secs = %secs% - 1 & set /a cs = 100%cs%

if %hours% lss 10 set hours=0%hours%
if %mins% lss 10 set mins=0%mins%
if %secs% lss 10 set secs=0%secs%
if %cs% lss 10 set cs=0%cs%

:: mission accomplished
set /a totalsecs = %hours%*3600 + %mins%*60 + %secs%
echo Command took %hours%:%mins%:%secs%.%cs% (%totalsecs%.%cs%s total)

Converting to y4m from other formats

You can use the ffmpeg tool to generate y4m from any of its supported video formats:

   ffmpeg -i video.webm -pix_fmt yuv420p video.y4m

Or just encode directly without an intermediate file:

   ffmpeg -i video.webm -pix_fmt yuv420p -f yuv4mpegpipe - | ./encoder_example - -o video.ogv

Note that ffmpeg is optimized for speed. You may not get comparable results across machines.

Merging two y4m videos side-by-side

To combine two y4m videos into a single video (with the input videos displayed side-by-side), do:

ffmpeg -i left.y4m -i right.y4m -filter_complex "[0:v]setpts=PTS-STARTPTS, pad=iw*2:ih[bg]; \
           [1:v]setpts=PTS-STARTPTS[fg]; [bg][fg]overlay=w" a_b_compare.y4m

Substitute ffmpeg with avconv if needed.