Get bitrate from remote video (pure nodejs) - node.js

I have videos in s3 and am curious if there is a way the bitrate can be efficiently gained using nodejs. I'm looking to make the new lambda Aws service run against newly added s3 objects to get bitrate.
Since I need to run in just node I can't use ffmpeg here

https://github.com/ListenerApproved/node-ffprobe
just did this on my node server, use probeData.format.bit_rate

Related

Should a long Running video processing task to be done client side or server side

I was creating an application in react for uploading video and using a REST API to send that to the server and store in S3. I also wanted the simple audio version of the video for some other tasks and I am confused as to what might be the better way:
Creating audio file on the fly when it is needed using node-ffmpeg package and not store it anywhere
Start converting the video file to audio on the browser client only, and posting that to the server for storage along with the video.
Just post the video to the server and use queue system for creating a new task for video conversion to audio and then save that to the S3 storage.
The second method seems to be saving some compute power on the server but it might be a problem if the video upload completes, audio conversion is still going on and the client disconnects.
Would appreciate some help, thanks.

CDN for RTMP live streaming URL

I am new into RTMP and live streaming. We have a live stream URL rtmp://someIPaddress/match, that is getting from a 3rd party source.
what I am doing is installing flussonic streamer in an ubuntu machine in aws and put the live stream url in flussonic.
flussonic will provide a url which is using in my android app through which the end users are watching.
Is it possible to achieve CDN in my scenario? I prefer to use aws CDN but I am confused. I have only used CDN when the images are stored in aws S3 bucket.
CloudFront supports RTMP(distribution type) but only VOD, it cannot serve Live stream. The other and better way would be convert your RTMP live stream to HLS/DASH stream using Medialive and push it to Mediapackage and use CDN(CloudFront) to serve HLS/DASH stream, however I think it will be more costly then your current solution.

How can my node.js server on AWS handle multiple users generating images when node calls Python program?

I have containerized node.js code that runs on ECS. When multiple users use node.js to call a .py image generating problem, only 1 user gets the image, the rest get errors. I wonder if it appropriate to use Lambda so that the image generation multithreads.
For some reason, the containerized code which uses docker works locally, but not on AWS when multiple users access the .py function.
If users send images from mobile application, you can use aws-sdk to upload images from mobile device to AWS S3, and configure Lambda trigger for image upload.
This Lambda will process image data and return you the result.
Since Lambda from serverless world, it can handle really big amount of invocations.
So, in case if you/your team can add aws-sdk to mobile application, it's nice approach to upload image directly from device to S3, trigger Lambda to image processing and change user's data in some storage.
If you have untrusted environment, like user's browser, it's not O.K. to upload image directly from browser to S3, since to achieve this goal you have to provide AWS access keys.
So, in this case, it's O.K. to upload image to server and transfer image from server to S3.
After this, the logic keeps the same: trigger AWS Lambda, process data and update it in storage.
This behaviour will reduce load to the server and allows you to work on features, instead of working on image storing and other stuff, which will just bother your server.

How to get file from cloud storage and process as local file without downloading?

I am working on a project where I have to extract frames from a video by using ffmpeg (node.js). I first upload video to firebase storage from my client, and then I want to process it in the backend server. However, ffmpeg only accept file as if it is stored locally.
const ff =new ffmpeg('C:/Users/alexh/Desktop/alex/name.avi');
It will not work with url. I am wondering is any way I can get file from url as if it is stored locally or firebase can provide me a way to get the file? I don't want to use filebase trigger event because I want to send http request to backend server.
Thank you so much
The fluent-ffmpeg package supports operating on readable streams instead of just files. The GCS Client library supports creating a readable stream for a GCS object. By combining these you can has ffmpeg operate directly from GCS.
If you were running this on Linux or OS X, you could use GCS Fuse to mount the bucket on your filesystem and then point FFmpeg directly to it.

NodeJS piping with ffmpeg

I wanted to do a HTTP live stream on a screen cast with using ffmpeg, nodejs and html5 . I wanted it to be as real time as possible. However, I find that my video received by the client was behind by 1~2 seconds (On Chrome/Chromium). I am using vp8/webm as my codec.
I have eliminated the following factors as such:
1) Network: I have tried serving and receiving the video file locally by stating the video source to be 127.0.0.1:PORT or localhost:PORT
2) ffmpeg encoding speed:I have tried outputting the file locally, it the "delay" seems to be negligible.
3) Chrome internal buffer. The buffer was accounted to be 0.07s~0.08s.
On the nodeJS side, I have a child process that runs the ffmpeg command, and did a ffmpeg.stdout.pipe(res); <-- ffmpeg is child_process.spawn(...)
So it seems that the ffmpeg.std.pipe(res) of nodejs seems to be the one delaying the video stream. Am I correct in assuming so ? Is there anyway that I may reduce the delay ?
Go to WebRTC no need to implement any thing like codec,pipe,etc(already in chrome,opera,firefox)
Uses:
MediaCaptureAPI(access your cam and mic and convert object to URL, default they are using vp8 codec,etc)
RTCPeerconnectionAPI(send and receive media stream p2p)
RTCDatachannelAPI(send and receive data using p2p)

Resources