Created
November 29, 2025 20:21
-
-
Save regispires/1a5345cac022717008e15d0c2839bbe9 to your computer and use it in GitHub Desktop.
Convert m4a to 48 kbps
This file contains hidden or 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
| #!/usr/bin/env bash | |
| # Verifica se um arquivo foi passado | |
| if [ -z "$1" ]; then | |
| echo "Uso: $0 arquivo.m4a" | |
| exit 1 | |
| fi | |
| INPUT="$1" | |
| # Verifica se o arquivo existe | |
| if [ ! -f "$INPUT" ]; then | |
| echo "Erro: arquivo '$INPUT' não encontrado." | |
| exit 1 | |
| fi | |
| # Obtém o bitrate em kbps via ffprobe | |
| BITRATE=$(ffprobe -v error -select_streams a:0 -show_entries stream=bit_rate \ | |
| -of default=nw=1:nk=1 "$INPUT") | |
| # Converte bits/s para kbps | |
| BITRATE_KBPS=$((BITRATE / 1000)) | |
| echo "Bitrate atual: ${BITRATE_KBPS} kbps" | |
| # Se já for 48 kbps, não faz nada | |
| if [ "$BITRATE_KBPS" -eq 48 ]; then | |
| echo "O arquivo já está em 48 kbps. Nenhuma conversão necessária." | |
| exit 0 | |
| fi | |
| # Define nome do arquivo de saída | |
| BASENAME="${INPUT%.*}" | |
| OUTPUT="${BASENAME}_48k.m4a" | |
| # Converte somente se for diferente | |
| echo "Convertendo para 48 kbps..." | |
| ffmpeg -i "$INPUT" -ac 1 -c:a aac -b:a 48k "$OUTPUT" | |
| echo "Arquivo convertido: $OUTPUT" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment