ffmpeg-mythtv/ffmpeg-to-mkv.sh

56 lines
1.6 KiB
Bash
Raw Normal View History

#!/bin/bash
set -e
set -x
file=${file:-"$A1"}
recordingsdir=${A2:-"/var/lib/mythtv/recordings"}
chanid=$1
starttimeutc=$2
title=${title:-"$A3"}
subtitle=${subtitle:-"$A4"}
season=${season:-"$A5"}
episode=${episode:-"$A6"}
ending=$(echo $file | awk -v FS='.' '{print $NF}')
outfile=${file/%.${ending}/.mkv}
debug=${debug:-"eval"}
ffmpeg=${ffmpeg:-"/usr/local/bin/ffmpeg"}
destdir=${destdir:-"${recordingsdir/recordings/videos\/transcode}"}
#chanid=${file:0:4}
#starttimeutc=${file:5:13}
if test $chanid -eq 1031; then
lang="fre"
else
lang="en"
fi
cmd="ionice -c 3 $ffmpeg -y -i ${recordingsdir}/${file} -f lavfi -i movie=${recordingsdir}/${file}[out0+subcc] -preset slow -crf 21 -map 0 -map -0:d -codec:a copy -map 1:s -map_metadata 1:s:0 -metadata:s:s \"language=${lang}\" -g 60 -keyint_min 30 -metadata \"title=${title}\" -metadata \"subtitle=${subtitle}\" -metadata \"season=${season}\" -metadata \"episode=${episode}\" -metadata \"service_name=$0\" ${destdir}/${outfile}"
echo Information:
echo chanid: $chanid
echo starttimeutc: $starttimeutc
echo file: $file
echo outfile: $outfile
echo recordingsdir: $recordingsdir
echo title: $title
echo subtitle: $subtitle
echo season: $season
echo episode: $episode
echo ending: $ending
echo debug: $debug
echo ffmpeg: $ffmpeg
echo destdir: $destdir
echo cmd: $cmd
$debug $cmd
exitstatus=$?
if ! test $exitstatus -eq 0; then
exit $exitstatus
fi
touch --reference="${recordingsdir}/${file}" "${destdir}/${outfile}"
myth-update-basename.sh $chanid $starttimeutc $outfile
myth-rebuild-seektable.sh $chanid $starttimeutc
exit $?