Daala Quickstart Windows: Difference between revisions
Line 30: | Line 30: | ||
== Building the executables == | == Building the executables == | ||
* Open the file '''Daala_static.sln''' located at '''daala\win32\Visual Studio\ | * Open the file '''Daala_static.sln''' located at '''daala\win32\Visual Studio\VS20xx''' folder. | ||
* Build the solution. | * Build the solution. | ||
This will generate 3 static libraries | This will generate 2 executables and 3 static libraries: | ||
* encoder_example.exe | * encoder_example.exe | ||
* decoder_example.exe | * decoder_example.exe | ||
* LibDaalaBase.lib | |||
* libdaaladec.lib | |||
* libdaalaenc.lib | |||
== Encoding a Video == | == Encoding a Video == |
Revision as of 13:49, 22 January 2015
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.
Pre-requisites
- Source Code - Solution files and source code patches
- Git
- libogg (v1.3.0 or later) - the VS solution files were tested with libogg-1.3.2
- Visual Studio (2008 or 2010)
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
- Unpack libogg into a folder named ogg.
If you cloned the Daala repository onto your C-drive root, your folder structure should now look like this:
C:\daala C:\ogg
Make sure you run the git clone operation on the same machine where you intend to use the code.
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.
Building the executables
- Open the file Daala_static.sln located at daala\win32\Visual Studio\VS20xx folder.
- Build the solution.
This will generate 2 executables and 3 static libraries:
- encoder_example.exe
- decoder_example.exe
- LibDaalaBase.lib
- libdaaladec.lib
- libdaalaenc.lib
Encoding a Video
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 also subsets of 1-second-long videos for faster encoding: video-1-short
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)
Encode the video:
./examples/encoder_example -v 30 video.y4m -o video.ogv
where
- -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.
Decoding a Video
You can decode the video back to .y4m with
./examples/decoder_example video.ogv -o decoded_video.y4m
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\Debug directory.
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).
- EncodeDecode.bat
:: Drag-and-drop .y4m video files onto this .bat file to auto-process them! :: turn off auto command outputting @echo off :: for /l %%i in (0,20,511) do = loop the commands after the "do" using a variable %%i starting at 0(daala lossless quality), in increments of 20, up to 511 (max daala lossy compression) :: echo Encoding -v %%i... >> Log.txt = write the current compression factor into a log file (>> appends to file, > truncates data in file then writes to it) :: & = allow multiple commands within the for loop :: call = call another bit of code, but return to this file when done! :: timecmd = time how long the following command takes (this is what timecmd.bat gets used for) :: 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 :: n (within %~n1) = grab input file name only :: the rest of the code follows along in similar lines... for /l %%i in (0,20,511) do echo Encoding -v %%i... >> Log.txt & call timecmd encoder_example.exe -v %%i "%~1" -o "%~n1%%i.ogv" >> Log.txt & echo Decoding -v %%i... >> Log.txt & call timecmd decoder_example.exe "%~n1%%i.ogv" -o "%~n1%%i.y4m" >> Log.txt :: when all the above encodes/decodes are done, don't close the command window! pause
- timecmd.bat
:: this code was obtained from https://stackoverflow.com/questions/673523/how-to-measure-execution-time-of-command-in-windows-command-line @echo off @setlocal :: 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_ms=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_ms=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 ms=%end_ms%-%start_ms% 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 %ms% lss 0 set /a secs = %secs% - 1 & set /a ms = 100%ms% if 1%ms% lss 100 set ms=0%ms% :: mission accomplished set /a totalsecs = %hours%*3600 + %mins%*60 + %secs% echo Command took %hours%:%mins%:%secs%.%ms% (%totalsecs%.%ms%s total) echo.
Drag-and-drop a y4m video onto EncodeDecode.bat and go grab a coffee, 'cause video encoding/decoding takes a while!
Creating 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
Note that ffmpeg is optimized for speed. You may not get repeatable results across machines.