[FFmpeg-user] Help with Image render into Video

Phil Turmel philip at turmel.org
Wed Oct 23 16:40:03 CEST 2013


On 10/23/2013 10:35 AM, Phil Turmel wrote:

> And this one (especially my response w/ script):
> https://lists.libav.org/pipermail/ffmpeg-user/2010-September/thread.html#26944

Hmmm.  The archive doesn't have the attached script.  Re-attached.

HTH,

Phil

-------------- next part --------------
#! /bin/bash
#
# Create a folder containing sequentially numbered links to arbitrary files, given
# an input list of quantities vs. filenames.

if [[ -z "$1" ]] ; then
	cat <<-EOF
		Usage:
		  mklinksequence foldername < textfile

		     'foldername' will be created if necessary, and any existing contents
		  replaced.  Consecutively numbered soft links of the form 'nnnnnnnn.ext'
		  will be created from the names given in 'textfile'.  The file extension
		  will be taken from the first source file.

		     'textfile' is expected to contain a list of source file names, preceeded
		  by the desired repeat quantity, one per line.  White space separates the
		  the quantity from the source file name, and can preceed the quantity.  Lines
		  not starting with a decimal digit are discarded.
		EOF
	exit 1
fi

# Define the actual link creation function
# mklinkseq quant srcfile
# DEST, framenumber and ext are drawn from the caller's environment
mklinkseq() {
	local linkbase qty canonicalsource firstf
	let qty=$1 firstf=framenumber+1
	if ! canonicalsource="`readlink -e \"$2\"`" ; then
		echo "Source file '$2' doesn't exist!"
		exit 1
	fi
	while let framenumber++ --qty ; do
		linkbase=`printf "%08d" $framenumber`
		[[ -a "$DEST/$linkbase.$ext" ]] && rm -f "$DEST/$linkbase.$ext"
		ln -s "$canonicalsource" "$DEST/$linkbase.$ext" || exit 1
	done
	printf "Linked %08d.$ext - %08d.$ext to $2\n" $firstf $framenumber
}

# Canonicalize and create the destination folder
DEST="`readlink -m \"$1\"`"
mkdir -p "$DEST" || exit

# Frame number is incremented before each use.
let framenumber=0

# Find and process the first source filename
while read qty srcfile ; do
	let quant=qty &>/dev/null || continue
	sourcebase="`basename \"$srcfile\"`"
	ext="${sourcebase##*.}"
	if [[ -z "$ext" ]] ; then
		echo "The first source file '$srcfile' has no extension!"
		exit 1
	fi
	mklinkseq $quant $srcfile
	break
done

# Process the remaining sources
while read qty srcfile ; do
	let quant=qty &>/dev/null || continue
	mklinkseq $quant $srcfile
done

# make sure the frame numbers after the last one are deleted
while let framenumber++ ; linkbase=`printf "%08d" $framenumber` ; [[ -a "$DEST/$linkbase.$ext" ]] ; do
	rm -f "$DEST/$linkbase.$ext"
done


More information about the ffmpeg-user mailing list