From e089b4d41dabc648535ccdc273cda596d2c41b99 Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Wed, 23 Oct 2013 19:28:53 +0200 Subject: [PATCH] tc-video-generic: dynamic audio bitrate (WIP) --- .scripts/tc-video-generic | 118 +++++++++++++++++++++++++------------- 1 file changed, 78 insertions(+), 40 deletions(-) diff --git a/.scripts/tc-video-generic b/.scripts/tc-video-generic index c9fea2ff..8801a720 100755 --- a/.scripts/tc-video-generic +++ b/.scripts/tc-video-generic @@ -1,7 +1,5 @@ #!/bin/sh -## TODO: audio quality. Copy if AAC or OGG <320k. -## mediainfo out.mkv | awk '/^Audio/{while(getline && ! index($0,"Bit rate ")); print $4}' ## TODO: handle srt encoding. if [ -z "$(command -v ffmpeg)" ]; then @@ -44,15 +42,15 @@ EOF SAMPLE="" # USER_OPT="" ## Can use environment value. VIDEO_FILTER="" -VIDEO_CODEC="-vn" -# VIDEO_CODEC="-c:v libx264 -preset slow -crf 20" +VIDEO_CODEC="-c:v libx264 -preset slow -crf 20" ## 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. -# AUDIO_CODEC="-c:a libvorbis -b:a 192k -ac 2" -AUDIO_CODEC="-c:a libvorbis -ac 2" +## description which is not available in these formats. +AUDIO_FILTER="-ac 2" +AUDIO_CODEC="libvorbis" +AUDIO_DEFAULT_RATE="192" ## What to do if file exists: # -y overwrite @@ -110,7 +108,7 @@ STATUS="$(set -o | grep 'shwordsplit' | awk '{print $2}')" _duration() { ## In seconds. - ffmpeg -i "$1" 2>&1 | awk '/Duration/ {split($2, time, /:|\./); print time[1]*60*60 + time[2]*60 + time[3]}' + ffmpeg -i "$1" 2>&1 &1 + ffmpeg -ss $i -t 10 -i "$1" -vf "cropdetect=24:2:0" -f null - 2>&1 &1 &1 &1 [$1]" STREAM_TITLE="" if $OPT_REMOVE_TITLE; then - STREAM_NUM=$(ffmpeg -i "$1" 2>&1 | grep -c 'Stream') + STREAM_NUM=$(ffmpeg -i "$1" 2>&1