From fa37c01979686fe0a32001b8f2687b248c7eb16a Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Thu, 26 Mar 2020 15:19:56 -0400 Subject: [PATCH 1/1] Add avi2mp4 --- scripts/Makefile.am | 2 +- scripts/avi2mp4 | 73 +++++++++++++++++++++++++++++++++++++++++ scripts/camera-download | 52 ----------------------------- 3 files changed, 74 insertions(+), 53 deletions(-) create mode 100755 scripts/avi2mp4 delete mode 100755 scripts/camera-download diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 56cd27c..8d32e91 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -2,7 +2,7 @@ # Install scripts in $(bindir) and distribute them. dist_bin_SCRIPTS = \ - camera-download \ + avi2mp4 \ cd-erase cd-copy media-write \ cgrep \ pstopdf \ diff --git a/scripts/avi2mp4 b/scripts/avi2mp4 new file mode 100755 index 0000000..8ad5487 --- /dev/null +++ b/scripts/avi2mp4 @@ -0,0 +1,73 @@ +#!/bin/bash + +PROG_NAME=$(basename $0) + +VIDEO_OPTS="-c:v libx264 -preset veryslow -crf 15" + +print_usage() +{ + echo "${PROG_NAME} -- Conversion AVI à MP4 (x264)" + 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)" +} + +# Default values +bitrate=192k +aac=0 + +while getopts "ab:" flag ;do + case ${flag} in + a) + aac=1 + ;; + b) + bitrate=${OPTARG} + ;; + h) + print_usage + exit 0 + ;; + ?) + echo "${PROG_NAME}: Option invalide: ${OPTARG}." + echo "Essayez \`${PROG_NAME} -h' pour plus d'informations." + exit 1 + ;; + esac +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 + echo "${PROG_NAME}: Too many arguments." + echo "Essayez \`${PROG_NAME} -h' pour plus d'informations." + exit 1 +fi + +if [ ${#} -ne 1 ]; then + echo "${PROG_NAME}: Nom de fichier manquant." + echo "Essayez \`${PROG_NAME} -h' pour plus d'informations." + exit 1 +fi + +src=${1} + +# Checking if input file exist. +if [ ! -f $1 ]; then + echo "$0: File ${src} not found." + print_usage + exit 1 +fi + +dest=`echo "${src}" | sed s/\.avi$/.mp4/g` + +ffmpeg -i ${src} ${VIDEO_OPTS} ${audio_opts} ${dest} diff --git a/scripts/camera-download b/scripts/camera-download deleted file mode 100755 index 5734b67..0000000 --- a/scripts/camera-download +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh - -PROG_NAME=$(basename $0) - -MOUNTPOINT=/media/camera -DIRNAME=$(date +%Y%m%d-%Hh%M) - -print_usage() -{ - echo "Usage: ${PROG_NAME} [OPTION]..." - echo - echo "Copy and delte images from digital camera." - echo - echo "Options:" - echo " -h display this help and exit" - exit 0 -} - -while getopts "h" flag ;do - case ${flag} in - h) - print_usage - ;; - ?) - echo "${PROG_NAME}: Invalid option: ${OPTARG}." - echo "Try \`${PROG_NAME} -h' for more information." - exit 1 - ;; - esac -done -shift `expr "${OPTIND}" - 1` - -# `$#' now represents the number of arguments after the options. -# `$1' is the first argument, etc. -if [ $# -ne 0 ]; then - echo "${PROG_NAME}: Too many arguments." - echo "Try \`${PROG_NAME} -h' for more information." - exit 1 -fi - - -if ! mount | grep -q ${MOUNTPOINT}; then - mount ${MOUNTPOINT} || exit 1 -fi - -mkdir -p ~/camera/${DIRNAME} && - -mv ${MOUNTPOINT}/dcim/???_???? ~/camera/${DIRNAME} - -umount /media/camera - -exit $? -- 2.20.1