Search code examples
videoresolutionhttp-live-streamingrtmp

Node Media Server: Force 480p on Video Streaming


I am working on a live streaming application written in node.js using the package Node Media Server. It works great! Question tho, can we force the video streaming or playback (recorded) to 480p?

My assumption, in the config below we can see:

const config = {
    rtmp: {
        ...
    },
    http: {
        ...
    },
    trans: {
        ffmpeg: "/usr/local/bin/ffmpeg",
        tasks: [
            {
                app: 'live',
                vc: "copy",
                vcParam: [],
                ac: "aac",
                acParam: ['-ab', '64k', '-ac', '1', '-ar', '44100'],
                rtmp: true,
                rtmpApp: 'live-ac',
                hls: true,
                hlsFlags: '[hls_time=2:hls_list_size=3:hls_flags=delete_segments]',
                mp4: true,
                mp4Flags: '[movflags=faststart]',
            }
        ]
    }
};

While acParam received parameters for some codec and bitrate. vcParam should take parameters as well to control the encoding of the video.

I tried to look for some related articles regarding transcoding and some sort of configuration. I found some using nginx but this does not meet the requirement I have on node.js

Again, can we force the video streaming or playback (recorded) to 480p? Thanks in advance!


Solution

  • You used vc copy. It means it will always use the original codec of the video and not transcode it.

    You can try adding:

    vcParams: [
              '-vf',
              "'scale=854:-1'",
              '-b:v',
              '1400k',
              '-preset',
              'fast',
              '-profile:v',
              'baseline',
              '-bufsize',
              '2100k',
              '-tune',
              'zerolatency',
            ],