#!/bin/bash #appunti per scrittura time su video # Bold BBlack='\e[1;30m' # Nero BRed='\e[1;31m' # Rosso BGreen='\e[1;32m' # Verde BYellow='\e[1;33m' # Giallo BBlue='\e[1;34m' # Blu BPurple='\e[1;35m' # Viola BCyan='\e[1;36m' # Ciano BWhite='\e[1;37m' # Bianco Color_Off='\e[0m' # Text Reset reset_console="\E[37;40m" #biancoBold echo -e $BRed'PROGRAMMA shell PER IMMISSIONE data e ora in cui il video è stato girato usando drawtext' if [[ "$1" == "" ]]; then echo -e $BWhite'Titolo video '$BYellow read titolo fi #tento di dedurre quando è stato girato il video timec=$(ffprobe -i $titolo -show_entries format_tags=creation_time -v quiet -of default=noprint_wrappers=1 ) echo -e $BWhite"Metadati creazione video "$BYellow$timec if [[ "$timec" == "" ]] ; then #costruzione nome output titolipos=`expr index "${titolo}" "."` titolipos=$(( $titolipos-1 )) nuovoct=${titolo:0:$titolipos} estensione=${titolo:$titolipos} outputct=$nuovoct'c_t'$estensione echo -e $BWhite"ATTENZIONE! Metadata tag "$BYellow"'creation_time' è vuoto."$BWhite" Digitare "$BYellow"Y"$BWhite" se si vuole inserire un tempo di creazione specifico, digitare "$BYellow"N "$BWhite"se si accetta di inserire il tempo di sistema come tag"$BYellow read scelta if [[ "$scelta" == "y" ]] || [[ "$scelta" == "Y" ]]; then echo -e $BWhite"Digitare data creazione nel seguente formato: "$BYellow"YYYY-mm-ddTHH:MM:SS.000000Z "$BWhite"(la T intermedia e la Z finale devono essere digitate maiuscole, come i separatori)" read creationstring else data=$(date '+%Y-%m-%d') echo -e $BWhite"data= "$BYellow$data tempo=$(date '+%H:%M:%S')".000000Z" echo -e $BWhite"Ora= "$BYellow$tempo timec=$data"T"$tempo echo -e $BWhite"Tag creation_time= "$BYellow$timec creationstring=$timec timec="TAG:creation_time="$creationstring fi # echo -e $BWhite"Inserimento metadata..." # ffmpeg -y -i $titolo -metadata creation_time="$creationstring" \ # -map 0 -c copy $outputct # rm $titolo # mv $outputct $titolo fi datac=${timec:18:10} orac=${timec:29:9} ore=${orac:0:2} if [[ ${ore:0:1} == "0" ]] ; then ore=${ore:1:1} fi min=${orac:3:2} if [[ ${min:0:1} == "0" ]] ; then min=${min:1:1} fi sec=${orac:6:2} if [[ ${sec:0:1} == "0" ]] ; then sec=${sec:1:1} fi echo -e $BWhite"Data creazione "$BYellow$datac$BWhite" ore: "$BYellow$orac echo -e $BWhite"ore:"$BYellow$ore$BWhite" minuti:"$BYellow$min$BWhite" secondi:"$BYellow$sec$BWhite timestamp=$(($ore*60*60+$min*60+$sec)) #----------------- #costruzione nome output titolipos=`expr index "${titolo}" "."` titolipos=$(( $titolipos-1 )) nuovo=${titolo:0:$titolipos} estensione=${titolo:$titolipos} output=$nuovo'timer'$estensione #----------------- echo -e $BWhite" Timestamp:"$BYellow$timestamp echo -e $BWhite"Famiglia font carattere? "$BGreen"(Scegliere nella cartella /usr/share/fonts/TTF/) "$BWhite"(digitare solo il nome comprensivo di estensione .ttf) Il carattere numerico digitale si trova in 'ani.ttf'"$BYellow read fontfamily echo -e $BWhite"Grandezza carattere?"$BYellow read fsz bsz=$(( $fsz/4 )) bsz=${bsz%.*} echo -e $BWhite"Colore carattere? "$BGreen"(nomeminuscolo o esa-decimale)"$BYellow read fontcolor echo -e $BWhite"Colore sfondo? "$BGreen"(nomeminuscolo o esa-decimale)"$BYellow read boxcolor echo -e $BWhite"Indice di traparenza?"$BYellow" (1 decimale)$BWhite Valori intermedi tra 0.0 (totale trasparenza) e 1.0 (totale opacità)"$BYellow read trasp echo -e $BWhite"Si desidera aggiungere testo prima e dopo il contatore? "$BYellow"1) Video girato il 00:00:01 Buona visione! 2) "$BWhite"Nessun testo, solo contatore "$BYellow" 3) Testo personalizzato "$BWhite"Scegliere 1-2-3"$BYellow read sceltat case "$sceltat" in "1") iniziale=" Video girato il " finale=" Buona visione! " ;; "2") iniziale="- " finale=' -' ;; "3") echo -e $BWhite"Digitare stringa iniziale o INVIO"$BYellow read iniziale echo -e $BWhite"Digitare stringa finale o INVIO"$BYellow read finale ;; *) iniziale="- " finale=' -' ;; esac echo -e $BWhite"Posizione verticale Y inizio scrittura counter (in senso orizzontale viene posto a metà video)?"$BYellow read y ffmpeg -i $titolo -filter_complex "[0:v]drawtext=fontfile='/usr/share/fonts/TTF/"$fontfamily"' \: \ 'text=""$iniziale""""$datac"" %{pts\:hms\:"$timestamp"}""$finale""\ \ :x=(w-text_w)/2:y="$y":fontsize="$fsz":alpha="$trasp":fontcolor="$fontcolor":box=1: \ boxcolor="$boxcolor"@0.8:boxborderw="$bsz"' [videotimer]" \ -metadata creation_time="$creationstring" \ -map "[videotimer]" -map 0:a -movflags use_metadata_tags -map_metadata 0 $output dur=$( ffprobe -i $output -show_entries format=duration -v quiet -of csv=p=0 ) echo -e $BYellow"Durata "$BWhite$output"= "$BGreen$dur exit 0