class MultimediaParadise::CaptureScreen

Constants

DEFAULT_INPUT
#

DEFAULT_INPUT

#
DEFAULT_STORE_IN_THIS_DIRECTORY
#

DEFAULT_STORE_IN_THIS_DIRECTORY

This is currently hardcoded to the current working directory, but you could also use another target directory.

#
USE_THIS_SCREEN_RESOLUTION
#

USE_THIS_SCREEN_RESOLUTION

#

Public Class Methods

new( i = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/multimedia_paradise/video/capture_screen.rb, line 41
def initialize(
    i           = nil, # This variable is not in use, for now.
    run_already = true
  )
  register_sigint
  reset
  case i # Handle special instructions here. (case i)
  when :dont_run_yet
    run_already = false
    i = nil
  end
  run if run_already
end

Public Instance Methods

add(i) click to toggle source
#

add (add tag)

This method will simply add to the main system command that will be run.

#
# File lib/multimedia_paradise/video/capture_screen.rb, line 166
def add(i)
  i = i.to_s unless i.is_a? String
  i = i.dup if i.frozen?
  i.strip! # We don't want leading or trailing ' '.
  # ======================================================================= #
  # Always prepend a ' ', unless it is already there.
  # ======================================================================= #
  i.prepend ' ' unless i.start_with? ' '
  @run_this_command = @run_this_command.dup if @run_this_command.frozen?
  @run_this_command << i
end
Also aliased as: append
add_audio_support() click to toggle source
#

add_audio_support

Use this method if you wish quick support for audio.

#
# File lib/multimedia_paradise/video/capture_screen.rb, line 142
def add_audio_support
  add ' -f alsa -ac 2 -i pulse'
end
add_default_audio() click to toggle source
#

add_default_audio

#
# File lib/multimedia_paradise/video/capture_screen.rb, line 269
def add_default_audio
  add ' -f alsa -ac 2 -i hw:0'
end
add_default_format() click to toggle source
#

add_default_format

#
# File lib/multimedia_paradise/video/capture_screen.rb, line 208
def add_default_format
  add ' -f x11grab'
end
add_default_framerate() click to toggle source
#

add_default_framerate

#
# File lib/multimedia_paradise/video/capture_screen.rb, line 215
def add_default_framerate
  add ' -framerate '+@framerate
end
add_default_input() click to toggle source
#

add_default_input

#
# File lib/multimedia_paradise/video/capture_screen.rb, line 201
def add_default_input
  add DEFAULT_INPUT # This is usually ' -input :0.0'.
end
add_default_video_size() click to toggle source
#

add_default_video_size

#
# File lib/multimedia_paradise/video/capture_screen.rb, line 222
def add_default_video_size
  add ' -video_size '+resolution?
end
append(i)
Alias for: add
build_up_main_string() click to toggle source
#

build_up_main_string

#
# File lib/multimedia_paradise/video/capture_screen.rb, line 257
def build_up_main_string
  add_default_video_size # Add the default screen resolution here.
  add_default_framerate
  add_default_format
  overwrite_if_the_file_already_exists
  add_default_input
  add_default_audio
end
framerate(i)
Alias for: set_framerate
framerate=(i)
Alias for: set_framerate
main?()
Alias for: main_string?
main_string?() click to toggle source
#

main_string?

#
# File lib/multimedia_paradise/video/capture_screen.rb, line 86
def main_string?
  @run_this_command
end
Also aliased as: main?
no_threads() click to toggle source
#

no_threads

Don’t use any threads.

#
# File lib/multimedia_paradise/video/capture_screen.rb, line 106
def no_threads
  add '-threads 0'
end
overwrite_if_the_file_already_exists() click to toggle source
#

overwrite_if_the_file_already_exists

#
# File lib/multimedia_paradise/video/capture_screen.rb, line 250
def overwrite_if_the_file_already_exists
  add ' -y' # Yes, overwrite the file if it already exists.
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method MultimediaParadise::Base#reset
# File lib/multimedia_paradise/video/capture_screen.rb, line 58
def reset
  super()
  # ======================================================================= #
  # === @run_this_command
  # ======================================================================= #
  @run_this_command = 'ffmpeg' # This is the base command.
  set_framerate 25 # These are used for buildup.
  # add ' g -30' # What is this option? I have no idea.
  set_store_where DEFAULT_STORE_IN_THIS_DIRECTORY # Where to store the captured dataset.
end
resolution?() click to toggle source
#

resolution?

#
# File lib/multimedia_paradise/video/capture_screen.rb, line 181
def resolution?
  USE_THIS_SCREEN_RESOLUTION
end
run() click to toggle source
#

run (run tag)

#
# File lib/multimedia_paradise/video/capture_screen.rb, line 276
def run
  build_up_main_string
  run_main_string
end
Also aliased as: start
run_main_string() click to toggle source
#

run_main_string

#
# File lib/multimedia_paradise/video/capture_screen.rb, line 72
def run_main_string
  sanitize_main_string
  # ======================================================================= #
  # Next, show the command to the user, with some "padding".
  # ======================================================================= #
  e
  e main?
  e
  system main? # And run it finally.
end
sameq() click to toggle source
#

sameq

#
# File lib/multimedia_paradise/video/capture_screen.rb, line 156
def sameq
  '' # This option never existed, hence we won't use it. We retain this for backwards compatibility however.
end
sanitize_main_string() click to toggle source
#

sanitize_main_string (sanitize tag)

#
# File lib/multimedia_paradise/video/capture_screen.rb, line 240
def sanitize_main_string
  @run_this_command.squeeze!(' ') if @run_this_command.include? '  '
  unless main?.include? store_where?
    append store_where?
  end
end
set_duration(i) click to toggle source
#

set_duration

#
# File lib/multimedia_paradise/video/capture_screen.rb, line 149
def set_duration(i)
  add '-t '+i.to_s
end
set_framerate(i) click to toggle source
#

set_framerate

In ffmpeg, “-r” equals the “-framerate” option.

#
# File lib/multimedia_paradise/video/capture_screen.rb, line 231
def set_framerate(i)
  i = i.to_s
  @framerate = i
end
Also aliased as: framerate=, framerate
set_store_where(i)
Alias for: store_here=
size(i = '1024x768')
Alias for: size=
size=(i = '1024x768') click to toggle source
#

size= (size tag)

This is -video_size which is equal to -s option in ffmpeg.

#
# File lib/multimedia_paradise/video/capture_screen.rb, line 95
def size=(i = '1024x768')
  add('-video_size '+i)
end
Also aliased as: video_size, video_size=, size
start()
Alias for: run
store_here=(i) click to toggle source
#

store_here=

This determines where to store the captured video.

#
# File lib/multimedia_paradise/video/capture_screen.rb, line 115
def store_here=(i)
  case i
  # ======================================================================= #
  # === :pwd
  # ======================================================================= #
  when :pwd
    i = return_pwd
  end
  if i.end_with? '/'
    i = i.dup if i.frozen?
    i << 'output.mp4' # Create a .mp4 file by default.
  end
  @store_where = i
end
Also aliased as: set_store_where
store_where?() click to toggle source
#

store_where?

#
# File lib/multimedia_paradise/video/capture_screen.rb, line 133
def store_where?
  @store_where
end
vcodec(i = 'libx264')
Alias for: video_codec=
video_codec=(i = 'libx264') click to toggle source
#

video_codec

Popular video codecs for ffmpeg are:

libx264
ffv1
#
# File lib/multimedia_paradise/video/capture_screen.rb, line 194
def video_codec=(i = 'libx264')
  add " -vcodec #{i}"
end
Also aliased as: vcodec
video_size(i = '1024x768')
Alias for: size=
video_size=(i = '1024x768')
Alias for: size=