projects
/
hvutilities.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
hvsp: allow to specify end commit as a label
[hvutilities.git]
/
scripts
/
avi2mp4
diff --git
a/scripts/avi2mp4
b/scripts/avi2mp4
index
c9c3042
..
9c2082f
100755
(executable)
--- a/
scripts/avi2mp4
+++ b/
scripts/avi2mp4
@@
-2,23
+2,23
@@
PROG_NAME=$(basename $0)
PROG_NAME=$(basename $0)
-VIDEO_OPTS="-c:v libx264 -preset veryslow -crf 15"
-
print_usage()
{
print_usage()
{
- echo "${PROG_NAME} -- Conversion
AVI à
MP4 (x264)"
+ echo "${PROG_NAME} -- Conversion MP4 (x264)"
echo "Usage: ${PROG_NAME} [OPTIONS...] FICHIER"
echo
echo "Options:"
echo " -a Conversion trame audio AAC (défaut=copier)"
echo "Usage: ${PROG_NAME} [OPTIONS...] FICHIER"
echo
echo "Options:"
echo " -a Conversion trame audio AAC (défaut=copier)"
- echo " -b Si option a sélectionnée, bitrate (défaut=192k)"
+ echo " -c Copie trame vidéo (défaut=conversion)"
+ echo " -b Si option \"a\" sélectionnée, bitrate (défaut=192k)"
}
# Default values
bitrate=192k
aac=0
}
# Default values
bitrate=192k
aac=0
+video_copy=0
-while getopts "ab:
" flag ;
do
+while getopts "ab:
ch" flag ;
do
case ${flag} in
a)
aac=1
case ${flag} in
a)
aac=1
@@
-26,6
+26,9
@@
while getopts "ab:" flag ;do
b)
bitrate=${OPTARG}
;;
b)
bitrate=${OPTARG}
;;
+ c)
+ video_copy=1
+ ;;
h)
print_usage
exit 0
h)
print_usage
exit 0
@@
-39,12
+42,6
@@
while getopts "ab:" flag ;do
done
shift `expr "${OPTIND}" - 1`
done
shift `expr "${OPTIND}" - 1`
-if [ x"${aac}" = x1 ]; then
- audio_opts="-c:a aac -b:a ${bitrate}"
-else
- audio_opts="-c:a copy"
-fi
-
# `$#' now represents the number of arguments after the options.
# `$1' is the first argument, etc.
if [ $# -gt 1 ]; then
# `$#' now represents the number of arguments after the options.
# `$1' is the first argument, etc.
if [ $# -gt 1 ]; then
@@
-59,15
+56,29
@@
if [ ${#} -ne 1 ]; then
exit 1
fi
exit 1
fi
+if [ x"${aac}" = x1 ]; then
+ audio_opts="-c:a aac -b:a ${bitrate}"
+else
+ audio_opts="-c:a copy"
+fi
+
+if [ x"${video_copy}" = x1 ]; then
+ video_opts="-c:v copy"
+else
+ video_opts="-c:v libx264 -preset veryslow -crf 15"
+fi
+
src="${1}"
# Checking if input file exist.
src="${1}"
# Checking if input file exist.
-if [ ! -f
$1
]; then
+if [ ! -f
"${src}"
]; then
echo "$0: File ${src} not found."
print_usage
exit 1
fi
echo "$0: File ${src} not found."
print_usage
exit 1
fi
-dest=`echo "${src}" | sed s/\.avi$/.mp4/g`
+# Cut everything after the last dot using sed:
+dest=`echo "${src}" | sed s/\.[^.]*$//`
+dest="${dest}.mp4"
-ffmpeg -i "${src}" ${
VIDEO_OPTS
} ${audio_opts} "${dest}"
+ffmpeg -i "${src}" ${
video_opts
} ${audio_opts} "${dest}"