aws-samples / aws-samples/aws-simple-streaming-webapp
simple-streaming-web-app is not working
- Dominant language
- Shell
- Stars
- 30
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
Hi! I am trying to build a webrtc application that uses ivs to broadcast the video. The main requirement for my app: it must work in all major browsers (chrome, ff, edge, safari, android webview, ios safari). I found this app in aws blogs, and from first look it is exactly what I need. BUT, actually it's not working out of the box. Problems that I found so far:
**1. (minor)** It's not possible to deploy the app in a custom region, because the region is hard coded (`install_ivs_backend.sh:174`)
```sh
replace_kms="arn:aws:kms:us-east-1:${replace_accountid}:alias/aws/s3"
```
I tried to change the region to eu-north-1 but no luck. Never mind, I deployed it to us-east-1.
**2. (minor)** The pattern in `hosting/S3AndCloudFront/parameters.json` contains account id which in my case have uppercase letters. And so whenever I tried to do `aws push` it failed on the S3 bucket creation error. So I changed the pattern to be able to deploy it.
**3. (major)** `stream.js:390` captureStream is not working for Firefox 100, it tells me no such method. Idk why, in Chrome it works.
```js
let vidStreaming = stream.current.captureStream(30);
```
**4. (major)** `stream.js:380-404` the app tries to send data into websocket before it opens. So I put the media recorder `start(1000)` in the "open" listener to make it work
```js
wsRef.current.addEventListener('open', async function open(data) {
// ...
});
let vidStreaming = stream.current.captureStream(30);
let outputStream = new MediaStream();
// ...
mediaRecorder.current.addEventListener('dataavailable', (e) => {
// happens BEFORE 'open'
wsRef.current.send(e.data);
});
```
**5. (critical)** `stream.js:397-400` mimeType `video/webm` is not supported by Safari (both mac/iphone), for Safari you should use `video/mp4`. So this app will work only on Windows, Linux PC and Android. Not sure if ffmpeg will silently handle change of container.
```js
mediaRecorder.current = new MediaRecorder(outputStream, {
mimeType: 'video/webm',
videoBitsPerSecond: 3000000,
});
```
**6. (critical)** even with all of my fixes I can't test this app, because on fargate side ffmpeg didn't transcode stream, it prints:
```sh
12.05.2022, 09:55:04 FFMPEG closed, reason 1 , null arn:aws:ecs:us-east-1:373068080393:task/ivs/4c9ec5a2571344d9aa33a7f17b178cb9
ivs-webrtc
12.05.2022, 09:55:04 Connection Closed: 1006 arn:aws:ecs:us-east-1:373068080393:task/ivs/4c9ec5a2571344d9aa33a7f17b178cb9
ivs-webrtc
12.05.2022, 09:55:04 FFMPEG MSG: [aac @ 0x56385e3f5c40] Qavg: -nan arn:aws:ecs:us-east-1:373068080393:task/ivs/4c9ec5a2571344d9aa33a7f17b178cb9
ivs-webrtc
12.05.2022, 09:55:04 FFMPEG MSG: Conversion failed! arn:aws:ecs:us-east-1:373068080393:task/ivs/4c9ec5a2571344d9aa33a7f17b178cb9
ivs-webrtc
12.05.2022, 09:55:04 FFMPEG MSG: [flv @ 0x56385e3ba380] Video codec vp8 not compatible with flv arn:aws:ecs:us-east-1:373068080393:task/ivs/4c9ec5a2571344d9aa33a7f17b178cb9
ivs-webrtc
12.05.2022, 09:55:04 Could not write header for output file #0 (incorrect codec parameters ?): Function not implemented arn:aws:ecs:us-east-1:373068080393:task/ivs/4c9ec5a2571344d9aa33a7f17b178cb9
ivs-webrtc
12.05.2022, 09:55:04 Error initializing output stream 0:1 -- arn:aws:ecs:us-east-1:373068080393:task/ivs/4c9ec5a2571344d9aa33a7f17b178cb9
ivs-webrtc
12.05.2022, 09:55:04 FFMPEG MSG: Stream mapping: arn:aws:ecs:us-east-1:373068080393:task/ivs/4c9ec5a2571344d9aa33a7f17b178cb9
ivs-webrtc
12.05.2022, 09:55:04 Stream #0:1 -> #0:0 (copy) arn:aws:ecs:us-east-1:373068080393:task/ivs/4c9ec5a2571344d9aa33a7f17b178cb9
ivs-webrtc
12.05.2022, 09:55:04 Stream #0:0 -> #0:1 (opus (native) -> aac (native)) arn:aws:ecs:us-east-1:373068080393:task/ivs/4c9ec5a2571344d9aa33a7f17b178cb9
ivs-webrtc
12.05.2022, 09:55:03 FFMPEG MSG: Input #0, matroska,webm, from 'pipe:': arn:aws:ecs:us-east-1:373068080393:task/ivs/4c9ec5a2571344d9aa33a7f17b178cb9
ivs-webrtc
12.05.2022, 09:55:03 Metadata: arn:aws:ecs:us-east-1:373068080393:task/ivs/4c9ec5a2571344d9aa33a7f17b178cb9
ivs-webrtc
12.05.2022, 09:55:03 encoder : Chrome arn:aws:ecs:us-east-1:373068080393:task/ivs/4c9ec5a2571344d9aa33a7f17b178cb9
ivs-webrtc
12.05.2022, 09:55:03 Duration: N/A, start: 0.000000, bitrate: N/A arn:aws:ecs:us-east-1:373068080393:task/ivs/4c9ec5a2571344d9aa33a7f17b178cb9
ivs-webrtc
12.05.2022, 09:55:03 Stream #0:0(eng): Audio: opus, 48000 Hz, mono, fltp (default) arn:aws:ecs:us-east-1:373068080393:task/ivs/4c9ec5a2571344d9aa33a7f17b178cb9
ivs-webrtc
12.05.2022, 09:55:03 Stream #0:1(eng): Video: vp8, yuv420p(progressive), 1280x720, SAR 1:1 DAR 16:9, 29.97 tbr, 1k tbn, 1k tbc (default) arn:aws:ecs:us-east-1:373068080393:task/ivs/4c9ec5a2571344d9aa33a7f17b178cb9
ivs-webrtc
```
**FFMPEG MSG: [flv @ 0x56385e3ba380] Video codec vp8 not compatible with flv.** - seems that ffmpeg command line arguments is incorrect.
So I am very surprised that this demo app is not working even for the most popular browser - Chrome.
--
Regarding to the app architecture, for me is not clear: is app intended to manage only one webrtc publisher? I know that ffmpeg does not do any intensive cpu operations when transcoding from webrtc to rtmps, but anyway at some count of publisher you can't use the same node.
**Q1.** Do I need to scale the instance count of fargate nodes somehow, like add node for each of the 10 publisher?
**Q2.** Same for ivs channel. Do I need to create a new channel for a new publisher (1 channel == 1 publisher)? So, I need to do it programmatically?
P. S. I am not trying to complain that app is not working, overall this app is doing a lot of work, so I hope to run it finally. Thank you for your work.
Contributor guide
Assessment
This issue has not been assessed yet.