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

JSMpeg not playing audio when websocket stream is used #411

Open
nikshay-psts opened this issue Dec 28, 2022 · 3 comments
Open

JSMpeg not playing audio when websocket stream is used #411

nikshay-psts opened this issue Dec 28, 2022 · 3 comments

Comments

@nikshay-psts
Copy link

I am streaming RTSP stream to web browser using ffmpeg with help of a websocket relay in node js as per the example given here https://github.com/phoboslab/jsmpeg

FFMPEG command used:
ffmpeg -rtsp_transport tcp -i rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4 -f mpegts -c:a mp2 -c:v mpeg1video http://127.0.0.1:5100/stream_from_ffmpeg

The video is playing good, but no audio, if i open the same RTSP URL above in vlc, the video plays along with the audio

@Xbai-hang
Copy link

I have the same problem.
When I used the project node-rtsp-stream, JSMpeg don't play audio.
But When I used the project: rtsp2web, JSMpeg played audio.

They all used the command: ffmpeg -i rtsp://**** -f mpegts -c:v mpeg1video -ca: mp2

So I think maybe this problem isn't caused by JSMPeg.

And I want to know if you solved this problem. If can, please tell me. Thank you.

@Xbai-hang
Copy link

I found the situation which caused this problem. Here are my ffmpeg options:

  • had problem: ffmpeg -i rtsp://**** -f mpegts -c:v mpeg1video -ca: mp2 -ar 16000
  • solved problem: ffmpeg -i rtsp://**** -f mpegts -c:v mpeg1video -ca: mp2 -ar 32000

I test the sampling rate: 16000、22050、32000、44100、48000。

My raw stream sampling rate is 16khz、and when I set the option -ar to 32000 and higher, I heard the audio sound.

I hope this can help you.

@phoboslab
Copy link
Owner

That's interesting. JSMpeg just uses the WebAudio createBuffer() function for audio, which should work with allmost all sample rates:

All browsers must support sample rates in at least the range 8,000 Hz to 96,000 Hz.

My assumption is that this issue is caused by a locked audio context. The test if WebAudio needs to be unlocked (testing only if we're running on iOS devices) is no longer true. All browsers start out with a locked context now. Proper unlocking is only handled by the VideoElement.

So, I'm not sure why the change in sample rate would fix that for you.

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

3 participants