编译FFMpeg/FFPlay

 

Introduction

FFplay is a simple and portable media player using the FFmpeg and SDL libraries. We modifies it and uses it as the video decoder of our wireless video transmission testbed.

FFplay is developed under Linux but it is possible to build for Windows. This document presents the tools and procedures for cross compiling FFplay under Windows. It is based on the online tutorial “Building ffmpeg for Windows with MSYS and MinGW” with our own updates. The original tutorial can be found from:
    http://www.gooli.org/blog/building-ffmpeg-for-windows-with-msys-and-mingw/

 

Tools

We use MinGW and MSYS as the cross compiling platform. In this section, we list all the tools and software we will use.  

MinGW and MSYS
MinGW stands for Minimalist GNU for Windows. It is a native Windows port of the GNU Compiler Collection (GCC), with freely distributable import libraries and header files for building native Windows applications.

MSYS is a Minimal SYStem providing a POSIX compatible Bourne shell environment, with a small collection of UNIX command line tools. It is primarily developed as a means to execute the configure scripts and Makefiles used to build Open Source software. MinGW and MSYS can be downloaded from:
    http://sourceforge.net/project/showfiles.php?group_id=2435

SDL Runtime Library
SDL stands for Simple DirectMedia Layer. It is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer. FFplay requires SDL library and here we need the Win32 runtime library “SDL.dll”. The library can be found from:
    http://www.libsdl.org/download-1.2.php

FFmpeg
Download our video encoding/decoding software based on FFmpeg.

 

Updates

Before start building, we need some updates for MinGW and MSYS. These updates resolve bugs and compatibility issues in older versions. Below is the list of necessary updates.

coreutils
Download coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2 from following address:
    http://downloads.sourceforge.net/mingw/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2

w32api
Get MinGW API for MS-Windows w32api-3.13 from following address:
    http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=11550
Download w32api-3.13-mingw32-dev.tar.gz which has been compiled for i386.

make
Get make-3.81 (or newer version) from:
    http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=24963
Download make-3.81-MSYS-1.0.11-2.tar.bz2 which has been compiled for i386.

bash
Since FFplay’s configure script doesn’t work with bash 2.0.4 that comes with MSYS. We need bash with a newer version. bash-3.1-MSYS-1.0.11-1.tar.bz2 can be downloaded from:
    http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=24963

SDL Development Library
To cross compile FFplay, we need SDL development library to be installed. The library can obtained from:
    http://www.libsdl.org/download-1.2.php
Download the SDL source codes SDL-1.2.13.tar.gz.

 

Install and Build

Now we are ready to install the tools and updates.
1. Install MinGW (choose “MinGW base tools” and “MinGW make”) into c:/mingw
2. Install MSYS into c:/msys/1.0
3. After MSYS installation, it will run a post install script. It will ask you some questions which you should answer as following:
    • Do you wish to continue with the post install? [yn ] —> y
    • Do you have MinGW installed? [yn ] —> y
    • Where is your MinGW installation? —> C:/mingw
4. Extract coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2. This file contains four directories: bin, info, lib, and man. Copy all files within these four directories to corresponding directories under C:/MinGW to overwrite old files.
5. Extract w32api-3.13-mingw32-dev.tar.gz. This file contains two directories: include and lib. Copy all files within these two directories to corresponding directories under C:/MinGW to overwrite old files.
6. Extract make-3.81-MSYS-1.0.11-2.tar.bz2. This file contains three directories: bin and share. Copy all files within these two directories to corresponding directories under C:/MinGW
to overwrite old files. And copy “make.exe” to C:/msys/1.0/bin.
7. Extract bash-3.1-MSYS-1.0.11-1.tar.bz2. It contains three directories: bin, info, and man. Copy all files within these three directories to corresponding directories under C:/MinGW to overwrite old files. And copy “bash.exe” to C:/msys/1.0/bin.
8. Extract SDL-1.2.13.tar.gz. Under MSYS shell, go to directory SDL-1.2.13 and run following commands to install SDL:
    • ./configure
    • make
    • make install
9. FFmpeg (our trimmed version, download here)
    • Create a file called “myconfig” in C:/work/ffmpeg and copy the following into it:
         #!/bin/sh
         ./configure –extra-cflags="-mno-cygwin -mms-bitfields"
         –extra-ldflags="-Wl,-add-stdcall-alias" –enable-memalign-hack
         –target-os=mingw32 –disable-shared –enable-static –disable-mmx
         –disable-mmx2 –disable-ffmpeg
         –enable-swscale –enable-gpl
    • Under MSYS shell, go to directory c/work/ffmpeg and run following commands to build FFplay:
        • ./myconfigure
        • make

Before running make, read the configuration output and make sure that the SDL check is “yes”. This means you have correctly installed SDL libraries. Otherwise FFplay won’t be built. If everything goes right, now you should be able to get ffplay.exe that runs under Windows.

 

To Use FFplay

To run FFplay, collect ffplay.exe and SDL.dll and put them in one directory. Now you are ready to go! You will be able to play local H.264 bitstreams, as well as receiving UDP packets. Below we list frequently used options and hot keys of ffplay.

Options:

    -h: show help
    -f: force format
    -s: set frame size (WxH or abbreviation)
    -dest_port: specify destination port number
    -fs: force full screen
    -x: force displayed width
    -y: force displayed height

Hot keys:

    q/ESC: quit
    f: toggle full screen
    p/SPC: pause

Play Local File
Open Windows cmd.exe and go to the directory that contains ffplay.exe and SDL.dll. Assume that you have a H.264 bitstream called foreman cif.264 in the same directory. Run following command to play the H.264 file:
    ffplay.exe foreman_qcif.264
While playing you can press “f” to toggle full screen display. Press “q” or “ESC” to quit ffplay. You can also specify the display window size through command line options. The figure below shows the screen shot of ffplay under Windows XP.

 

Receive Packets Using Socket
To receive UDP packets, you need specify the socket port through command line option. Assume port number 12345 is used, use following command:
    ffplay.exe -dest_port 12345 -f h264
With the knowledge of your IP address and port number, the transmitter can then send encoded H.264 packets to you. ffplay will be able to pick up and decode the packets, and to display video in real time.

版权所有,禁止转载. 如需转载,请先征得博主的同意,并且表明文章出处,否则按侵权处理.

    分享到:

留言

你的邮箱是保密的 必填的信息用*表示