I have setup a nginx RTMP server and the purpose is to store videos streamed from mobile devices in MP4 format for later analysis. Although mobile devices are streaming videos in 720p resolution NodeMediaServer always store video in 540p resolution. How can I change this behaviour? Following is NodeMediaServer configuration:
const nodeMediaServerConfig = {
rtmp: {
port: 1936,
chunk_size: 60000,
gop_cache: true,
ping: 60,
ping_timeout: 10,
},
http: {
port: 8000,
mediaroot: './media',
allow_origin: '*',
},
trans: {
ffmpeg: '/usr/bin/ffmpeg',
tasks: [
{
app: 'live',
vcParam: [
"-c:v",
"libx264",
"-vf",
"scale=720:-1",
"-b:v",
"2800k",
"-bufsize",
"4200k",
"-preset",
"fast",
],
ac: 'aac',
acParam:["-b:a", "128k", "-ar", 48000],
mp4: true,
mp4Flags: '[movflags=faststart]',
},
],
},
};
Any help in this matter is highly appreciated.
Change
scale=720:-1toscale=-2:720If you use
scale=720:-1with an input of 1920x1080, it will be scaled to 720x405. If you usescale=-2:720with an input of 1920x1080, it will be scaled to 1280x720.-2will automatically calculate the appropriate value to preserve aspect (in relation to the other value), and will adjust the value to make it divisible by 2 (needed for libx264).See scale filter documentation.