how to host mp3 file with koa framework - node.js

I'm coding API server to be used in mp3 app.
I've used koa-send, koa-static, and just setting mp3 file to response-body.
But, no matter what API the app uses, the app stops. When I sent the length of the MP3 file separately because the app did not seem to accept the length of the MP3 file, it worked on iOS but not on Android.
If I post the same MP3 file on S3 and send request to that URL, it worked well, so I can't understand what the problem is.
Also, if I play music on Safari using my API, it comes out as a live broadcast. (using other sites, it comes in the form of mp3)
If it's a problem that you don't know how long it's playing, why is it the same file, but not on other sites, and not on my API?
Other storage site:
My API:

Related

Audio in safari

Hello developers community,
Currently I have task to create walkie talkie app,
I am using React.js,socket.io(for real time communication) & express js.
I am not able to play audio continuously which arrives from socket listener.
specifically in IOS safari.
I can play audio with static url(base64 data url) but not with dynamic base64.
Is there any way to contionuosly pass & play the audio.
I am free to adopt any other framework or protocol also. just need some guidence for create this type of application.
I tried Audio() api and also set UX flow to get user activity in website so that browser allows Audio() to play.

Can I stream a static image feed into a video with Node.js?

I want to create a small PoC where I can stream a static image source into a video. The idea behind that is that I have an (old) IP camera that only serves snapshots on an HTTP endpoint. When calling that endpoint, you get a static JPEG picture. Let's say, the URL I want to "convert" is: http://mycamera.local/live.jpg
Now, I want to create a script using Node.js to quickly call that URL over and over in order to form some sort of video stream. I'm not an expert into media encoding and stuff, but I guess that the variable refresh rate induced by HTTP latency, the camera's FPS... would make it a bit trickier to pipe images into a video response?
I thought I'd go with Express and Axios to serve and query HTTP content. I've also read that FFmpeg could play a role in there. But, I am open to any suggestion. I could even switch languages if that's required. This question is so specific I think, that any response would do.
A couple of requirements I cannot change:
The camera can only serve static pictures on a single endpoint.
I have no other protocol than HTTP on the camera.
I am not buying or modifying the existing hardware, even though I know there are very cheap units out there.
My server must serve a live video that could be streamed by VLC for instance.

Use Google Cloud Storage to Host Audio Files for Streaming but not Downloading

I have a bunch of audio files that I want people to be able to listen to. My website has an audio player so that people can listen to them. My audio player looks something like this (though this is simplified):
<audio>
<source src="https://storage.googleapis.com/my-bucket/my-file.mp3">
</audio>
The problem is that it would take almost no work for someone to just grab all of those MP3 urls and download the files.
Is there a way that I can make it so that it's only accessible for streaming, but not for downloading?
How do sites like SoundCloud handle this problem?
For example, SoundCloud lets you play people's songs. However, when I look in Firefox's Network tab I see that when playing a single song it's sending many requests to different MP3 files such as:
/media/3831430/3943025/c9OpfFFp3iYQ.128.mp3
/media/3192789/3352448/c9OpfFFp3iYQ.128.mp3
/media/3033128/3192788/c9OpfFFp3iYQ.128.mp3
Does anyone know what type of system they have going on there? Is this a common anti-piracy pattern for MP3 files that I could, perhaps, implement?
I was hit by the same problem, and I secured my storage bucket from the world by creating a middleware/pass-through service. Now this service has token validation of header and thus wont let your stream until you are authenticated. I used node pipe to achieve this, I hope this help. Here is sample code in js.
const http = require('http');
http.createServer(function(request, response) {
require('request')
.get("https://gcpmusicbucket.com/mp3/My-Song-1.mp3")
.pipe(response);
})
.listen(3000)

Upload videos to twitter from url in node

In my app I want to post a video to multiple networks (fb, twitter...), i'm uploading video to cloudinary and it sends back url, which I use to post to fb.
For twitter, there is no way to post a video with the url. Is there any alternatives to do this?
My server size is pretty low, like 1-2GB, so I can't download a video to my server and then create a stream to upload to twitter. I worry that if 3-4 users started to upload then my server will crash with out of memory.
Any suggestions using twit package or Simple HTTP Requests are welcome. Thanks
I had found an interesting article on how to upload your files to third party. Streaming File Uploads to Storage Server with Node.js
So you can update the code from the example with your twitter upload code.

How to play realtime binary stream through client speakers in HTML5

I need help playing a binary stream to a client's speakers using the client's web browser. The stream is being recorded from a client's web browser and is sent to a NodeJS server using BinaryJS. I have successfully streamed the binary data back to the client from the server, but cannot figure out how to play it. I am using NodeJs, BinaryJS, webAudio API, and HTML5. I have also been testing with Firefox. Has anybody done this before? Thanks in advance.
If this is an option for you, the simplest option would be to encode your data to a compressed format (say, mp3, ogg, opus, etc.), and simply put the URL in an <audio> tag.
This pages is a good introduction on how to stream mp3 from node.

Resources