ffmpeg publishing VP8 to Janus Gateway

2,532 views
Skip to first unread message

Alex C

unread,
Jun 2, 2016, 7:27:52 AM6/2/16
to meetecho-janus
I'm looking to use Janus Gateway to stream very low latency to a thousand viewers from a single source.

I'm aiming for VP8 video streaming since H.264 support hasn't dropped in Chrome yet.

My config is


    [gst-rpwc]
    type = rtp
    id = 1
    description = Test Stream
    audio = no
    video = yes
    videoport = 8004
    videopt = 96
    videortpmap = VP8/90000
    videofmtp = profile-level-id=42e028\;packetization-mode=1


I'm testing initially on OSX with the built in webcam. This is the pipeline 

 ffmpeg -f qtkit -video_device_index 0 -i "" -video_size 640x480 -f mpeg1video -b:v 800k -r 30

I'm just not sure how to pipe that to my Janus Gateway server! Do I _have_ to use gstreamer?

Edit: I tried ffmpeg -f qtkit -video_device_index 0 -i "" -video_size 640x480 -f mpeg1video -b:v 800k -r 30 http://x.x.x.x:8004 but I got connection refused.

Амнон Исраэли

unread,
Jun 2, 2016, 7:43:09 AM6/2/16
to meetecho-janus
mpeg1video - mean you going to use MPEG1 codec. You need VP8.

Lorenzo Miniero

unread,
Jun 2, 2016, 8:13:47 AM6/2/16
to meetecho-janus
Besides, the output must be rtp://, not http://. Finally, you don't need the packetization mode line for VP8 in the streaming plugin configuration.

L.

Alex C

unread,
Jun 2, 2016, 8:40:11 AM6/2/16
to meetecho-janus
So just videofmtp = profile-level-id=42e028

Excuse my ignorance I'm pretty new to ffmpeg and the world of encoding. Is the video format for VP8 as follows?

ffmpeg -f qtkit -video_device_index 0 -i "" -video_size 640x480 -vcodec libvpx_vp8 -f alsa -b:v 800k -r 30 rtp://x.x.x.x:8004 

I get invalid output format for -f alsa, also for -f video4linux2. What other output formats would work with OSX for VP8 encoding?

Lorenzo Miniero

unread,
Jun 2, 2016, 8:44:31 AM6/2/16
to meetecho-janus
Il giorno giovedì 2 giugno 2016 14:40:11 UTC+2, Alex C ha scritto:
So just videofmtp = profile-level-id=42e028



No, you don't need that line at all. That's only for H.264.

 
Excuse my ignorance I'm pretty new to ffmpeg and the world of encoding. Is the video format for VP8 as follows?

ffmpeg -f qtkit -video_device_index 0 -i "" -video_size 640x480 -vcodec libvpx_vp8 -f alsa -b:v 800k -r 30 rtp://x.x.x.x:8004 

I get invalid output format for -f alsa, also for -f video4linux2. What other output formats would work with OSX for VP8 encoding?



You should probably look around for examples of how to encode VP8 in tools like ffmpeg/gstreamer, as sometimes the syntax changes from version to version. I think there are some examples in the group, if you use the search feature.
The only thing's that important from the Janus Streaming plugin perspective is that 1) the codec must be coherent with what you specified in the configuration, and 2) that you send the media via RTP and not soemthing else (e.g., the HTTP you had before).

L.

Alex C

unread,
Jun 2, 2016, 9:08:26 AM6/2/16
to meetecho-janus
Thank you, definitely making progress

My config now looks like

[gst-rpwc]
type = rtp
id = 1
description = RPWC H264 test streaming
audio = no
video = yes
videoport = 8004
videopt = 100
videortpmap = VP8/90000


And my publisher looks like


ffmpeg -f avfoundation  -video_size 640x480 -framerate 30 -i "0" -b:v 800k -c:v libvpx rtp://178.62.29.190:8004

However I get the error:

Input #0, avfoundation, from '0':
  Duration: N/A, start: 84921.465000, bitrate: N/A
    Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 640x480, 30 fps, 30 tbr, 1000k tbn, 1000k tbc
