-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathoggencoder.sh
executable file
·76 lines (67 loc) · 1.75 KB
/
oggencoder.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/sh
#
# Encodeur OGG basé sur GStreamer
#
# Syntaxe:
# ./mp4encoder <source>
# avec <source> : fichier video
# => Fichier au format .ogg (Theora + Vorbis)
#
# Paramètres d'encodage à modifier dans variable (VIDEO|AUDIO)_ENCODER_PARAMETERS
# - Video:
# - Audio:
#
VERSION="1.0"
SOURCE=$1
BASENAME=$(basename $1 .${1##*.})
DESTINATION=$BASENAME.ogg
VIDEO_ENCODER="theoraenc"
VIDEO_ENCODER_PARAMETERS=""
AUDIO_ENCODER="vorbisenc"
AUDIO_ENCODER_PARAMETERS=""
VIDEOAUDIO_MUXER="oggmux"
# Test des paramètres
param() {
if [ "$#" -ne "1" ]; then
echo "Syntaxe: $0 <video>"
exit 1
fi
if [ ! -r $@ ]; then
echo "Impossible de lire le fichier $@"
fi
}
# Fonction permettant de tester la présence des plugins Gstreamer
check() {
# Test plugins gstreamer
gst-inspect $VIDEO_ENCODER 2>&1 > /dev/null
if [ "$?" -ne "0" ]; then
echo "Encodeur $VIDEO_ENCODER introuvable / Installer le plugin gstreamer $VIDEO_ENCODER";
exit 10
fi
gst-inspect $AUDIO_ENCODER 2>&1 > /dev/null
if [ "$?" -ne "0" ]; then
echo "Encodeur $AUDIO_ENCODER introuvable / Installer le plugin gstreamer $AUDIO_ENCODER";
exit 11
fi
}
encode() {
# Pipeline d'encodage
PIPELINE="gst-launch -t filesrc location=$SOURCE ! progressreport ! decodebin name=decoder \
decoder. ! queue ! audioconvert ! $AUDIO_ENCODER $AUDIO_ENCODER_PARAMETERS ! queue ! \
$VIDEOAUDIO_MUXER name=muxer \
decoder. ! queue ! ffmpegcolorspace ! $VIDEO_ENCODER $VIDEO_ENCODER_PARAMETERS ! queue ! \
muxer. muxer. ! queue ! filesink location=$DESTINATION"
# Resume
echo
echo "Encodage de $SOURCE vers $DESTINATION"
echo "Paramètres video: $VIDEO_ENCODER_PARAMETERS"
echo "Paramètres audio: $AUDIO_ENCODER_PARAMETERS"
echo
# Encodage
time $PIPELINE
}
# Programme principal
param $@
check
encode
exit 0