FFmpeg & cross-compiling for Windows on Linux

September 13, 2009 2 comments

Lately I have been trying to look into compiling ffmpeg for windows/mac/linux as a standalone executable. Compiling for Linux and Mac is pretty straightforward, however for Windows, it’s not that easy. I figured others would have issues too so here’s a quick summary of my experiments.

To compile FFmpeg for Windows, the recommended way is to leverage MinGW. You can set up MinGW on Windows or you can install it on a Linux box as a cross-compiler. Since I already had setup a Debian as a VM running inside VMWare Workstation for compiling FFmpeg on Linux, I figured I’d go that way.

A typical setup would be:
1. Download latest ffmpeg
2. Install gcc & mingw:
% apt-get install build-essentials
% apt-get install mingw
3. Compile ffmpeg
% ./configure –target-os=mingw32 –cross-prefix=i386-mingw32msvc-

Unfortunately, it would be too easy, right. You end up with this error most likely:
ERROR: MinGW runtime version must be >= 3.15.

so what versions do we have installed you say?
% su –
% apt-get install apt-show-versions
% apt-show-versions mingw32-runtime
mingw32-runtime/unstable uptodate 3.13-1

Yep. The latest and greatest mingw runtime debian package is 3.13.

So, I am going to show you how to upgrade it to 3.15 now. First, we need to download the 3.13 sources:
% apt-get build-dep mingw32-runtime
% apt-get source mingw32-runtime

This should download 3 files in your current directory:
and create the mingw32-runtime-3.13 folder.

Next we want to update with the latest MinGW sources:
% cd mingw32-runtime-3.13/upstream
% ls
mingw-runtime-3.13-20070825-1-src.tar.gz w32api-3.10-src.tar.gz

You need to go to the MinGW download site and download the 3.15 MinGW runtime and 3.13 Win32 API tar files.
% wget http://downloads.sourceforge.net/project/mingw/MinGW%20Runtime/mingwrt-3.15/mingwrt-3.15-mingw32-src.tar.gz
% wget http://downloads.sourceforge.net/project/mingw/MinGW%20API%20for%20MS-Windows/Current%20Release_%20w32api-3.13/w32api-3.13-mingw32-src.tar.gz

Unfortunately, the paths are not correct and you need to change a few things. We need to untar the downloaded files, rename the exported folder and re-tar so that the debian build is happy.
% tar -zxf mingwrt-3.15-mingw32-src.tar.gz
% mv mingwrt-3.15-mingw32 mingw-runtime-3.15
% tar -czf mingw-runtime-3.15-src.tar.gz mingw-runtime-3.15
% rm -rf mingw-runtime-3.15

Same thing for W32 Api:
% tar -zxf w32api-3.13-mingw32-src.tar.gz
% mv w32api-3.13-mingw32 w32api-3.13
% tar -zcf w32api-3.13-src.tar.gz w32api-3.13
% rm -rf w32api-3.13

Now remove the old stuff so that it doesn’t get confused:
% rm mingw-runtime-3.13-20070825-1-src.tar.gz
% rm mingwrt-3.15-mingw32-src.tar.gz
% rm w32api-3.13-mingw32-src.tar.gz
% rm w32api-3.10-src.tar.gz

Now you should have only 2 tars in the folder:
% ls
mingw-runtime-3.15-src.tar.gz w32api-3.13-src.tar.gz

Great. Now before we rebuild, we need to update the change log
% cd ..
% vim debian/changelog

Edit it so that the top now refers to new version 3.15:
mingw32-runtime (3.15-1) unstable; urgency=low

* runtime-3.15 / w32api-3.13

-- your_name < your_email > Sun, 13 Sep 2009 15:17:51 -0700

Alternatively you can download my version:
% wget http://plutinosoft.com/stuff/changelog
% mv changelog debian/

Great. You should have everything ready now to rebuild the debian package. In case you’ve had issues following the previous section, you can download my already updated folder or jump directly to building it:
% wget http://plutinosoft.com/stuff/mingw32-runtime-3.15.tar.gz
% tar -xzvf mingw32-runtime-3.15.tar.gz
% cd mingw32-runtime-3.15
% su –

Let’s build it now!
% apt-get install fakeroot
% debian/rules clean
% dpkg-buildpackage -rfakeroot -uc -b
% cd ..

Here we go, you should see a nice new .deb file:
% ls

Let’s install it:
% dpkg -i mingw32-runtime_3.15-1_all.deb

Voila! Ffmpeg is happy now ;-)

Some additional resources that helped me greatly along the way:
* Debian.org apt howto
* FFmpeg site
* MinGW site

rsync goodness

September 11, 2009 No comments yet

So I have been using a simple way to backup my data. I have a NAS (based on awesome freenas) running on my home network. I mount one of its drive in windows and I execute the following code within cygwin:

rsync -avm --exclude="*.obj" --exclude="*.o" --exclude="*.sbr" --exclude="*.pch" --delete --ignore-existing --ignore-errors --force --no-o --no-p --chmod=ugo=rwX /c/Code/ /S/private/Code/

This will backup/sync my Code folder from C drive to S drive (mounted NAS). It works great but unfortunately I have been having lots of rsync warnings as such:

cannot delete non-empty directory xxx

This article suggested it was the use of the “backup flag” -b but I was not using it. It just happened that the issue is actually in the --exclude pattern combined with the --ignore-existing. The excluded files (which happen to have been on my backup drive for some reasons) are not being removed and thus it cannot delete the directories even with the --force option (which is strange).

The solution is to use the flag --delete-excluded:
rsync -avm --exclude="*.obj" --exclude="*.o" --exclude="*.sbr" --exclude="*.pch" --delete --delete-excluded --ignore-existing --ignore-errors --force --no-o --no-p --chmod=ugo=rwX /c/Code/ /S/private/Code/

And voila, no more warnings!

New site Look & Feel

September 9, 2009 No comments yet

Over the week-end, I have revamped the site. It looks more professional and shows better the different projects I am involved with in a nice scroller on the front page. The blog is moved away via the top right menu.
The site works ok on iPhone, the videos embedded in the pages for the scroller don’t seem to hide properly though. I will probably switch to images instead.

Let me know what you think!

DLNA DMC Compliance

September 9, 2009 4 comments

Tonight, I have finished making Platinum DLNA compliant with the DMC profile. A DMC (Digital Media Controller) browses a DMS (Digital Media Server) or MSD (Media Server Device) and control the playback of DMP (Digital Media Player) or MRD (Media Renderer Device).

In the process, I have fixed many bugs, crashes, deadlocks and will publish version 0.5.2 anytime now.

Platinum DLNA compliance moving along

August 29, 2009 1 comment

Today I have spent some time testing Platinum with DLNA tools. I am focusing on the Control Point right now. Looks like I have 2 errors and 1 warning left out of around 120 tests. Not bad!

Screenjelly button

August 16, 2009 No comments yet

Screenjelly is a web service that lets you record whatever is happening on your screen including audio for 3 minutes without any downloads or plugins to install. Once finished, you get a link you can send via email, IM or even Twitter.

You can either go to http://screenjelly.com to start your recording or you can now embed a Screenjelly button on your site and let your readers start directly from your site. I have added one to my sidebar. Screenjelly also provides an API to let your site capture the recordings once submitted by your viewers. More info here.

Oh and there’s a bookmarklet too now so wherever you are roaming on the web, you can now start a recording right there without having to go to Screenjelly.com anymore. Kinda cool.

Oh and you can embed the video too by the way. Here’s a video that was recorded today by someone using ScreenSplitr and DemoGod. Cool!