question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Default Video Resolution

See original GitHub issue

So far, the implementation of this package is doing great! Question tho, how can we force resolution on 480p, 720p, or 1080p when streaming? Or upon recording of the .mp4

I was looking for parameters in the code below that might achieve the requirement. But no luck!

trans: { ffmpeg: "/usr/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]', dash: false, dashFlags: '[f=dash:window_size=3:extra_window_size=5]', mp4: true, mp4Flags: '[movflags=faststart]', } ] }

I noticed that acParam has parameters, should there be for vcParam as well?

Thanks in advance!

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

5reactions
dev-steverobcommented, Feb 13, 2020
    ffmpeg: '/usr/bin/ffmpeg',
    tasks: [
      {
        app: 'hls_1080p',
        hls: true,
        ac: 'aac',
        acParam: ['-b:a', '192k', '-ar', 48000],
        vcParams: ['-vf', "'scale=1920:-1'", '-b:v', '5000k', '-preset', 'fast', '-profile:v', 'baseline', '-bufsize', '7500k'],
        hlsFlags: '[hls_time=10:hls_list_size=0:hls_flags=delete_segments]',
      },
      {
        app: 'hls_720p',
        hls: true,
        ac: 'aac',
        acParam: ['-b:a', '128k', '-ar', 48000],
        vcParams: ['-vf', "'scale=1280:-1'", '-b:v', '2800k', '-preset', 'fast', '-profile:v', 'baseline', '-bufsize', '4200k'],
        hlsFlags: '[hls_time=10:hls_list_size=0:hls_flags=delete_segments]',
      },
      {
        app: 'hls_480p',
        hls: true,
        ac: 'aac',
        acParam: ['-b:a', '128k', '-ar', 48000],
        vcParams: ['-vf', "'scale=854:-1'", '-b:v', '1400k', '-preset', 'fast', '-profile:v', 'baseline', '-bufsize', '2100k'],
        hlsFlags: '[hls_time=10:hls_list_size=0:hls_flags=delete_segments]',
      },
      {
        app: 'hls_360p',
        hls: true,
        ac: 'aac',
        acParam: ['-b:a', '96k', '-ar', 48000],
        vcParams: ['-vf', "'scale=480:-1'", '-b:v', '800k', '-preset', 'fast', '-profile:v', 'baseline', '-bufsize', '1200k'],
        hlsFlags: '[hls_time=10:hls_list_size=0:hls_flags=delete_segments]',
      }
    ]
  }````
0reactions
iabtyagicommented, Dec 3, 2020

After struggling with the same issue for a few days and trying out various ffmpeg options, here is what I have found. Hope it helps others.

  1. It’s vcParam and not vcParams. It was discussed above but adding it to summarize. The reason vcParams appears to work is because it gets ignored and the library uses default options.
  2. The scale value in the example above and in many other samples elsewhere is within two pairs of quotes. That needs to be changed. "'scale=1280:-1'" --> 'scale=1280:-1'
  3. It is better to try out -2 instead of -1 as some codecs expect that. (Oversimplified statement, but -2 should work)
  4. I found it better to have an additional param -g with a value about double of frame rate of source video so that the .ts files generated had proper length of 2 seconds (hls_time value in my case). My input source was 15 fps, so I set -g to 30.

So here is the config that worked for me:

vc: 'libx264',
vcParam: ['-g', '30', '-vf', 'scale=1280:-2', '-b:v', '2800k', '-preset', 'fast', '-profile:v', 'baseline', '-bufsize', '4200k'],

About the scale filter: https://trac.ffmpeg.org/wiki/Scaling

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Complete List of Video Resolutions and their Pixel Size
Here's the list of video resolutions commonly used. They are classified into SD (Standard Resolution), HD (High Definition), Full HD, 4K, ...
Read more >
Video resolution & aspect ratios - Computer - YouTube Help
Recommended resolution & aspect ratios · 4320p (8k): 7680x4320 · 2160p (4K): 3840x2160 · 1440p (2k): 2560x1440 · 1080p (HD): 1920x1080 · 720p...
Read more >
How to Permanently Change YouTube Video Quality
Select the drop-down menu adjacent to Default Quality and choose your preferred quality for YouTube videos. Click Save to finish. Refresh ...
Read more >
Is there a way to set your default resolution for YouTube ...
You can edit settings for video playback in the "Playback Setup" section of "My Account" (http://www.youtube.com/account#playback/quality). There is an option ...
Read more >
YouTube Lowers Default Quality on All Videos to Standard ...
YouTube is lowering the video quality as a precautionary measure in light of the coronavirus pandemic, which is causing millions of people to ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found