[NULL @ 0x7fb50a012000] Unable to find a suitable output format for 'rtp://178.62.29.190:8004'
rtp://178.62.29.190:8004: Invalid argument 

Where does the problem lie for that? Does it need to be told an output format from Janus when it connects (and is failing to get that)? Or is the problem that Janus is reporting back the format I'm sending is invalid? 

Alex C

unread,
Jun 2, 2016, 9:12:49 AM6/2/16
to meetecho-janus
OK I needed -f rtp just before the rtp:// address!

Alex C

unread,
Jun 2, 2016, 9:51:22 AM6/2/16
to meetecho-janus
Everything appears to be "working" however my video feed only gets 1 or 2 frames every 10 seconds or so.

ffmpeg -f avfoundation -video_size 640x480 -framerate 30 -i "0" -an -c:v libvpx -f rtp rtp://x.x.x.x:8004

I think the stream itself from the publisher (my laptop) is struggling as illustrated by this gif, notice how it struggles to advance the frames... http://f.cl.ly/items/1l0L0w3M182O363F2Z1w/Screen%20Recording%202016-06-02%20at%2002.47%20pm.gif

Alex C

unread,
Jun 2, 2016, 9:52:41 AM6/2/16
to meetecho-janus
Janus doesn't report any issues:

HTTP/Janus sessions watchdog started

[test] New video stream! (ssrc=1621663919)

Creating new session: 67846169

Creating new handle in session 67846169: 3003307565

[3003307565] Creating ICE agent (ICE Full mode, controlling)

[WARN] [3003307565] Still waiting for the DTLS stack for component 1 in stream 1...

[3003307565] The DTLS handshake has been completed

WebRTC media is now available

Lorenzo Miniero

unread,
Jun 2, 2016, 9:53:31 AM6/2/16
to meetecho-janus
That's because it isn't an issue in Janus. You'll have to play a bit with the ffmpeg script to get it working as per your requirements.

L.

Амнон Исраэли

unread,
Jun 2, 2016, 5:37:14 PM6/2/16
to meetecho-janus
ffmpeg -f avfoundation -video_size 640x480 -framerate 30 -i "0" -an -c:v libvpx -f rtp rtp://x.x.x.x:8004

you tray encode video from mac camera as i understand.
with default VP8 codec setting i think encoder eat 100% of your CPU.
try add: 
-quality realtime -error-resilient default

Alex C

unread,
Jun 2, 2016, 5:49:19 PM6/2/16
to meetecho-janus
You are absolutely right! That's probably the main cause. I've added those params but it's still eating 100% of my retina macbook pro CPU

ffmpeg -f avfoundation -video_size 640x480 -framerate 25 -i "0" -an -c:v libvpx -quality realtime -error-resilient default -f rtp rtp://x.x.x.x:8004


Any other hidden params of ffmpeg I could try to make it more efficient?

Амнон Исраэли

unread,
Jun 2, 2016, 7:05:52 PM6/2/16
to meetecho-janus
You may try to add:

-threads CORE_NUMBER

but i think it's will not really help.
I did many tries to take stream from webcam with ffmpeg (doesn't matter what os mac, windows, linux)
everytime i got strange problems.

пятница, 3 июня 2016 г., 0:49:19 UTC+3 пользователь Alex C написал:

Alex C

unread,
Jun 3, 2016, 4:09:12 AM6/3/16
to meetecho-janus
I presume Janus doesn't have any plugins to encode video in a different format if I was to pipe h264 and utilise the server's processing power to convert to VP8?

Lorenzo Miniero

unread,
Jun 3, 2016, 4:11:32 AM6/3/16
to meetecho-janus
No, you have to do transcoding yourself.

L.

Амнон Исраэли

unread,
Jun 3, 2016, 4:51:35 AM6/3/16
to meetecho-janus
You can use videoroom plugin take stream from your webcam to Janus.
Chrome encoder does not eat CPU like ffmpeg do.
And do rtp forward to stream plugin.

пятница, 3 июня 2016 г., 11:09:12 UTC+3 пользователь Alex C написал:
Reply all
Reply to author
Forward
0 new messages