rotacionando vídeos de celular

6 views
Skip to first unread message

Jorge Barros de Abreu

unread,
Dec 29, 2017, 5:30:50 PM12/29/17
to slack-u...@googlegroups.com
Olá.

Precisa do ffmpeg instalado.
Segue script pronto:

#início do script
#INFORME O NOME DO ARQUIVO A SER ROTACIONADO COMO $1
#................INFORME O ANGULO DE ROTACAO COMO $2
#EXEMPLO: script.sh arquivo.mp4 0
#$2:
#0 = 90 ANTIHORÁRIO E GIRO VERTICAL (default).
#1 = 90 HORÁRIO.
#2 = 90 ANTIHORÁRIO.
#3 = 90 HORÁRIO E GIRO VERTICAL
#para pegar informacoes do video
informacoes(){
LARGURA=`mplayer -frames 0 -identify $ARQUIVO 2>/dev/null | grep ^VIDEO | tr -s ' ' | cut -d ' ' -f 3 | cut -d 'x' -f 1`
ALTURA=`mplayer -frames 0 -identify $ARQUIVO 2>/dev/null | grep ^VIDEO | tr -s ' ' | cut -d ' ' -f 3 | cut -d 'x' -f 2`
BITRATE=`mplayer -frames 0 -identify $ARQUIVO 2>/dev/null | grep "ID\_VIDEO\_BITRATE=" | cut -d '=' -f 2`
FRAMERATE=`mplayer -frames 0 -identify $ARQUIVO 2>/dev/null | grep ^VIDEO | tr -s ' ' | cut -d ' ' -f 4 | tr -d 'bp'`
echo "LARGURAxALTURA: LARGURA=$LARGURA ALTURA=$ALTURA"
echo "Quadros por Segundo - framerate=$FRAMERATE"
echo "Velocidade do fluxo de vídeo - bitrate=$BITRATE"
echo "Vídeo frames por segundo="`mplayer -frames 0 -identify $ARQUIVO 2>/dev/null | grep "ID\_VIDEO\_FPS=" | cut -d '=' -f 2`
}
if [ "$#" -ne 2 ]
then
echo "Precisa de dois parâmetros"
exit 1
fi
if [ "$2" -ne 0 ] && [ "$2" -ne 1 ] && [ "$2" -ne 2 ] && [ "$2" -ne 3 ]
then
echo "Valor vai de 0 a 3"
exit 1
fi
if ! [ -e $1 ]
then
echo "Arquivo nao existe"
exit 1
fi
ARQUIVO=$1
ffmpeg -i "$1" -q:v 0 -q:a 0 -vf "transpose=$2" -aspect 16:9 "rot$1"
echo "Antes:"
informacoes
ARQUIVO="rot$1"
echo "Depois:"
informacoes
#fim do script

--
Data Estelar 2458117,477986
http://sites.google.com/site/ficmatinf
Desejo-lhe Paz, Vida Longa e Prosperidade.
São Bem Vindas Mensagens no Formato texto UTF-8 com Acentos.
Reply all
Reply to author
Forward
0 new messages