Skip to content

Instantly share code, notes, and snippets.

@p5150j
Created January 19, 2016 03:33
Show Gist options
  • Save p5150j/906767c4efdff3b9497a to your computer and use it in GitHub Desktop.
Save p5150j/906767c4efdff3b9497a to your computer and use it in GitHub Desktop.

Quality

Input
  • videoBitrate (aka bitrate): target average number of bits-by-seconds. The bigger the better for quality, but bigger file size and slower (more cpu). Should be based on size and fps. Recommended: height x width x fps x CONSTANT
  • desiredWidth and desiredHeight (aka size): Should be at 4:3 aspect ratio and even numbers. The bigger the better for quality (as far as bitrate allows it), but slower to encode (more cpu). Recommended: more than 800x600 on desktop recording, less for webcam.
  • desiredFrameRate (aka fps): number of frames per second being encoded. This should not affect frames (pictures) quality, but improves transitions between them. Also makes files bigger and requires proportional CPU, so video_file will start dropping frames when cpu is not enough. Recommended: more than 15 and less than 30.
  • ffmpegOptions: extra options to passed to function av_dict_set. The more relevant are:
    • deadline: encoder algorithm, controls cpu/quality rate. Recommended: deadline
    • cpu-used: from 0 to 15. the bigger the slower but also more cpu friendly. Recommended: 10 or 15
Output
  • framesRecorded: actual video frames saved to the file.
  • framesDiscarded: number of frames from videoQueue that are being discarded when it can't flush audioQueue. You should start lowering bitrate (so size and fps) to avoid it
  • laggingEncoder: true when audioQueue is not empty after encoding (probably due to processing overhead). Shouldn't happen except cpu is trashing a lot and not even audio could be encoded.

Callbacks

  • onPlaybackChanged(string): receives the new playback state:
    • stopped: from recording or paused states
    • recording: only from startRec command or paused state
    • paused: only from recording state
  • onPlaybackTimeChanged(float): updates current recording time (only works while on recording state)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment