illuspas / Node-Media-Server

A Node.js implementation of RTMP/HTTP-FLV/WS-FLV/HLS/DASH/MP4 Media Server
https://www.npmjs.com/package/node-media-server
MIT License
5.96k stars 1.52k forks source link

Stream MP4 Videos #16

Open acollazomayer opened 6 years ago

acollazomayer commented 6 years ago

Hi how can i stream a mp4 video instead of a flv video to play it in a browser. the video needs to be mp4 to be picked in a html5 video tag

illuspas commented 6 years ago

Put the demp.mp4 file in the ‘public’ directory, then you can access it through http://localhost:8000/demo.mp4

<video controls>
    <source src="http://localhost:8000/demo.mp4" type="video/mp4">
</video>

Just like normal usage.

acollazomayer commented 6 years ago

The thing is that i dont want the normal usage, i want to stream the video to the server and then pick up the stream in the browser, but it has to be an mp4, webm or ogg because the video is a 360 video and all the players that i found use the html video tag to reproduce the video

illuspas commented 6 years ago

So your need is to streaming a video file.The easy way is to use ffmpeg.

ffmpeg -re -i INPUT_FILE.mp4 -c copy -f flv rtmp://serverip/live/STREAM_NAME

If the audio or video coding is not AAC\H.264, you also need transcoding.

ffmpeg -re -i INPUT_FILE.mp4 -c:v copy -c:a aac -f flv rtmp://serverip/live/STREAM_NAME

or

ffmpeg -re -i INPUT_FILE.mp4 -c:v libx264 -tune zerolatency -c:a aac -f flv rtmp://serverip/live/STREAM_NAME

Then using flv.js to play it.

acollazomayer commented 6 years ago

However does the flv.js reproduce 360 videos?

ithustle commented 5 years ago

Put the demp.mp4 file in the ‘public’ directory, then you can access it through http://localhost:8000/demo.mp4

Hey, @illuspas . This is the only way to stream files? If I have my files on AWS s3, how can I proceed?

RupamShaw commented 4 years ago

How can I proceed for streaming videos when file is in azure container .