Opened 3 years ago

Last modified 2 months ago

#8705 new defect

content_type option is not working with tee output

Reported by: animtim Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: tee
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no


Summary of the bug:

When using ffmpeg to send a webm video stream to an icecast server, it needs the option -content_type video/webm . It works fine for a single output, but when using a tee output (to both send the stream to the server and save to disk for example), the -content_type option is lost and default value (audio/mpeg) is used instead, so the stream on the icecast server is not readable.

I could workaround the issue locally by editing libavformat/icecast.c to replace the default value to video/webm and rebuild ffmpeg, but of course this is not a solution for most users...

Also, I tried to pass the option to the corresponding tee output but it was not recognized/not working.

So I guess it is a bug to fix... Or maybe I missed something?

How to reproduce:

-install an icecast server, with a mountpoint for video.webm, and of course adapt the source, password and url in the command below:

ffmpeg -video_size 1920x1080 -thread_queue_size 512 -framerate 30 -f x11grab -i :0.0+0,0 \
  -thread_queue_size 512 -f pulse -ac 2 -i default \
  -f webm -cluster_size_limit 2M -cluster_time_limit 5100 -content_type video/webm \
  -vf scale=640:-1 \
  -acodec libvorbis -aq 4 \
  -vcodec libvpx -b:v 1000K -crf 40 -g 150 -deadline good -threads 2 \
  -f tee -map 0:v -map 1:a "icecast://source:password@example.domain:8000/video.webm|savedVideo.webm"

ffmpeg version 4.1.5 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 8.4.0 (Mageia 8.4.0-1.mga7)

Note: tested with several distribution packages (Debian stable and sid, Manjaro), issue is the same.

Change History (9)

comment:1 by Cigaes, 3 years ago

You need to set the content_type option on the icecast output of the tee muxer, not on the tee muxer itself. Otherwise, what tee should do if muxing to WebM on one side and to Ogg on the other?

comment:2 by animtim, 3 years ago

Yes, though I tried to pass the content type option to the icecast output like this:


But it doesn't work, with this console output:

[icecast @ 0x26a4e40] Streaming WebM but appropriate content type NOT set!
[icecast @ 0x26a4e40] Set it with -content_type video/webm
[webm @ 0x268ca00] Unknown option 'content_type'
[tee @ 0x1a21180] Slave muxer #0 failed, aborting.
Could not write header for output file #0 (incorrect codec parameters ?): Option not found
Error initializing output stream 0:1 --

So, is there another way to pass the option to the icecast output that I missed?

comment:3 by Cigaes, 3 years ago

There is a problem. This syntax can only set format options, not protocol option. It should allow to set protocol options.

In the meantime, you can set protocol options with an ugly syntax, something like, IIRC, icecast,,content_type,video/webm,,://....

comment:4 by animtim, 3 years ago

ah! so I was not crazy, there is indeed a problem... "good" :)

I tried the syntax you suggested but it also doesn't work
(and I couldn't find any mention about it in the doc to check if it was correct):

[tee @ 0xaa3180] Slave 'icecast,,content_type,video/webm,,://source:password@example.domain:8000/video.webm': error opening: No such file or directory
[tee @ 0xaa3180] Slave muxer #0 failed, aborting.
Could not write header for output file #0 (incorrect codec parameters ?): No such file or directory
Error initializing output stream 0:1 --
Last edited 3 years ago by animtim (previous) (diff)

comment:6 by animtim, 3 years ago

Thanks, I'll test your patch tonight and let you know if it works.

comment:7 by Carl Eugen Hoyos, 3 years ago

Keywords: tee added
Version: unspecifiedgit-master

comment:8 by animtim, 3 years ago

I tested your patch, it works perfectly.

(as in, now "[content_type=video/webm]icecast://source:password@example.domain:8000/video.webm|savedVideo.webm" works as expected )

I hope this patch will be included in next release :)

Thanks for your fast answers and for the fix, great work!

comment:9 by tubby, 2 months ago

I have the same issue with -content_type, -ice_name and -ice_url. This works fine for 1 icecast server, but when i use tee with fifo it goes wrong

i've tried command 3, but that does also not work. Is the patch al in production? My debian FFMPEG version: ffmpeg 7:4.3.5-0+deb11u1

My command:

/usr/bin/ffmpeg -loglevel debug -nostdin -hide_banner -y -err_detect ignore_err -i rtp://@XXXXXXXXXX -reconnect 1 -reconnect_at_eof 1 -reconnect_streamed 1 -reconnect_delay_max 2 -attempt_recovery 1 -strict experimental -preset veryfast -threads 0 -acodec libmp3lame -b:a 256k -sample_rate 48000 -f tee -map 0 -content_type audio/mpeg -ice_name test123 -ice_url "http://<myserver>:4444/test.mp3" "[f=fifo:fifo_format=mp3:drop_pkts_on_overflow=1:onfail=ignore:attempt_recovery=1:recovery_wait_time=1]icecast://source:<password>@<myserver>:4444/test.mp3|[f=fifo:fifo_format=mp3:drop_pkts_on_overflow=1:onfail=ignore:attempt_recovery=1:recovery_wait_time=1]icecast://source:<password>@<myserver>:4444/test.mp3"
Last edited 2 months ago by tubby (previous) (diff)
Note: See TracTickets for help on using tickets.