mirror of
https://github.com/tonydamage/nux-env.git
synced 2025-12-11 13:24:28 +01:00
tdm-media: Converted to nuxr-runner
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
This commit is contained in:
parent
163a2b820b
commit
851914ff75
1 changed files with 57 additions and 55 deletions
112
bin/tdm-media
112
bin/tdm-media
|
|
@ -1,68 +1,70 @@
|
||||||
#!/usr/bin/env nux-runner
|
#!/usr/bin/env nuxr-nuxsh
|
||||||
|
|
||||||
type ffmpeg > /dev/null 2>&1 && FFMPEG_OR_LIBAV=ffmpeg
|
type ffmpeg > /dev/null 2>&1 && FFMPEG_OR_LIBAV=ffmpeg
|
||||||
type avconv > /dev/null 2>&1 && FFMPEG_OR_LIBAV=avconv
|
type avconv > /dev/null 2>&1 && FFMPEG_OR_LIBAV=avconv
|
||||||
|
|
||||||
function task.video.change.container {
|
QUALITY=${QUALITY:=90}
|
||||||
CONTAINER=$1;
|
|
||||||
shift;
|
@namespace task. {
|
||||||
echo "Using $FFMPEG_OR_LIBAV for conversion."
|
|
||||||
for video in "$@"; do
|
function :video.change.container {
|
||||||
echo "Starting processing Video: $video";
|
CONTAINER=$1;
|
||||||
$FFMPEG_OR_LIBAV -i "$video" -vcodec copy -acodec copy "${video}.$CONTAINER"
|
shift;
|
||||||
echo "Processing done.";
|
echo "Using $FFMPEG_OR_LIBAV for conversion."
|
||||||
done
|
for video in "$@"; do
|
||||||
|
echo "Starting processing Video: $video";
|
||||||
|
$FFMPEG_OR_LIBAV -i "$video" -vcodec copy -acodec copy "${video}.$CONTAINER"
|
||||||
|
echo "Processing done.";
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function task.nikon-mp4 {
|
function :nikon-mp4 {
|
||||||
task.video.change.container mp4 "$@"
|
task.video.change.container mp4 "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
function task.downscale {
|
function :downscale TARGET SIZE {
|
||||||
local TARGET=$1; shift;
|
local i=0;
|
||||||
local SIZE=$1; shift
|
local count="$#";
|
||||||
local i=0;
|
mkdir -p $TARGET;
|
||||||
local count="$#";
|
for image in "$@"; do
|
||||||
mkdir -p $TARGET;
|
let "i=i+1"
|
||||||
for image in "$@"; do
|
name=$(basename $image);
|
||||||
let "i=i+1"
|
target_file=$TARGET/$name;
|
||||||
name=$(basename $image);
|
if [ -n "$PRESERVE" ]; then
|
||||||
target_file=$TARGET/$name;
|
target_dir="${TARGET}/$(dirname "$image")";
|
||||||
if [ -n "$PRESERVE" ]; then
|
mkdir -p "$target_dir";
|
||||||
target_dir="${TARGET}/$(dirname "$image")";
|
target_file="${target_dir}/$name";
|
||||||
mkdir -p "$target_dir";
|
fi
|
||||||
target_file="${target_dir}/$name";
|
echo "Image: $i/$count Downsampling $image -> $target_file"
|
||||||
fi
|
convert $image \
|
||||||
echo "Image: $i/$count Downsampling $image -> $target_file"
|
-filter Lanczos -sampling-factor 1x1 \
|
||||||
convert $image \
|
-resize "${SIZE}x${SIZE}>" \
|
||||||
-filter Lanczos -sampling-factor 1x1 \
|
-quality 90 \
|
||||||
-resize "${SIZE}x${SIZE}>" \
|
$target_file
|
||||||
-quality 90 \
|
done
|
||||||
$target_file
|
}
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## to:: <jpg|png> <image...>
|
## to:: <jpg|png> <image...>
|
||||||
##
|
##
|
||||||
## Convert image to
|
## Convert image to
|
||||||
##
|
##
|
||||||
function task.to {
|
function :to target {
|
||||||
target=$1;
|
if ! nux.check.function "media.to.$target" ; then
|
||||||
shift;
|
echo Target type "$target" is not supported.
|
||||||
if ! nux.check.function "media.to.$target" ; then
|
return -1
|
||||||
echo Target type "$target" is not supported.
|
fi
|
||||||
return -1
|
for file in "$@"; do
|
||||||
fi
|
target_dir=$(dirname "$file");
|
||||||
for file in "$@"; do
|
target_file=$(basename "$file" | sed -re 's/\.[a-z0-9_]+$//g' -e "s/\$/.$target/g" );
|
||||||
target_dir=$(dirname "$file");
|
target_full="$target_dir/$target_file";
|
||||||
target_file=$(basename "$file" | sed -re 's/\.[a-z0-9_]+$//g' -e "s/\$/.$target/g" );
|
media.to.$target "$file" "$target_full"
|
||||||
target_full="$target_dir/$target_file";
|
echo $file $target_file
|
||||||
media.to.$target "$file" "$target_full"
|
done
|
||||||
echo $file $target_file
|
}
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function media.to.jpg {
|
function media.to.jpg {
|
||||||
convert "$1" -quality 90 -auto-orient "$2"
|
convert "$1" -quality $QUALITY -auto-orient "$2"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue