kyriesent / node-rtsp-stream

Stream any RTSP stream and output to websocket for consumption by jsmpeg (https://github.com/phoboslab/jsmpeg). HTML5 streaming video! Requires ffmpeg.
MIT License
451 stars 166 forks source link

Fixed Video Dimensions #73

Closed Ashwin-Ramesh2607 closed 3 years ago

Ashwin-Ramesh2607 commented 3 years ago

Hi, when I create the canvas element and set a size (example width=400 and height=400), I am able to set my layout on the HTML before the stream starts. Now when I start the RTSP stream, the dimensions of my RTSP stream override the size of the canvas. As a result, the stream occupies (960 * 540) on the HTML page, and it messes up the layout entirely. Can you please suggest a fix?

florinnichifiriuc commented 3 years ago

Use '-vf':'scale=400:400' to your ffmpegOptions

stream = new Stream({
 name: 'name',
 streamUrl: 'rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov',
 wsPort: 9999,
 ffmpegOptions: { // options ffmpeg flags
  '-stats': '', // an option with no neccessary value uses a blank string
//  '-r': 15, // options with required values specify the value after the key
'-codec:a': 'mp2',
   '-ar': 44100,    
    '-ac': 1,    
'-b:a':'128k' ,
'-vf':'scale=720:-1'
 }
})
Ashwin-Ramesh2607 commented 3 years ago

@florinnichifiriuc Thanks, that worked like a charm. I like this solution, as opposed to resizing on the UI since lesser data is streamed this way.