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

👀 MediaSource Stream Possible? #1761

Closed
Fenny opened this issue Oct 19, 2019 · 5 comments
Closed

👀 MediaSource Stream Possible? #1761

Fenny opened this issue Oct 19, 2019 · 5 comments

Comments

@Fenny
Copy link

@Fenny Fenny commented Oct 19, 2019

Hi all,

Chromecast removed service workers in their latest updates and we cannot use BrowserCast anymore to cast torrent media ( from the browser )

The last hope is the "Media Source Extensions" ( MSE ) but this seems complicated and I couldn't figure out how to make it work with webtorrent.

Is it possible to use webtorrent to create an MediaSource mse-demo?

I would like to hear your thoughts, Fenny

Reference 897

@Fenny Fenny mentioned this issue Oct 19, 2019
@Fenny Fenny changed the title Chromecast MediaSource Possible? MediaSource Stream Possible? Oct 19, 2019
@Fenny Fenny changed the title MediaSource Stream Possible? 👀 MediaSource Stream Possible? Oct 19, 2019
@jimmywarting

This comment has been minimized.

Copy link
Contributor

@jimmywarting jimmywarting commented Oct 19, 2019

did chromecast remove service worker?! that's a bummer!

any references to chromecast changelog or something like that?

@Fenny

This comment has been minimized.

Copy link
Author

@Fenny Fenny commented Oct 20, 2019

I tried to look for any changelog or more information on the service worker matter but without luck.
@johanholmerin said that a recent update broke support for service workers browsercast issues 2.

With browsercast not working, I'm trying to extend my own sender library ChromecastJS with an extra feature to stream local or webtorrent files to my custom chromecast receiver.
Using the the .captureStream() function and PeerJS library instead.
So far I might found an easy fallback to cast local files / filestreams to a chromecast.

  // sender
  media = torrent.files.find(function (file) {
    return file.name.endsWith('.mp4')
  })
  media.renderTo('#video', (err, elem) => {
    stream = elem.captureStream(24)
    peer.call(peerreceiver, stream);
  })
  // chromecast receiver
  peer.on('call', function(call) {
    call.answer();
    call.on('stream', (stream) => {
      document.getElementById('video').srcObject = stream
      document.getElementById('video').play()
    })
  });

However, using a direct mp4 link works fine, but using the webtorrent file stream does not transfer the audio correctly to the receiver ( messed up audio ).
I think it has to do with the Webtorrent Videostream module

If you got any ideas, feel free to help .

edit
Audio works fine when I use the .captureStream() function to another video element on the same page. But when I switch to a webrtc stream to another peer, the audio gets all messed up.
Unless I use a direct media source 😕

edit 2
So I published the code to my receiver app to see if it works. I have good and bad news.

https://giphy.com/gifs/VcBlGiJ08eyH5Iv4KR

I managed to cast a torrent media file from the browser without any extentions.
The sound is still messed up ( weird beeps )
The framerate is awefull, I tried 0, 24, 60 fps on the captureStream function.

I think captureStream is not the way to go if we cannot fix the framerate issue.

I'm now trying to use the MediaSource API to construct the chunks directly from the createReadStream

webtorrent mediastream test

@Fenny

This comment has been minimized.

Copy link
Author

@Fenny Fenny commented Oct 21, 2019

It seems that Google has removed the ServiceWorker from the navigator object.
Why would they do this?

@jimmywarting

This comment has been minimized.

Copy link
Contributor

@jimmywarting jimmywarting commented Oct 21, 2019

😞

should file a bug report

@Fenny

This comment has been minimized.

Copy link
Author

@Fenny Fenny commented Oct 21, 2019

My bad, serviceWorker is still in the navigator object but your app needs to run in a "secure context" ( localhost or https )

google/shaka-player#2205 (comment)

The chromecast still crashes when registering a serviceworker ( even if it's empty ) while the same code works on any browser.

I think this is an underlying C++ bug in the latest chromecast firmware
https://support.google.com/chromecast/thread/17509737?hl=en

@Fenny Fenny closed this Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.