Here you can find every blog post in 2020, with full content.

Streaming to Icecast2 using ffmpeg


It's been a while since I last updated this blog, but I recently played around a lot with ffmpeg and my personal Icecast2 server.
So today, I want to teach you how to stream basically anything to an Icecast2 server.
This post assumes that you already have an Icecast2 server running as well as ffmpeg installed. Well then, let's crack on with the tutorial.

Streaming audio files

First of all, we're gonna stream an audio file to our Icecast2 server.
This is just a simple one-liner:

ffmpeg -re -i YOURAUDIOFILE.flac -ar 48000 -ac 2 -c:a libvorbis -aq 5 -content_type 'audio/ogg' -vn -f ogg 

This seems confusing at first, but it's actually quite simple:
-re This option causes the input file to be read at about 1x speed and not as fast as possible by your CPU, so that ffmpeg doesn't just dump all of the data onto your Icecast2 server
-i YOURAUDIOFILE.flac This is just your input file.
-ar 48000 -ac -c:a libvorbis -aq 5 This just specifies that your output should be 48000Hz stereo audio, encoded using libvorbis with a quality level of 5.
-content_type 'audio/ogg' -f ogg This tells your Icecast2 server that the audio is encoded in the ogg vorbis format.
-vn Disables video output.
icecast://source:PASSWORD@YOURICECASTSERVER:8000/MOUNTPOINT.ogg Your Icecast2 server information. Replace PASSWORD, YOURICECASTSERVER and MOUNTPOINT with the appropriate values.

Streaming an audio device

Streaming an audio device is very similar to streaming a file.
First determine your audio device name using ffmpeg -list_devices true -f dshow -i dummy and then run the following command:

ffmpeg -f dshow -i audio="YOURDEVICENAME" -ar 48000 -ac 2 -c:a libvorbis -aq 5 -content_type 'audio/ogg' -vn 
-f ogg icecast://source:PASSWORD@YOURICECASTSERVER:8000/MOUNTPOINT.ogg

It's basically the same as the previous command, with the only difference being that your input file is now a DirectShow device. As you cannot read a device faster that realtime, the -re flag is not needed anymore

Mi, 06 Mai 2020 22:54:04 +0200

youtube-dl: Ripping High-Quality Audio


Just another quick youtube-dl tutorial, this time on how to rip the audio from videos. Again, just add this to your .bashrc file

As .opus (directly from YouTube)

function ytaudiorip() { youtube-dl -f bestaudio -o tmpaudio.webm -- $1 ffmpeg -i tmpaudio.webm -c:a copy ${2}.opus rm tmpaudio.webm }

As .ogg (conversion with ffmpeg)

function ytaudiorip-ogg() { youtube-dl -f bestaudio -o tmpaudio.webm -- $1 ffmpeg -i tmpaudio.webm -b:a 160k ${2}.ogg rm tmpaudio.webm } Di, 14 Jan 2020 18:55:12 +0100

youtube-dl: Downloading Streams


Just a quick tutorial on downloading YouTube live streams, just add this to your .bashrc file

With DVR:

function streamdl-dvr() { URL=$(youtube-dl --no-warnings -f 95 -g -- $1) ffmpeg -live_start_index -180000 -i $URL -c copy ${2}.ts }

Without DVR (always in 720p)

alias streamdl="youtube-dl -f 95 --" Di, 14 Jan 2020 18:55:07 +0100