Proper JSON syntax to query about streams

Hello everyone,

I feel like I’m making progress with Janus, but I’ve hit a snag, and Googling and other forms of searching haven’t led me to a solution yet, so I’m here to ask for help.

I have Janus running, and I have the streaming plugin working, and that all seems to be reported as fine in the log output (as well as to the terminal shell), but when I try to query about streams using a JSON protocol as sent to the server using curl I get and error message.

Here’s the command and output:

$  curl -X POST http://localhost:7088/admin/streaming -H "Content-Type: application/json"     -d '{
       "janus": "message",
        "transaction": "list_streams",
        "request": "list",
        "admin_secret": "adminpwd"
}'
{
   "janus": "error",
   "transaction": "list_streams",
   "error": {
      "code": 457,
      "reason": "Unhandled request 'message' at this path"
   }

Any hints would be appreciated. Thanks, Bill

There’s no such path in the Admin API, and your request is incorrect as well. Please refer to the Admin/Monitor API documentation: message_plugin is the message you’re looking for, and our Admin API demo page has examples of how you can send it.

Okay, thank you Lorenzo. I guess I was conflating something I found in “janus.js” in the sendMessage() function that assembles a JSON query with:

let request = { "janus": "message", "body": message, "transaction": transaction };

Which maybe that goes directly to the Janus core vs. the HTTP-transport?

Anyway, if I can expand the discussion a little – I’ve copied the Janus example files to my local system, and am going to http://localhost:8000/streaming.html in my browser. The pull down menu lists the two stream protocols that I have configured (only really need one, but I’ve been testing with two – though only actually streaming to one of them at a time). Anyway, the pull down works, and when I click “Watch”, the stream connects, but I only get the audio.

Here’s what I have for the active configuration in janus.plugin.streaming.jcfg:

h264-sample: {                                                                                       
        type = "rtp"                                                                                 
        id = 10                                                                                      
        description = "H.264 live stream coming from ffmpeg"                                         
        #audio = false                                                                               
        audio = true                                                                                 
        audiopt = 111                                                                                
        audiocodec = "opus"                                                                          
        audioport = 8005                                                                             
        video = true                                                                                 
        videoport = 8004                                                                             
        #videopt = 126                                                                               
        videopt = 96                                                                                 
        videocodec = "h264"                                                                          
        videofmtp = "profile-level-id=42e01f;packetization-mode=1"                                   
        secret = "adminpwd"                                                                          
}

And Janus reports:

[...]
Loading plugin 'libjanus_streaming.so'...
[WARN]   -- Invalid type, skipping mountpoint 'dtls'...
JANUS Streaming plugin initialized!
[...]
[h264-sample] New video stream! (#1, ssrc=4109249590, index 0)
[h264-sample] New audio stream! (#0, ssrc=3499262986)
[... (now connecting with the "Watch" button)]
Creating new session: 8737537767661925; 0x7f1ed4001ab0
Creating new handle in session 8737537767661925: 8869882144794039; 0x7f1ed4001ab0 0x7f1ed40022a0
[8869882144794039] Creating ICE agent (ICE Full mode, controlling)
[WARN] [8869882144794039] Failed to add some remote candidates (added 0, expected 1)
[8869882144794039] The DTLS handshake has been completed
[janus.plugin.streaming-0x7f1ea0008fb0] WebRTC media is now available
[WARN] [8869882144794039] Failed to add some remote candidates (added 0, expected 1)
[WARN] [8869882144794039] Error resolving mDNS address (cdbbf5d7-8262-4107-8144-87ee8a199d0c.local): Error resolving “cdbbf5d7-8262-4107-8144-87ee8a199d0c.local”: Name or service not known
[WARN] [8869882144794039] Error resolving mDNS address (f7388223-fb33-4a32-ab20-2c80a936216d.local): Error resolving “f7388223-fb33-4a32-ab20-2c80a936216d.local”: Name or service not known

I feel like I’m soooo close, but just need that last little nudge to get video working.

(This is the problem with developing a useful tool that people from different backgounds – I’m more from computer graphics – who, like me, aren’t familiar with web development. Only enough to make us/me dangerous!)

Thank you so much for the tool and the help!
Bill

Update with good news. So I continued to do some Googling, and found an ffmpeg command that seems to work with my local copy of the Janus streaming.html example!

Here’s my non-functioning command:

ffmpeg -re -i ~/myvideo.mp4 -an -c:v copy -flags global_header -bsf dump_extra -f rtp rtp://localhost:8004 -vn -codec:a libopus -f rtp rtp://localhost:8005

And here’s the improved working version – though audio and video are not synchronized in the web browser playback, so more research to be done, but it’s a good feeling to be this far along:

ffmpeg -re -i ~/Videos/crumbs.mp4 -an -c:v libx264 -profile:v baseline -b:v 1M -flags global_header -bsf dump_extra -f rtp rtp://localhost:8004 -vn -codec:a libopus -f rtp rtp://localhost:8005

I guess that MP4 file wasn’t actually streaming H.264 codec, even though I had in my mind that it was created with H.264.

Also, perhaps the reencoding is why the audio and video are not synchronized in playback.

Thanks again for the tool and the forum!

1 Like