Last active
October 9, 2021 17:44
-
-
Save mageddo/aea6fa6037615d383f5c6380abdd4147 to your computer and use it in GitHub Desktop.
Convert Video To Youtube Format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export AV_LOG_FORCE_NOCOLOR=1 &&\ | |
FILES_TO_CONVERT=(*.MOV) &&\ | |
TOTAL=${#FILES_TO_CONVERT[@]} &&\ | |
I=0 &&\ | |
OUT_DIR=converted && mkdir -p ${OUT_DIR} &&\ | |
for IN in "${FILES_TO_CONVERT[@]}"; do | |
I=$((I + 1)) &&\ | |
OUT="${OUT_DIR}/${IN%.*}-30-fps.mp4" &&\ | |
SIZE=$(ls -lha $IN | awk '{ print $5}') &&\ | |
DURATION=$(ffmpeg -i $IN 2>&1 | grep -oP 'Duration: \K(\d+:\d+:\d+)') &&\ | |
mkdir -p converted &&\ | |
echo -e "\n\e[96m> converting ${IN} size=$SIZE, duration=$DURATION\e[96m (\e[92m${I}\e[96m of \e[92m${TOTAL}\e[96m)\e[39m" &&\ | |
ffmpeg -v warning -hide_banner -stats -i "${IN}" -crf 28 -vcodec libx264 -acodec aac -strict -2 "${OUT}" | |
done &&\ | |
beep -r 4 -d 500 -l 500 -f 2000 &&\ | |
zenity --info --width=250 --title="Conversão videos concluída" --text="A conversão está concluída" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export AV_LOG_FORCE_NOCOLOR=1 &&\ | |
FILES_TO_CONVERT=(*.MOV) &&\ | |
TOTAL=${#FILES_TO_CONVERT[@]} &&\ | |
I=0 &&\ | |
OUT_DIR=converted && mkdir -p ${OUT_DIR} &&\ | |
for IN in "${FILES_TO_CONVERT[@]}"; do | |
I=$((I + 1)) &&\ | |
OUT="${OUT_DIR}/${IN%.*}-30-fps.mp4" &&\ | |
SIZE=$(ls -lha $IN | awk '{ print $5}') &&\ | |
DURATION=$(ffmpeg -i $IN 2>&1 | grep -oP 'Duration: \K(\d+:\d+:\d+)') &&\ | |
mkdir -p converted &&\ | |
echo -e "\n\e[96m> converting ${IN} size=$SIZE, duration=$DURATION\e[96m (\e[92m${I}\e[96m of \e[92m${TOTAL}\e[96m)\e[39m" &&\ | |
ffmpeg -v warning -hide_banner -stats -i "${IN}" -crf 28 -vcodec libx264 -acodec aac -strict -2 "${OUT}" | |
done &&\ | |
zenity --info --width=250 --title="Conversão videos concluída" --text="A conversão está concluída" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Trocando o codec do áudio para AC3 que é o recomendado pelo youtube e que eu consegui ver diferenças claras no áudio, quando usando AAC as vezes chiava | |
# Usando o CODEC h264_nvenc porque ele é muito mais rápido, 8x contra 1x do libx264 | |
# Fixando o bitrate para 22M para ter a melhor qualidade vs tamanho, já que o codec h264_nvenc nao suporta o padrão CRF e não mantem uma qualidade tão boa quando deixo em rate variavel | |
# Convertendo os vídeos para 2K, assim o youtube mantem o bitrate do vídeo e não descarta os pacotes quando subo | |
export FN=edited/video.mp4 | |
ffmpeg -i DJI_0290.MP4 \ | |
-hide_banner -filter_complex "\ | |
[0:v] [0:a] \ | |
concat=n=1:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" \ | |
-c:a ac3 -b:a 192K -b:v 22M -c:v h264_nvenc "${FN}" &&\ | |
ffmpeg -i "${FN}" -vf scale=2560x1440:flags=lanczos \ | |
-c:a copy -c:v h264_nvenc -b:v 22M "${FN%.*}-2k.mp4" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment