Isso pode ser feito usando somente pipes, ie. sem renomear e sem links simbólicos.
Aqui está um script que eu coloquei juntos, comentários e tudo.
Eu configurei para jogar a 1 frame por segundo.
O processamento de imagens usa o pacote netpbm
por exemplo: images-to-vid '$HOME/images" '\./img_[0-9]{4}[^/0-9]*' 1024 768
# Make a video from images whose sizes and aspect-ratios may vary.
#
# Each image is resized to fit maximized within the video frame.
# The images are positioned centrally and padded (when required)
#
# Images are sourced using 'find'.
# They are selected according to a regular expression.
# Symbolic links are ignored.
#
# Output from 'find' is sorted by path, ie. not by name alone,
# but with a -maxlevel 1, this is typically the same...
# You will need to customize the sort if this is not suitable.
#
# Note about 'find':
# This script uses 'find -regex' instead of 'find -name'.
# The pattern must match the whole returned path,
# from ^ to $ inclusive
# The -regextype option is: posix-extended
#
srceD="${1}" # Source Directory
srceR="${2}" # Source imaage extended Regex pattern
targW="${3:-800}" # Target pixel Width
targH="${4:-600}" # Target pixel Height
targB="${5:-black}" # Target Background colour (X11 colours)
targM="${6:-4}" # Target screen geometry Modulo (as required by Target codec)
TARGw=$((targW-(targW%targM))); ((TARGw==targW)) || { echo "Target Width must be divisible by $targM. Rounding down to $TARGw" 1>&2 ; targW=$TARGw; }
TARGh=$((targH-(targH%targM))); ((TARGh==targH)) || { echo "Target Height must be divisible by $targM. Rounding down to $TARGh" 1>&2 ; targH=$TARGh; }
# TODO: test for W/H == 0
cd "$srceD" || exit 2
find . -maxdepth 1 \
\( -type f \) -and -not \
\( -type l \) \
-regextype posix-extended \
-regex "$srceR" \
-print0 |
sort -z |
{
while IFS= read -d $'# Make a video from images whose sizes and aspect-ratios may vary.
#
# Each image is resized to fit maximized within the video frame.
# The images are positioned centrally and padded (when required)
#
# Images are sourced using 'find'.
# They are selected according to a regular expression.
# Symbolic links are ignored.
#
# Output from 'find' is sorted by path, ie. not by name alone,
# but with a -maxlevel 1, this is typically the same...
# You will need to customize the sort if this is not suitable.
#
# Note about 'find':
# This script uses 'find -regex' instead of 'find -name'.
# The pattern must match the whole returned path,
# from ^ to $ inclusive
# The -regextype option is: posix-extended
#
srceD="${1}" # Source Directory
srceR="${2}" # Source imaage extended Regex pattern
targW="${3:-800}" # Target pixel Width
targH="${4:-600}" # Target pixel Height
targB="${5:-black}" # Target Background colour (X11 colours)
targM="${6:-4}" # Target screen geometry Modulo (as required by Target codec)
TARGw=$((targW-(targW%targM))); ((TARGw==targW)) || { echo "Target Width must be divisible by $targM. Rounding down to $TARGw" 1>&2 ; targW=$TARGw; }
TARGh=$((targH-(targH%targM))); ((TARGh==targH)) || { echo "Target Height must be divisible by $targM. Rounding down to $TARGh" 1>&2 ; targH=$TARGh; }
# TODO: test for W/H == 0
cd "$srceD" || exit 2
find . -maxdepth 1 \
\( -type f \) -and -not \
\( -type l \) \
-regextype posix-extended \
-regex "$srceR" \
-print0 |
sort -z |
{
while IFS= read -d $'%pre%' -r file ;do
# make Composite image on coloured Background
pnmcomp -align=center -valign=middle \
<(anytopnm "$file" 2>/dev/null |
pnmscale -xysize $targW $targH) \
<(ppmmake "$targB" $targW $targH)
done |
ffmpeg -r 1 \
-f image2pipe \
-vcodec ppm \
-i - \
-y -s ${targW}x${targH} \
-vcodec mjpeg \
images.avi
}
' -r file ;do
# make Composite image on coloured Background
pnmcomp -align=center -valign=middle \
<(anytopnm "$file" 2>/dev/null |
pnmscale -xysize $targW $targH) \
<(ppmmake "$targB" $targW $targH)
done |
ffmpeg -r 1 \
-f image2pipe \
-vcodec ppm \
-i - \
-y -s ${targW}x${targH} \
-vcodec mjpeg \
images.avi
}