Jump to content

FFmpeg

From EDM2

Getting FFmpeg

The best way to get FFmpeg sources is with SVN. Paul Smedley has built a SVN client available at http://download.smedley.info/subversion-1.4.4-os2.zip. Entering this command

svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg

will create a directory called ffmpeg below where you entered the command and download the source. To update the source you can enter

svn update

in the ffmpeg directory. Further information including a web interface to the source and links to daily snapshots are available at http://ffmpeg.mplayerhq.hu/download.html

Patching FFmpeg

As FFmpeg does not officially support OS/2 at this time you need to apply this patch

Index: configure
=================================================================
--- configure	(revision 11093)
+++ configure	(working copy)
@@ -71,6 +71,7 @@
   echo "  --enable-pp              enable GPLed  postprocessing support [default=no]"
   echo "  --enable-swscaler        software scaler support [default=no]"
   echo "  --enable-beosthreads     use BeOS threads [default=no]"
+  echo "  --enable-os2threads      use OS/2 threads [default=no]"
   echo "  --enable-pthreads        use pthreads [default=no]"
   echo "  --enable-w32threads      use Win32 threads [default=no]"
   echo "  --enable-x11grab         enable X11 grabbing [default=no]"
@@ -637,6 +638,7 @@

 THREADS_LIST='
     beosthreads
+    os2threads
     pthreads
     w32threads
 '
@@ -1217,6 +1219,35 @@
         targetos=irix
         ranlib="echo ignoring ranlib"
         ;;
+    os/2*)
+        ar="emxomfar -p256"
+        ranlib="echo ignoring ranlib"
+        strip="lxlite"
+        ln_s="cp -f"
+        add_cflags "-Zomf"
+        DESCRIPTION="'\"\$(SLIBNAME_WITH_VERSION)\"'"
+        EXESUF=".exe"
+        FFLDFLAGS="-Zomf -Zbin-files -Zargs-wild -Zmap"
+        SHFLAGS='$(FULLNAME).def -Zdll -Zomf'
+        FFSERVERLDFLAGS=""
+        LIBSUF="_s.lib"
+        SLIBPREF=""
+        SLIBSUF=".dll"
+         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
+        SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
+        SLIB_CREATE_DEF_CMD='echo LIBRARY $(FULLNAME) INITINSTANCE TERMINSTANCE > $(FULLNAME).def; \
+          echo DESCRIPTION $(DESCRIPTION) >> $(FULLNAME).def; \
+          echo PROTMODE >> $(FULLNAME).def; \
+          echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(FULLNAME).def; \
+          echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(FULLNAME).def; \
+          echo EXPORTS >> $(FULLNAME).def; \
+          emxexp -o $(OBJS) >> $(FULLNAME).def'
+        SLIB_EXTRA_CMD='emximp -o $(LIBPREF)$(FULLNAME)_dll.a $(FULLNAME).def; emximp -o $(LIBPREF)$(FULLNAME)_dll.lib $(FULLNAME).def'
+        SLIB_INSTALL_EXTRA_CMD='install -m 644 $(LIBPREF)$(FULLNAME)_dll.lib $(LIBPREF)$(FULLNAME)_dll.a "$(LIBDIR)"'
+        SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(FULLNAME)_dll.lib;rm -f "$(LIBDIR)"/$(LIBPREF)$(FULLNAME)_dll.a'
+        vhook="no"
+        ;;
+
     *)
         targetos="${targetos}-UNKNOWN"
         ;;
@@ -1917,6 +1948,7 @@

 if enabled shared; then
     echo "BUILD_SHARED=yes" >> config.mak
+    echo "DESCRIPTION=${DESCRIPTION}" >> config.mak
     echo "PIC=-fPIC -DPIC" >> config.mak
     echo "SPPMAJOR=${pp_version%%.*}" >> config.mak
     echo "SPPVERSION=$pp_version" >> config.mak
@@ -1933,6 +1965,7 @@
     echo "SLIBNAME=${SLIBNAME}" >> config.mak
     echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
     echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
+    echo "SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}" >> config.mak
     echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
     echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
     echo "SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}" >> config.mak
Index: common.mak
==================================================================
--- common.mak	(revision 11093)
+++ common.mak	(working copy)
@@ -28,6 +28,7 @@
 	$(LN_S) $^ $@

 $(SLIBNAME_WITH_MAJOR): $(OBJS)
+	$(SLIB_CREATE_DEF_CMD)
 	$(CC) $(SHFLAGS) $(LDFLAGS) -o $@ $^ $(EXTRALIBS)  $(EXTRAOBJS)
	$(SLIB_EXTRA_CMD)

@@ -51,7 +52,7 @@

 clean::
 	rm -f *.o *~ *.a *.lib *.so *.so.* *.dylib *.dll \
-	      *.def *.dll.a *.exp *.ho
+	      *.def *.dll.a *.exp *.ho *.map

 distclean: clean
 	rm -f .depend


Copy and paste the above patch into a file called os2.patch and in the ffmpeg directory enter the command

patch -p0 < os2.patch.

Warning Make sure that you have gnu patch in your path ahead of the OS/2 patch.exe in x:\os2. There is a version of gnu patch available at http://hobbes.nmsu.edu/pub/os2/dev/util/gnupatch.zip

Hints on Setting the Environment

To build FFmpeg you need an unix build setup. Currently only GCC3.3.5 is supported for building. A complete build environment is available at http://www.smedley.info/os2ports/index.php?page=build-environment.

If you would like to build a build enviroment from scratch http://developer.mozilla.org/en/docs/OS/2_Build_Prerequisites has links to many ported packages.

You also need SDL setup correctly to build FFplay, see http://www.edm2.com/index.php/SDL and also follow the instructions at http://www.edm2.com/index.php/SDL#Configure_can.27t_link_SDL_Init or configure will fail to find SDL. Configure needs a Posix shell, I recommend pdksh, http://hobbes.nmsu.edu/pub/os2/util/shell/pdksh-5.2.14-bin-2.zip Ash will also work if %PWD% is first set, eg

set PWD=x:/path/to/ffmpeg

Note uses slashes instead of backslashes.

Compiling FFmpeg

Before compiling you have to decide whether to build with shared libs or static libs. For standalone use I'd advise static libs as the simpler solution. For using in other projects shared libs do have advantages, both in ease of maintenance and for licensing issues. First step should be to do

sh configure --help

to see all available options. Hint, by using a cmd prompt in an EPM window you can get a scrollable window. Basic FFmpeg can be compiled as

sh configure --enable-static --disable-shared --enable-os2threads

or

sh configure --enable-shared --disable-static --enable-os2threads

then

make

At this point

make install

Will install FFmpeg in /usr/local. You can pass prefix to configure to change the install location eg

sh configure --enable-shared --disable-static --enable-os2threads --prefix=x:/ffmpeg

Testing FFmpeg

Various Hints