home | info | other | archiving
Archiving uncompressed audio
Requires: ffmpeg and node.js.
If running windows, get cygwin to run the commands.

Suppose you want to release some uncompressed music on youtube. There really isn't a way to do this natively on youtube -- the music in the audio channel will be compressed once you upload your video file. However with Pitahaya, you can use the video channel to store the uncompressed audio data. A listener can listen to your track on youtube, and if they like it and want a hard copy, they can download the video with youtube-dlc as normal, but can now extract the uncompressed audio from the video channel with pitahaya, getting the music in its original quality.
Encoding This command will convert the 16 bit 44.1 kHz uncompressed audio file audio.flac into the video output.mp4. The video will contain an uncompressed copy of the .flac file in the video channel, and an audible copy of the audio in the audio channel.
ffmpeg -nostats -loglevel 0 \
-i audio.flac \
-f s16le -acodec pcm_s16le \
-ar 44100 -ac 2 - \
| pitahaya --tx pcm \
| ffmpeg -y -i audio.flac \
-framerate 10 -f rawvideo \
-pixel_format rgba -video_size 1920x1080 \
-i - -shortest -c:v libx264 \
-crf 31 -preset veryfast \
-r 10 -g 20 -f flv output.mp4
After running the command, you will now have the file output.mp4 which can be uploaded to youtube as a normal 1080p video.  
Note: the mp4 filesize will likely be large, averaging just under 100 megabytes per minute of audio. Smaller files can be achieved by changing veryfast to medium, slow or slower but those settings will take longer to encode. Also note that this will overwrite any instance of output.mp4 that may already exist in the directory.
Decoding Download an 'archival' youtube video with the following command: (replace abcdefghijk with a valid youtube url path)
youtube-dlc -f 137 -o "outputcopy.mp4" https://youtu.be/abcdefghijk
which will save the video as outputcopy.mp4. Click here if you get any errors.
You can now extract the uncompressed audio data from the video by running the following command:
ffmpeg -nostats -loglevel 0 \
-re -i outputcopy.mp4 \
-vcodec rawvideo -pix_fmt rgba \
-r 20 -f rawvideo - \
| pitahaya --rx 1080p \
| ffmpeg -y -f s16le \
-ar 44100 -ac 2 -i - \
-f flac audiocopy.flac
After running the command, you will now have the file audiocopy.flac which will have the same audio data as the original file audio.flac.