Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

400 Bad Request on pushing to twitch #18

Open
tmatth opened this issue Mar 7, 2024 · 9 comments
Open

400 Bad Request on pushing to twitch #18

tmatth opened this issue Mar 7, 2024 · 9 comments

Comments

@tmatth
Copy link
Contributor

tmatth commented Mar 7, 2024

I've tried vp8, vp9 and h264 with no luck, see:
https://www.reddit.com/r/WebRTC/comments/12nc5md/twitchtv_now_supports_webrtc_ingestion_via_whip/

cc @Sean-Der

By contrast, https://github.com/ggarber/whip-go does work with twitch.tv.

@lminiero
Copy link
Member

lminiero commented Mar 8, 2024

I don't know how I'm supposed to test this. I see a static endpoint, but for tokens it says Twitch Stream Key: does this mean I should have an account or something like that?

@tmatth
Copy link
Contributor Author

tmatth commented Mar 8, 2024

I don't know how I'm supposed to test this. I see a static endpoint, but for tokens it says Twitch Stream Key: does this mean I should have an account or something like that?

Yeah you need an account (which is free), here is what I tested (after adding some args in the dockerfile):

tmatth@bellini:/big-repos/simple-whip-client$ docker run -it --rm simple-whip-client

--------------------
Simple WHIP client
------------------

WHIP endpoint:  https://g.webrtc.live-video.net:4443/v2/offer
Bearer Token:  <TWITCH_STREAM_KEY>
Trickle ICE:    no (candidates in SDP offer)
Auto STUN/TURN: no
STUN server:    stun://stun.l.google.com:19302
TURN server:    (none)
Audio pipeline: audiotestsrc is-live=true wave=red-noise ! audioconvert ! audioresample ! queue ! opusenc ! rtpopuspay pt=100 ssrc=1 ! queue ! application/x-rtp,media=audio,encoding-name=OPUS,payload=100
Video pipeline: videotestsrc is-live=true pattern=ball ! videoconvert ! queue ! x264enc speed-preset=ultrafast tune=zerolatency ! rtph264pay config-interval=1 pt=96 ssrc=2 ! queue ! application/x-rtp,media=video,encoding-name=H264,payload=96

[WHIP] Initializing the GStreamer pipeline:
webrtcbin name=sendonly bundle-policy=3  stun-server=stun://stun.l.google.com:19302  videotestsrc is-live=true pattern=ball ! videoconvert ! queue ! x264enc speed-preset=ultrafast tune=zerolatency ! rtph264pay config-interval=1 pt=96 ssrc=2 ! queue ! application/x-rtp,media=video,encoding-name=H264,payload=96 ! sendonly. audiotestsrc is-live=true wave=red-noise ! audioconvert ! audioresample ! queue ! opusenc ! rtpopuspay pt=100 ssrc=1 ! queue ! application/x-rtp,media=audio,encoding-name=OPUS,payload=100 ! sendonly.
[WHIP] Configured jitter-buffer size (latency) for PeerConnection to 200ms
[WHIP] Starting the GStreamer pipeline
[WHIP] Creating offer
[WHIP] Offer created
[WHIP] Setting local description
[WHIP] ICE gathering started...
[WHIP] ICE gathering completed
[WHIP] Sending SDP offer (1291 bytes)
[ERR] [src/whip-client.c:whip_connect:729]  [400] Bad Request
[WHIP] Disconnecting from server (HTTP error)
[WHIP] GStreamer pipeline stopped

Bye!

@lminiero
Copy link
Member

lminiero commented Mar 8, 2024

Yeah you need an account (which is free)

Created one but god the settings are so annoying. Just to create a stream I have to go through a 1000 hoops, pick a category I don't want to pick, can't make it private or unlisted who knows why. I have zero interest in giving this a go, to be honest. 400 means the server doesn't like something we send, and there's no way for me to know what just by guessing. Hopefully someone with Twitch knowledge will chime in and tell me what to fix.

@lminiero
Copy link
Member

lminiero commented Mar 8, 2024

Pinging @danjenkins as he may know who to nudge about that.

@lminiero
Copy link
Member

lminiero commented Mar 8, 2024

I enabled libsoup3 debugging, which shows this:

< HTTP/1.1 400 Bad Request
< Soup-Debug-Timestamp: 1709915007
< Soup-Debug: SoupMessage 1 (0x7f471c101c90)
< Access-Control-Allow-Headers: Content-Type, Authorization
< Access-Control-Allow-Origin: *
< Date: Fri, 08 Mar 2024 16:23:27 GMT
< Content-Length: 98
< Content-Type: text/plain; charset=utf-8
< 
< failed to handle offer: failed to create broadcast session: h264 codec is missing in the SDP offer

Apparently it doesn't like the way H.264 is negotiated.

@lminiero
Copy link
Member

lminiero commented Mar 8, 2024

I pushed a commit to enable HTTP debugging, if you want to make more tests. Adding something like -H body to the command line will debug requests and responses on the console.

@tmatth
Copy link
Contributor Author

tmatth commented Mar 8, 2024

I pushed a commit to enable HTTP debugging, if you want to make more tests. Adding something like -H body to the command line will debug requests and responses on the console.

My guess is something like missing profile-level-id here:

a=fmtp:96 packetization-mode=1;sprop-parameter-sets=Z0LAFdoFB+wFqDAwNSgAAAMACAAAAwHkeLF1,aM48gA==

vs. the functional version in OBS

a=fmtp:96 profile-level-id=42e01f;packetization-mode=1;level-asymmetry-allowed=1

If I can confirm this is just a gstreamer issue hopefully I can fix it in the dockerfile and close.

@lminiero
Copy link
Member

lminiero commented Mar 8, 2024

In my case the profile-level-id was there, just not one they'd like maybe

a=fmtp:96 packetization-mode=1;sprop-parameter-sets=Z0LAFdoFB+wFqDAwNSgAAAMACAAAAwHkeLF1,aM48gA==;profile-level-id=42c015;level-asymmetry-allowed=1

@lminiero
Copy link
Member

I haven't followed: has this been fixed by Twitch in the meanwhile?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants