[FFmpeg-user] ffmpeg processing in batch

Maxim Levkov maxim.levkov at gmail.com
Tue Mar 20 23:09:02 CET 2012


Hi Susan,

Without reading your script in detail, the one thing I can think of is that
you probably need to instantiate one instance per processing file and not
all files by one instance of ffmpeg. Have you tried pushing single instance
of FFMPEG against single transcoding process? Hence, if you launch multiple
instances of FFMPEG you would end up processing multiple files, just make
sure 1:1 relationship (e.g. one executed instance of FFMPEG for one
processed output).

Once I will go over your script, I might think of something else.

Regards,
Maxim Levkov

On Tue, Mar 20, 2012 at 8:24 AM, Susan James
<sjames at susanjamescompany.com>wrote:

> Hi All,
>
> I'm encoding videos with a batch script and my script will only process
> one file at a time even though I make the call to process all files listed
> in a file.list
> My command pipeline is below for both MAC and Linux.
> My batch script is attached.
>
> I can't figure out why ffmpeg refuses to process multiple files in an
> automated script.  Can someone help me with this?  Are my command pipelines
> below wanting an additional parameter to process in batch?
>
> I log to a logs.txt but the only output I get is for the one file that
> ffmpeg processes.  I've also attached the logs.txt which includes output
> from both the MAC and LINUX processing.
>
> Any help is much appreciated.  I've been working at this for days and days
> with no resolution for processing in batch.
>
> thanks!
> Susan
>
>
>
> ============ ffmpeg commands ================
> MAC
> ffmpeg -i "file1.HiRes" -ab 320k -vol 1024 -strict experimental -threads 5
> -vcodec libx264 -b:v 2000k -pix_fmt yuv420p "file1-as.mp4"
>
>
> LINUX
> ffmpeg -i "file1.HiRes" -ab 320k -vol 1024 -vcodec libx264 -b:v 2000k
> -threads 5 -pix_fmt yuv420p "file1-as.mp4"
> ==============================**================
>
> #! /bin/bash
>
> #
> # Arguments:
> #       "SourceFileDir" "TargetDir" "file.list" countToProcess
> #
>
> function usage ()
> {
>        cat << __END_USAGE__
> Usage:
>        $0 "SourceFileDir" "TargetDir" "file.list" countToProcess
>
> Example:
>
>        $0 "/source/ChandiHiResClasses" "/target" "file.list" 2
> __END_USAGE__
>
>        exit 123
> }
>
> [ $# == 4 ] || usage
>
>
> srcFileDirName=`basename "$1"`
> targFileDir="$2/${srcFileDirName}-as"
> fileList="$3"
>
> # How many files to process in each invocation
> declare -i count=$4
>
> # Create the target directory if it does not exist.
>
> echo ""
> echo -n "Checking for existence of target directory :: ${targFileDir} ... "
> if [ ! -d "${targFileDir}" ]
> then
>        echo "Creating it."
>        mkdir -p "${targFileDir}"
> else
>        echo "It Exists."
> fi
>
> cat << __EOM__
>
> Will process maximum ${count} files in this invocation, lesser if file
> list in
> "${fileList}" contains less than ${count} entries.
>
> __EOM__
>
> function updateFiles ()
> {
>        echo ""
>        echo "Processed \"$1\"."
>        echo "Updating \"${fileList}\" and \"${fileList}.done\"."
>        echo ""
>
>        # Append the names of processed file to the list of already
> processed files
>        # kept in "${fileList}.done".
>        echo "$1" >> "${fileList}.done"
>
>        # Remove the processed files from list of files kept in
> "${fileList}"
>        tempFile=`mktemp tmp.XXXXXXXXXX`
>        grep -v "^$1" "${fileList}" > "${tempFile}"
>        mv "${tempFile}" "${fileList}"
> }
>
> # Make a copy of file containing list of file names to be processed. As we
> will
> # be updating the original file after each successful run of invoked ffmpeg
> # command, we will use this copy in while loop below.
>
> listCopy=`mktemp tmp.XXXXXXXXXX`
> cp "${fileList}" "${listCopy}"
>
> declare -i i=1
> while read fileName
> do
>        if [ $i -le $count ]
>        then
>                echo "${i}. Starting with processing of \"${fileName}\" ..."
>
>                # Add similar lines to remove other extensions if needed.
>                targetFileName=${fileName/%.mov}
>
>                targetFileName="${targetFileName}-as.mp4"
>
>                echo "Target filename : \"${targetFileName}\""
>                echo ""
>                echo "Running command ..."
>                echo "ffmpeg -i \"$1/$fileName\" -ab 320k -vol 1024 -vcodec
> libx264 -b:v 2000k -pix_fmt yuv420p \"${targFileDir}/${targetFileName}\" &&
> updateFiles \"${fileName}\""
>
>                # Uncomment following command, above echo line is for
> verbose output.
>
>                ffmpeg -i "$1/$fileName" -ab 320k -vol 1024 -vcodec libx264
> -b:v 2000k -pix_fmt yuv420p "${targFileDir}/${targetFileName}" &&
> updateFiles "${fileName}"
>
>                echo "Completed processing of \"${fileName}\"."
>                echo ""
>                i=$[$i+1]       # Processed one more file.
>        else
>                break
>        fi
> done < "${listCopy}"
>
> # Remove the temporary copy of file list.
> rm ${listCopy}
>
> echo ""
> echo "Exiting this invocation of script."
>
> MAC
>
> cat /tmp/logs.txt
>
> Checking for existence of target directory ::
> /Volumes/My_Book_2//From_Birth_to_Death.HiRes-as ... It Exists.
>
> Will process maximum 5 files in this invocation, lesser if file list in
> "file.list" contains less than 5 entries.
>
> 1. Starting with processing of "From_Birth_to_Death_14.HiRes" ...
> Target filename : "From_Birth_to_Death_14.HiRes-as.mp4"
>
> Running command ...
> ffmpeg -i
> "/Volumes/LaCie_Disk_2TB/From_Birth_to_Death.HiRes/From_Birth_to_Death_14.HiRes"
> -ab 320k -vol 1024 -vcodec libx264 -b:v 2000k -pix_fmt yuv420p
> "/Volumes/My_Book_2//From_Birth_to_Death.HiRes-as/From_Birth_to_Death_14.HiRes-as.mp4"
> && updateFiles "From_Birth_to_Death_14.HiRes"
>
>
> Linux
>
>  cat /tmp/logs.txt
>
> Checking for existence of target directory ::
> /source2//From_Birth_to_Death.HiRes-as ... It Exists.
>
> Will process maximum 2 files in this invocation, lesser if file list in
> "file.list" contains less than 2 entries.
>
> 1. Starting with processing of "From_Birth_to_Death_12.HiRes" ...
> Target filename : "From_Birth_to_Death_12.HiRes-as.mp4"
>
> Running command ...
> ffmpeg -i
> "/source/From_Birth_to_Death.HiRes//From_Birth_to_Death_12.HiRes" -ab 320k
> -vol 1024 -vcodec libx264 -b:v 2000k -pix_fmt yuv420p
> "/source2//From_Birth_to_Death.HiRes-as/From_Birth_to_Death_12.HiRes-as.mp4"
> && updateFiles "From_Birth_to_Death_12.HiRes"
>
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
>


More information about the ffmpeg-user mailing list