Class: FFruby::VideoStream

Inherits:
Stream
  • Object
show all
Defined in:
ext/ffruby/ffrubystream.c,
ext/ffruby/ffrubystream.c

Overview

An interface to FFmpeg on video streams. Provides access to video metadata.

Instance Method Summary collapse

Methods inherited from Stream

#bit_rate, #codec, #initialize, #tag

Constructor Details

This class inherits a constructor from FFruby::Stream

Instance Method Details

#frame_aspect_ratioObject

Returns the frame aspect ratio.



116
117
118
119
120
121
122
123
124
# File 'ext/ffruby/ffrubystream.c', line 116

static VALUE ffrvs_frame_aspect_ratio(VALUE self)
{
	AVStream *stream = ffrs_get_stream(self);

	if (stream->codec->width == 0 || stream->codec->height == 0)
		return Qnil;
	else
		return rb_funcall(rb_mKernel, rb_intern("Rational"), 2, INT2NUM(stream->codec->width), INT2NUM(stream->codec->height));
}

#frame_rateObject

Returns the frame rate as a Rational.



151
152
153
154
155
156
157
158
159
160
# File 'ext/ffruby/ffrubystream.c', line 151

static VALUE ffrvs_frame_rate(VALUE self)
{
	AVStream *stream = ffrs_get_stream(self);
	ffrs_open_codec(stream);	

	if (stream->r_frame_rate.den && stream->r_frame_rate.num)
		return rb_funcall(rb_mKernel, rb_intern("Rational"), 2, INT2NUM(stream->r_frame_rate.num), INT2NUM(stream->r_frame_rate.den));
	else
		return rb_funcall(rb_mKernel, rb_intern("Rational"), 2, INT2NUM(stream->codec->time_base.den), INT2NUM(stream->codec->time_base.num));
}

#heightObject

Returns the frame height.



109
110
111
112
113
# File 'ext/ffruby/ffrubystream.c', line 109

static VALUE ffrvs_height(VALUE self)
{
	AVStream *stream = ffrs_get_stream(self);
	return INT2NUM(stream->codec->height);
}

#real_aspect_ratioObject

Returns the real aspect ratio.



138
139
140
141
142
143
144
145
146
147
148
# File 'ext/ffruby/ffrubystream.c', line 138

static VALUE ffrvs_real_aspect_ratio(VALUE self)
{
	VALUE x, y;
	x = ffrvs_frame_aspect_ratio(self);
	y = ffrvs_sample_aspect_ratio(self);

	if (x == Qnil || y == Qnil)
		return Qnil;
	else
		return rb_funcall(x, rb_intern("*"), 1, y);
}

#sample_aspect_ratioObject

Returns the sample aspect ratio.



127
128
129
130
131
132
133
134
135
# File 'ext/ffruby/ffrubystream.c', line 127

static VALUE ffrvs_sample_aspect_ratio(VALUE self)
{
	AVStream *stream = ffrs_get_stream(self);

	if (stream->codec->sample_aspect_ratio.den == 0 || stream->codec->sample_aspect_ratio.num == 0)
		return rb_funcall(rb_mKernel, rb_intern("Rational"), 2, INT2FIX(1), INT2FIX(1));
	else
		return rb_funcall(rb_mKernel, rb_intern("Rational"), 2, INT2NUM(stream->codec->sample_aspect_ratio.num), INT2NUM(stream->codec->sample_aspect_ratio.den));
}

#widthObject

Returns the frame width.



102
103
104
105
106
# File 'ext/ffruby/ffrubystream.c', line 102

static VALUE ffrvs_width(VALUE self)
{
	AVStream *stream = ffrs_get_stream(self);
	return INT2NUM(stream->codec->width);
}