Shell: transcoding folder fix.
parent
22e0e39a7c
commit
a9ffe6c4d3
|
@ -171,21 +171,24 @@ tc_transcode()
|
||||||
shift $(($OPTIND - 1))
|
shift $(($OPTIND - 1))
|
||||||
|
|
||||||
|
|
||||||
## Zsh compatibility
|
|
||||||
local STATUS
|
|
||||||
STATUS="$(set -o | grep 'shwordsplit' | awk '{print $2}')"
|
|
||||||
if [ "$STATUS" = "off" ]; then
|
|
||||||
set -o shwordsplit
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
tc_transcode .
|
tc_transcode .
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local OLDIFS
|
||||||
|
OLDIFS=$IFS
|
||||||
|
|
||||||
|
## Zsh compatibility
|
||||||
|
local STATUS
|
||||||
|
STATUS="$(set -o | grep 'shwordsplit' | awk '{print $2}')"
|
||||||
|
[ "$STATUS" = "off" ] && set -o shwordsplit
|
||||||
|
|
||||||
_tc_transcode()
|
_tc_transcode()
|
||||||
{
|
{
|
||||||
|
local IFS
|
||||||
|
IFS=$OLDIFS
|
||||||
|
|
||||||
echo "================================================================================"
|
echo "================================================================================"
|
||||||
ffmpeg $TC_OVERWRITE $TC_SAMPLE -i "$1" \
|
ffmpeg $TC_OVERWRITE $TC_SAMPLE -i "$1" \
|
||||||
-c:v libx264 -preset $TC_VIDEO_PRESET -crf $TC_VIDEO_QUAL $TC_VIDEO_TUNE $TC_VIDEO_OPTS \
|
-c:v libx264 -preset $TC_VIDEO_PRESET -crf $TC_VIDEO_QUAL $TC_VIDEO_TUNE $TC_VIDEO_OPTS \
|
||||||
|
@ -195,6 +198,8 @@ tc_transcode()
|
||||||
}
|
}
|
||||||
|
|
||||||
for i in "$@"; do
|
for i in "$@"; do
|
||||||
|
|
||||||
|
## Argument is a folder. We search for all video files in there.
|
||||||
if [ -d "$i" ]; then
|
if [ -d "$i" ]; then
|
||||||
|
|
||||||
local IFS
|
local IFS
|
||||||
|
@ -202,7 +207,7 @@ tc_transcode()
|
||||||
"
|
"
|
||||||
|
|
||||||
## TODO: provide max-depth as option.
|
## TODO: provide max-depth as option.
|
||||||
for i in $(find "$i" \( \
|
for j in $(find "$i" \( \
|
||||||
-iname '*.mkv' -o \
|
-iname '*.mkv' -o \
|
||||||
-iname '*.mp4' -o \
|
-iname '*.mp4' -o \
|
||||||
-iname '*.avi' -o \
|
-iname '*.avi' -o \
|
||||||
|
@ -210,22 +215,19 @@ tc_transcode()
|
||||||
-iname '*.flv' -o \
|
-iname '*.flv' -o \
|
||||||
-iname '*.wmv' -o \
|
-iname '*.wmv' -o \
|
||||||
-iname '*.mpg' \) ); do
|
-iname '*.mpg' \) ); do
|
||||||
_tc_transcode $i
|
_tc_transcode $j
|
||||||
done
|
done
|
||||||
|
|
||||||
|
## Argument is a regular file.
|
||||||
else
|
else
|
||||||
_tc_transcode "$i"
|
_tc_transcode "$i"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
## Restore Zsh previous options. This will not turn off shwordsplit if it
|
## Restore Zsh previous options. This will not turn off shwordsplit if it
|
||||||
## was on before calling the function.
|
## was on before calling the function.
|
||||||
if [ "$STATUS" = "off" ]; then
|
[ "$STATUS" = "off" ] && set +o shwordsplit
|
||||||
set +o shwordsplit
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# tc_mux()
|
# tc_mux()
|
||||||
|
|
Loading…
Reference in New Issue