Class: FFmpegCore::Movie

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/ffmpeg_core/movie.rb

Overview

Modern API for working with video files

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Movie

Returns a new instance of Movie.



10
11
12
13
# File 'lib/ffmpeg_core/movie.rb', line 10

def initialize(path)
  @path = path
  @probe = Probe.new(path)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/ffmpeg_core/movie.rb', line 8

def path
  @path
end

#probeObject (readonly)

Returns the value of attribute probe.



8
9
10
# File 'lib/ffmpeg_core/movie.rb', line 8

def probe
  @probe
end

Instance Method Details

#screenshot(output_path, options = {}) ⇒ String

Extract screenshot from video

Parameters:

  • output_path (String)

    Path to output image

  • options (Hash) (defaults to: {})

    Screenshot options

Options Hash (options):

  • :seek_time (Integer, Float)

    Time in seconds to seek to (default: 0)

  • :resolution (String)

    Resolution (e.g., “640x360”)

  • :quality (Integer)

    JPEG quality 2-31, lower is better (default: 2)

Returns:

  • (String)

    Path to screenshot file



44
45
46
47
# File 'lib/ffmpeg_core/movie.rb', line 44

def screenshot(output_path, options = {})
  screenshotter = Screenshot.new(path, output_path, options)
  screenshotter.extract
end

#transcode(output_path, options = {}) ⇒ String

Transcode video with modern API

Parameters:

  • output_path (String)

    Path to output file

  • options (Hash) (defaults to: {})

    Transcoding options

Options Hash (options):

  • :video_codec (String)

    Video codec (e.g., “libx264”)

  • :audio_codec (String)

    Audio codec (e.g., “aac”)

  • :video_bitrate (String, Integer)

    Video bitrate (e.g., “1000k” or 1000)

  • :audio_bitrate (String, Integer)

    Audio bitrate (e.g., “128k” or 128)

  • :resolution (String)

    Resolution (e.g., “1280x720”)

  • :frame_rate (Integer, Float)

    Frame rate (e.g., 30)

  • :custom (Array<String>)

    Custom FFmpeg flags

Returns:

  • (String)

    Path to transcoded file



31
32
33
34
# File 'lib/ffmpeg_core/movie.rb', line 31

def transcode(output_path, options = {})
  transcoder = Transcoder.new(path, output_path, options)
  transcoder.run
end