Class: VideoFile::Thumbnailer

Inherits:
Data
  • Object
show all
Defined in:
lib/video_file.rb,
ext/video_file_ext/ext.c

Instance Method Summary collapse

Constructor Details

#initialze(file, width, count = 1) ⇒ Object

Parameters:

  • file (VideoFile::File)

    a video file

  • width (Numeric)

    the desired width (pixels) of generated thumbnails

  • count (Integer) (defaults to: 1)

    the number of frames per thumbnail (concatenated horizontally)



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'ext/video_file_ext/ext.c', line 136

VALUE thumbnailer_m_initialize(int argc, VALUE* argv, VALUE self)
{
    VALUE file = Qnil;
    VALUE width = Qnil;
    VALUE count = Qnil;
    rb_scan_args(argc, argv, "21", &file, &width, &count);

    Check_TypedStruct(file, &file_type);

    Thumbnailer *thumbnailer;
    VfFile *file_;
    TypedData_Get_Struct(self, Thumbnailer, &thumbnailer_type, thumbnailer);
    TypedData_Get_Struct(file, VfFile, &file_type, file_);

    int width_ = FIX2INT(width);
    unsigned n_ = count == Qnil ? 1 : FIX2UINT(count);

    if(!vf_thumbnailer_init(&thumbnailer->thumbnailer, file_, width_, n_)) {
        rb_raise(eError, "%s", thumbnailer->thumbnailer.last_error_str);
    }
    return self;
}

Instance Method Details

#fileVideoFile::File

Returns the file associated with this thumbnailer.

Returns:



159
160
161
162
163
# File 'ext/video_file_ext/ext.c', line 159

VALUE thumbnailer_m_file(VALUE self) {
    Thumbnailer *thumbnailer;
    TypedData_Get_Struct(self, Thumbnailer, &thumbnailer_type, thumbnailer);
    return thumbnailer->file;
}

#get(position, accurate: false, filter: false) ⇒ String

Obtain a thumbnail at the given position

Parameters:

  • position (Numeric)

    position in seconds

  • accurate (Boolean) (defaults to: false)

    whether accurate seeking is desired

  • filter (Boolean) (defaults to: false)

    whether to filter out black, white and monton frames

Returns:

  • (String)

    JPEG-encoded thumbnail



12
13
14
# File 'lib/video_file.rb', line 12

def get(position, accurate: false, filter: false)
  get__(position, accurate, filter)
end