mirror of
https://github.com/nikdoof/mediatomb-config.git
synced 2025-12-25 07:39:21 +00:00
Imported config
This commit is contained in:
118
mediatomb/mediatomb-transcode
Executable file
118
mediatomb/mediatomb-transcode
Executable file
@@ -0,0 +1,118 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# This script is used by MediaTomb for transcoding support.
|
||||
#
|
||||
# Basic function that will transcode any input file into the target type
|
||||
# 'dvd' ffmpeg supports
|
||||
video_common() {
|
||||
local input="$1"
|
||||
local output="$2"
|
||||
exec ffmpeg -i "$input" -t dvd -y "$output"
|
||||
}
|
||||
|
||||
# Basic function that will transcode any input file into the wav format
|
||||
audio_common() {
|
||||
local input="$1"
|
||||
local output="$2"
|
||||
exec ffmpeg -i "$input" -f s16be -y "$output"
|
||||
}
|
||||
|
||||
transcode_matroska() {
|
||||
local input="$1"
|
||||
local output="$2"
|
||||
local alang="$3"
|
||||
local slang="$4"
|
||||
|
||||
audiofmt=`mediainfo --Inform="Audio;%Format%" "$1"`
|
||||
vidfmt=`mediainfo --Inform="Video;%Format%" "$1"`
|
||||
|
||||
echo "Format: $vidfmt/$audiofmt"
|
||||
|
||||
if [ "$vidfmt" = "AVC" ]; then
|
||||
# Already MP4, use it
|
||||
outvidfmt="copy -bsf h264_mp4toannexb"
|
||||
#outvidfmt="libx264 -level 41 -vpre normal"
|
||||
else
|
||||
outvidfmt="avc"
|
||||
fi
|
||||
|
||||
if [ "$audiofmt" = "AAC" ]; then
|
||||
outaudfmt="copy"
|
||||
else
|
||||
outaudfmt="libmp3lame -ab 192k"
|
||||
fi
|
||||
exec ffmpeg -i "$1" -vcodec $outvidfmt -acodec $outaudfmt -copyts -sameq -f mpegts -y "$2"
|
||||
}
|
||||
|
||||
# Our "main" function below.
|
||||
|
||||
USAGE="
|
||||
This script is used by MediaTomb for transcoding support. It can also serve as
|
||||
a script to transcode various files in a format suitable for streaming directly.
|
||||
|
||||
Synopsis:
|
||||
mediatomb-transcode [TRANSCODE FUNCTION OPTION] [GENERIC OPTIONS]
|
||||
|
||||
Generic Options:
|
||||
-h, --help Display this help message.
|
||||
-i, --input Input file that is meant to be transcoded.
|
||||
-o, --output Output file that will be read back by MediaTomb.
|
||||
--audio-lang Specify ISO 639 language code to use for audio.
|
||||
--subtitle-lang Specify ISO 639 language code to use for subtitles.
|
||||
|
||||
Transcode Function Options (one is required):
|
||||
--video-common Perform generic video transcoding.
|
||||
--audio-common Perform generic audio transcoding.
|
||||
--transcode-matroska Used in transcoding matroska files.
|
||||
"
|
||||
|
||||
while [ "$#" -gt "0" ]
|
||||
do
|
||||
case "$1" in
|
||||
-i|--input)
|
||||
INPUT="$2"
|
||||
shift; shift;
|
||||
;;
|
||||
-o|--output)
|
||||
OUTPUT="$2"
|
||||
shift; shift;
|
||||
;;
|
||||
--video-common)
|
||||
USE_VIDEO_COMMON=1
|
||||
shift
|
||||
;;
|
||||
--audio-common)
|
||||
USE_AUDIO_COMMON=1
|
||||
shift
|
||||
;;
|
||||
--transcode-matroska)
|
||||
USE_TRANSCODE_MATROSKA=1
|
||||
shift
|
||||
;;
|
||||
--audio-lang)
|
||||
ALANG="$2"
|
||||
shift; shift;
|
||||
;;
|
||||
--subtitle-lang)
|
||||
SLANG="$2"
|
||||
shift; shift;
|
||||
;;
|
||||
-h|--help|*)
|
||||
echo "${USAGE}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Perform specified function
|
||||
if [ $USE_VIDEO_COMMON ]; then
|
||||
video_common "$INPUT" "$OUTPUT"
|
||||
elif [ $USE_AUDIO_COMMON ]; then
|
||||
audio_common "$INPUT" "$OUTPUT"
|
||||
elif [ $USE_TRANSCODE_MATROSKA ]; then
|
||||
transcode_matroska "$INPUT" "$OUTPUT" "$ALANG" "$SLANG"
|
||||
else
|
||||
# Must specify one transcoding function
|
||||
echo "${USAGE}"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user