Use at own risk. Programs haven't been thoroughly tested.
script: movie2flv.bash
A simple BASH script to help make you convert all kind of video formats to FLV movies for use with Flash players like youtube. Automatically tries to install ffmpeg if needed, and also automatically generates a preview thumbnail of the movie. If you want you can change the options of ffmpeg like bitrate, sound, etc. see 'man ffmpeg' for more information.
Info
@author Kevin van Zonneveld
@version 0.2
@link http://kevin.vanzonneveld.net
@param (string) MOVIE_SOURCE the path to the video file to convert
@version 0.2
@link http://kevin.vanzonneveld.net
@param (string) MOVIE_SOURCE the path to the video file to convert
Example
Usage
Outputs
[ generates video.flv and video.png and leaves the original video.ogg untouched ]
movie2flv.bash video.ogg
Outputs
[ generates video.flv and video.png and leaves the original video.ogg untouched ]
Source Code
download source#!/bin/bash # CMD_FFMPEG="${HOME}/ffmpeg/bin/ffmpeg" CMD_APTITUDE=$(which aptitude) CMD_SVN=$(which svn) function ffm_Convert2FLV(){ # figure out all the paths BASENAME=${1%.[^.]*} sorc_mov=${1} dest_mov=${BASENAME}.flv dest_pic=${BASENAME}.png # create FLV ${CMD_FFMPEG} -i ${sorc_mov} \ -y \ -vcodec flv \ -b 300k \ -s 320x240 \ -r 6 \ -an \ -croptop 6 \ -cropbottom 6 \ -f flv \ ${dest_mov} # create PNG ${CMD_FFMPEG} -i ${dest_mov} -y -ss 00:00:01 -vcodec png -vframes 1 -an -sameq -f rawvideo ${dest_pic} } function sys_InstallFFMPEG(){ echo "You need to be root to install the latest version of ffmpeg:" sudo echo "accepted. installing the latest ffmpeg..." echo "compiling can take a very long time, don't worry." echo -n "trying to download build-essential " if [ -f /etc/apt/sources.list ]; then [ $? -ne 0 ] || sudo aptitude -y update 1> /dev/null && sudo aptitude -y install build-essential 1> /dev/null if [ $? -eq 0 ]; then echo "[okay]" else echo "[fail]" exit 1 fi else echo "[ignore]" fi echo -n "trying to download ffmpeg SVN trunk " [ $? -ne 0 ] || mkdir -p ${HOME}/ffmpeg/src 1> /dev/null [ $? -ne 0 ] || cd ${HOME}/ffmpeg/src [ $? -ne 0 ] || sudo svn --force export svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg 1> /dev/null if [ $? -eq 0 ]; then echo "[okay]" else echo "[fail]" exit 1 fi echo -n "trying to build (can take long, ignore warnings!) " [ $? -ne 0 ] || cd ${HOME}/ffmpeg/src/ffmpeg [ $? -ne 0 ] || sudo ./configure --prefix=${HOME}/ffmpeg 1> /dev/null && sudo make 1> /dev/null && sudo make install 1> /dev/null [ $? -ne 0 ] || sudo chown -R ${USER}.${USER} ${HOME}/ffmpeg 1> /dev/null if [ -f "${CMD_FFMPEG}" ] && [ -x "${CMD_FFMPEG}" ];then echo "[okay]" echo echo "Great! We can now start using ${CMD_FFMPEG}" else echo "[fail]" echo echo "Something went wrong while building ffmpeg. Please take a look at the errors above." exit 1 fi } function dia_YesNo(){ # arg1 = title # arg2 = description while true; do echo "${1}" echo -n "${2} (Y/n) " && read yn case $yn in "y" | "Y" | "" ) dia_Return="1" break ;; "n" | "N" ) dia_Return="0" break ;; * ) echo "unknown response. Asking again" ;; esac done } if [ ! -n "${CMD_FFMPEG}" ] || [ ! -x "${CMD_FFMPEG}" ];then dia_YesNo "I did not find the latest ffmpeg version at ${CMD_FFMPEG}." "Automatically try to install?" if [ "${dia_Return}" == "1" ];then sys_InstallFFMPEG fi fi if [ ! -n "${CMD_FFMPEG}" ] || [ ! -x "${CMD_FFMPEG}" ];then echo "recent ffmpeg not found at ${CMD_FFMPEG}. Aborting" exit 1 else if [ -n "${1}" ]; then echo "Initiating convert" ffm_Convert2FLV ${1} else echo "You need to specify a file to convert. Example: " echo "${0} mymovie.ogg" fi fi
#5. Richard on 20 January 2008
#4. Kevin on 13 November 2007
that goes along with this script.
Cause I believe I already explained how to include audio somewhere on that page. Thanks!
#3. Peter on 07 November 2007
Running Debian etch and I have the same issue trying to do a convert with aptitudes version of ffmpeg. Converts the video but not the audio ... any thoughts?
#2. ken on 03 November 2007
http://gallery.menalto.com/node/34767
#1. mike on 16 October 2007