I'm building a program (I want to use libavformat not ffmpeg executable) to stream live video to Icecast server and it looks like FFmpeg should be able to do it. I can write the live video to a file (which is not really simple to begin with :) ) but I can't find simple code / example to how to use avformat/avio to write to Icecast (network) mount point. Any pointers to example code would be appreciated.
Asked
Active
Viewed 1,616 times
0
-
A bit dated, but see this: http://stackoverflow.com/a/9985297/362536 These days it's even easier... you can use an HTTP PUT request instead of a SOURCE request. – Brad Jul 20 '16 at 16:26
2 Answers
1
Actually it was easy. You just open the output URL as this where "xxx:yyy" is the user and the password for the mount :
const char *outputfile = "icecast://xxx:yyy@10.0.0.1:8000/xyz.mkv";
out_format = av_guess_format(NULL, outputfile, NULL);
You might need to set the content type:
av_dict_set(&out_options, "content_type", "video/x-matroska", 0);
Then you just open the URL:
avio_open2(&out_fctx->pb, outputfile, AVIO_FLAG_WRITE, NULL, &out_options) < 0);
It's tested and working.

Iasen Kostov
- 49
- 7
0
When using FFmpeg, you specify the output as an icecast:// URL:
ffmpeg -i input.mkv -content-type video/webm icecast://user:password@hostname.tld/mountpoint
It's unclear if you are using ffmpeg or libavformat directly; if there's a way to specify a URL for output in the latter case, though, just preface it with icecast:// I would assume.
Another option is to use libshout instead; it's a library designed for sending streams to an Icecast server at the appropriate rate.

Tangent 128
- 536
- 3
- 4
-
That's why I said that I'm building a program (not using ffmpeg executable). And libshout is a mess to compile under windows. I don't even want to get into that :) – Iasen Kostov Jul 19 '16 at 19:07