Welcome to the wiki talking about FFmpeg on Windows.

Bash script for compiling FFmpeg basically

In this script, we need svn to checkout FFmpeg source. Plase refer to Getting FFmpeg source code with Subversion Command-Line Client

basic_ffmpeg.sh
#!/bin/sh
# ***************************************************************************
#
# Bash script for getting FFmpeg source code and compiling FFmpeg basically
#
# Version: 1.0 @ September 15, 2010
#
# *** License ***
#
# Except where otherwise noted, all of the batchs and scripts are
# copyrighted by http://www.FFmpegWindows.org
#
# Copyright (C) 2010 http://www.FFmpegWindows.org All rights reserved.
#
# These batchs and scripts are provided "as-is," without any express or
# implied warranty. In no event shall the author be held liable for any
# damages arising from the use of them.
#
# Permission is granted to anyone to use these batchs and scripts for
# any purpose, including commercial applications, and to alter and
# redistribute it, provided that the following conditions are met:
#
# 1. All redistributions of batchs and scripts must retain all copyright
#    notices that are currently in place, and this list of conditions
#    without modification.
#
# 2. Modified versions must be plainly marked as such, and must not be
#    misrepresented as being the original batchs and scripts.
#
# http://www.ffmpegwindows.org
#
# ***************************************************************************
 
BASE_DIR=/ffmpeg
SRC_DIR=$BASE_DIR/src
BUILD_DIR=$BASE_DIR/build
INSTALL_DIR=$BASE_DIR/bin_basic
CONFIG_PARAMS=" --prefix=$INSTALL_DIR \
				--disable-static \
				--enable-shared \
				--enable-memalign-hack \
				--target-os=mingw32
				"
 
FFMPEG_TRUNK=svn://svn.ffmpeg.org/ffmpeg/trunk
 
# read Yes/No or Quit
# param $1 -> prompt message
# return 1 -> Yes
# return 0 -> No
function read_yes_no()
{
	while true
	do
		echo -ne "$1 (\e[31;1mY\e[0mes/\e[31;1mN\e[0mo/\e[31;1mQ\e[0muit)[N]:"
		read YNQ
		case "$YNQ" in
			'Y' | 'y' | 'Yes' | 'yes' | 'YES')
				return 1
			;;
			'' | 'N' | 'n' | 'No' | 'no' | 'NO')
				return 0
			;;
			'Q' | 'q' | 'Quit' | 'quit' | 'QUIT')
				exit 1
			;;
			*)
				:
			;;
		esac
	done
}
 
# check svn client
function check_svn_client()
{
	# check "which" util
	which which >/dev/null 2>&1
	if [ $? -ne 0 ]; then
		echo "We need \"which\" util"
		exit 1
	fi
	# check "svn" util
	which svn >/dev/null 2>&1
	if [ $? -ne 0 ]; then
		echo "We need \"svn\" util"
		exit 1
	fi
	echo "Subversion Command-Line Client: $(which svn)"
}
 
# checkout ffmpeg src
function checkout_ffmpeg_src()
{
	svn checkout $FFMPEG_TRUNK $SRC_DIR
}
 
# update ffmpeg src
function update_ffmpeg_src()
{
	svn revert $SRC_DIR/configure >/dev/null 2>&1
	read_yes_no "Do you want to update ffmpeg src with ffmpeg svn repository?"
	if [ $? -ne 0 ]; then
		svn update $SRC_DIR
	fi
}
 
# check target src folder
# return 1 -> svn checkout
# return 0 -> svn update
function check_src_dir()
{
	# the target src folder is not existing.
	if [ ! -d $SRC_DIR ]; then
		return 1
	fi
 
	# the target src folder is existing.
	svn info $SRC_DIR >/dev/null 2>&1
 
	# the target src folder is not a repository.
	if [ $? -ne 0 ]; then
		if [ ! -z "$(ls $SRC_DIR)" ]; then
			# the target src folder is not empty.
			read_yes_no "\e[31;1mWARNING\e[0m: \"$SRC_DIR\" is not empty!
Are you sure to checkout ffmpeg src here?"
			if [ $? -ne 1 ]; then
				exit 1
			fi
		fi
		return 1
	fi
 
	# the target src folder is a repository.
	if svn info $SRC_DIR | grep "^URL: $FFMPEG_TRUNK$" >/dev/null 2>&1
	then
		# the target src folder is ffmpeg src trunk
		return 0
	else
		echo "\"$SRC_DIR\" is not empty and it seems to be another repository."
		exit 1
	fi
}
 
# check configure script
function check_configure()
{
	if [ ! -x $SRC_DIR/configure ]; then
		echo "The configure script is not found in ffmpeg src folder \"$SRC_DIR\""
		exit 1
	fi
}
 
# check GCC version for missing-prototypes
function check_gcc_prototypes()
{
	# check "gcc"
	which gcc >/dev/null 2>&1
	if [ $? -ne 0 ]; then
		echo "No GCC found."
		exit 1
	fi
	gcc_ver=$(gcc -dumpversion)
	if [ $gcc_ver \< 4.4 ]; then
		# disable missing-prototypes
		if grep "^[^#].*missing-prototypes" $SRC_DIR/configure > /dev/null 2>&1
		then
			cp -p $SRC_DIR/configure $SRC_DIR/configure.orig
			sed -e 's/\(.*\)\(missing-prototypes\)/#\1\2/' \
				$SRC_DIR/configure > $SRC_DIR/configure.tmp
			# "\n" -> "\r\n"
			awk '{ print $0"\r" }' < $SRC_DIR/configure.tmp > $SRC_DIR/configure
			rm $SRC_DIR/configure.tmp
		fi
	fi
}
 
# check svn client
check_svn_client
 
# create base dir
if [ ! -d $BASE_DIR ]; then
	mkdir -p $BASE_DIR
fi
 
# check target src folder
check_src_dir
case $? in
	1)
		checkout_ffmpeg_src
	;;
	0)
		update_ffmpeg_src
	;;
	*)
		exit 1
esac
 
# check configure script
check_configure
 
# check GCC version for missing-prototypes
check_gcc_prototypes
 
# create build dir
if [ ! -d $BUILD_DIR ]; then
	mkdir -p $BUILD_DIR
fi
 
# clean build dir
rm -fr $BUILD_DIR/*
 
# run configure
cd $BUILD_DIR
$SRC_DIR/configure $CONFIG_PARAMS
if [ $? -ne 0 ]; then
	exit 1
fi
 
# use multiple CPUs
MULTI_CPU=""
if [ ! -z $NUMBER_OF_PROCESSORS ]; then
	if [ $NUMBER_OF_PROCESSORS -gt 1 ]; then
		MULTI_CPU=-j2
	fi
fi
# run make
make -s $MULTI_CPU
if [ $? -ne 0 ]; then
	exit 1
fi
 
# run install
rm -fr $INSTALL_DIR
make -s install
if [ $? -ne 0 ]; then
	exit 1
fi
 
# remove unused DLLs
LIST=$(ls $INSTALL_DIR/bin)
for ITEM in $LIST; do
	if [ ${ITEM##*.} = dll ]; then
		NAME=${ITEM%.*}
		if [ $NAME = ${NAME##*-} ]; then
			rm -fr $INSTALL_DIR/bin/$ITEM
		elif [ ! $NAME = ${NAME##*.} ]; then
			rm -fr $INSTALL_DIR/bin/$ITEM
		fi
	fi
done
 
echo -e "\nAll done"

Bash scripts for FFmpeg

Print/export