tc-audio-transcode: better way to overwrite.

master
Pierre Neidhardt 2013-05-03 23:44:53 +02:00
parent 37b76dd981
commit 521fd91459
4 changed files with 30 additions and 15 deletions

View File

@ -39,7 +39,13 @@ URxvt.clipboard.pastecmd: xclip -o -quiet
! URxvt.clipboard.copycmd: xclip -i -selection clipboard
!! Font
!! TODO: xft fonts seem to be messy with ranger image preview.
! URxvt*font : xft:Liberation Mono:pixelsize=14
URxvt*font : xft:Dejavu Sans Mono:pixelsize=14
! URxvt*font : -*-dejavu sans mono-*-*-*-*-*-*-*-*-*-*-iso8859-*
! URxvt*font : -*-dejavu sans-medium-r-*-*-14-*-*-*-*-*-*-*
!xterm*font : -*-dejavu sans-medium-r-*-*-14-*-*-*-*-*-*-*
xterm*faceName:DejaVu Sans Mono:pixelsize=12
! URxvt*boldFont : xft:Monospace:bold:pixelsize=14
! URxvt*boldFont : xft:Monospace Bold:pixelsize=12

View File

@ -105,7 +105,7 @@ EOF
## OPTIONS
CAPITAL=0
OVERWRITE=0
OVERWRITE="-n"
PREVIEW=0
SKIP=0
@ -148,7 +148,7 @@ while getopts ":a:b:cd:fg:l:n:r:t:hps" opt; do
CAPITAL=1
;;
f)
OVERWRITE=1
OVERWRITE="-y"
;;
p)
@ -310,7 +310,7 @@ OUTPUT_FOLDER=$(eval echo $OUTPUT_FOLDER)
OUTPUT_FILE=$(eval echo $OUTPUT_FILE)
if [ -e "${OUTPUT_FILE}.$OUTPUT_FORMAT" ]; then
if [ $OVERWRITE -eq 0 ]; then
if [ $OVERWRITE = "-n" ]; then
## If file exist, we append a unique timestamp to the name.
OUTPUT_FILE="$OUTPUT_FILE-$(date '+%F-%H%M%S')"
OUTPUT_MSG="$(tput setf 1)$(tput bold)(Warning: destination exists, appending timestamp.)$(tput sgr0)"
@ -397,7 +397,7 @@ STATUS="$(set -o | grep 'shwordsplit' | awk '{print $2}')"
## TAG/RECODE
## With the -map_metadata parameter we clear all metadata.
ffmpeg -i "$1" -vn -sn $OGG_PARAM \
ffmpeg $OVERWRITE -i "$1" -vn -sn $OGG_PARAM \
-map_metadata -1 \
-metadata title="$OUTPUT_TITLE" \
-metadata artist="$OUTPUT_ARTIST" \
@ -410,11 +410,6 @@ ffmpeg -i "$1" -vn -sn $OGG_PARAM \
echo
if [ $OVERWRITE -eq 1 ]; then
mv -vf "$OUTPUT_FILE.$OUTPUT_FORMAT" "$1"
echo
fi
## Restore Zsh previous options. This will not turn off shwordsplit if it
## was on before calling the function.
[ "$STATUS" = "off" ] && set +o shwordsplit

View File

@ -7,6 +7,7 @@ fi
if [ $# -ne 2 ]; then
echo "Usage: ${0##*/} VIDEO AUDIO_OUTPUT"
exit
fi
ffmpeg -i "$1" -vn -sn -c:a copy -map 0:1 "$2"

View File

@ -66,9 +66,10 @@ Transcode FILES or files found in FOLDERS to .mkv with x264 and ogg. Output
files are the same as the original, with time appended. You can customize
encoding with the TC_* variables.
-f: Overwrite existing file if any.
-h: Display this help.
-s: Sample of ten minutes.
-f: Overwrite existing file if any.
-h: Display this help.
-s: Sample of 5 minutes.
-S MIN: Sample of MIN minutes.
EOF
}
@ -79,7 +80,7 @@ TC_OVERWRITE="-n"
TC_SAMPLE=""
while getopts ":fhs" opt; do
while getopts ":fhsS:" opt; do
case $opt in
f)
TC_OVERWRITE="-y"
@ -89,7 +90,10 @@ while getopts ":fhs" opt; do
exit 1
;;
s)
TC_SAMPLE="-ss 60 -t 600"
TC_SAMPLE="-ss 60 -t 360"
;;
S)
TC_SAMPLE="-ss 60 -t $((60+60*$OPTARG))"
;;
?)
_printhelp "$0"
@ -116,14 +120,23 @@ fi
STATUS="$(set -o | grep 'shwordsplit' | awk '{print $2}')"
[ "$STATUS" = "off" ] && set -o shwordsplit
## WARNING: we mix down audio to 2 channels with '-ac 2'. This greatly reduce
## file size and avoid any confusion for playback, which is often the case when
## converting DTS to any other format because DTS has embedded channel
## description which is not available in other formats.
_tc_transcode()
{
echo "================================================================================"
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:a libvorbis -b:a $TC_VIDEO_AUDIO_QUAL \
-c:a libvorbis -b:a $TC_VIDEO_AUDIO_QUAL -ac 2 \
-c:s copy \
-map 0 "${1%.*}-$(date '+%F-%H%M%S').mkv"
# -metadata:s:a:0 title="FR (OGG Stereo)" \
# -metadata:s:a:1 title="EN (OGG Stereo)" \
# -c:a libvorbis -b:a $TC_VIDEO_AUDIO_QUAL \
# -c:a dca -b:a 500k -strict -2 \
}
for i in "$@"; do