Audio pathway, from computer to headphones/speakers

Here is the script I use, to make a YT video out of a .wav file and a still-image. It’s produced according to the encoding recomendations from YT and the result is max. quality. It’s mostly just to show encoding settings for transforming a .wav to a .m4a/AAC audio file/stream, and the encoder settings for producing an MP4 video that makes YT max. happy:

#!/bin/bash

# Make a video fit for YouTube, taking as input a waw audio file and a still image.
# Video will be 1080p@6fps
# Usage: audio2video.sh AUDIOFILE.wav PICTUREFILE

test $# -ne 2  && { echo "Usage: audio2video.sh AUDIOFILE.wav PICTUREFILE"; exit 1; }

AUDIOFILE="$1"
PICTUREFILE="$2"
SHORTNAME="$(echo $AUDIOFILE | sed 's/\....$//;s/^.*\///')"
INTERMEDIATE="$SHORTNAME.m4a"

# First make an M4A audio file
echo Generating intermediate M4A audio file "./$INTERMEDIATE" ...

ffmpeg -hide_banner -i "$AUDIOFILE" -c:a aac -b:a 384k "./$INTERMEDIATE"
test $? -ne 0 && exit 1;

echo Generating video file "./$SHORTNAME.mp4" ...

ffmpeg -hide_banner -loop 1 -framerate 6 -i "$PICTUREFILE" \
        -i "$INTERMEDIATE" -c:v libx264 -preset slow \
        -tune stillimage -crf 18 -c:a copy -shortest -pix_fmt yuv420p \
        -movflags faststart -movflags negative_cts_offsets -bf 2 -flags +cgop \
        -threads 0 "$SHORTNAME.mp4"

echo Deleting intermediate file ...
rm "$INTERMEDIATE"

echo Done!

The media info of the audio part of the resulting .mp4 video is as follows:

Audio
ID                                       : 2
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2
Duration                                 : 4 min 5 s
Duration_LastFrame                       : -1 ms
Bit rate mode                            : Constant
Bit rate                                 : 353 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 10.5 MiB (56%)
Default                                  : Yes
Alternate group                          : 1

The reult is this:

Now, whether you think that’s good or bad quality, I can only say that it sounds pretty much like it sounded when it came out of my eurorack. So it is possible…

2 Likes