Class: FFruby::Stream
- Inherits:
-
Object
- Object
- FFruby::Stream
- Defined in:
- ext/ffruby/ffrubystream.c,
ext/ffruby/ffrubystream.c
Overview
An interface to FFmpeg on any type of stream. Provides access to generic metadata.
Direct Known Subclasses
Instance Method Summary collapse
-
#bit_rate ⇒ Object
Returns the bit rate.
-
#codec ⇒ Object
Returns the codec name.
-
#new(file, index) ⇒ FFruby::Stream
constructor
Creates an FFruby::Stream instance using the given FFruby::File and stream index.
-
#tag ⇒ Object
Returns the FourCC tag.
Constructor Details
#new(file, index) ⇒ FFruby::Stream
Creates an FFruby::Stream instance using the given FFruby::File and stream index. This should usually only be called by FFruby itself. Access stream instances using FFruby::File#streams instead.
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'ext/ffruby/ffrubystream.c', line 173
static VALUE ffrs_initialize(VALUE self, VALUE file, VALUE index)
{
AVFormatContext *fmt;
AVStream *stream;
unsigned int i = FIX2UINT(index);
Data_Get_Struct(file, AVFormatContext, fmt);
if (i < 0 || i >= fmt->nb_streams)
rb_raise(rb_eIndexError, "Stream index out of range!");
DATA_PTR(self) = fmt->streams[i];
stream = ffrs_get_stream(self);
return self;
}
|
Instance Method Details
#bit_rate ⇒ Object
Returns the bit rate.
85 86 87 88 89 |
# File 'ext/ffruby/ffrubystream.c', line 85
static VALUE ffrs_bit_rate(VALUE self)
{
AVStream *stream = ffrs_get_stream(self);
return INT2NUM(stream->codec->bit_rate);
}
|
#codec ⇒ Object
Returns the codec name.
53 54 55 56 57 58 |
# File 'ext/ffruby/ffrubystream.c', line 53
static VALUE ffrs_codec(VALUE self)
{
AVStream *stream = ffrs_get_stream(self);
ffrs_open_codec(stream);
return rb_str_new2(stream->codec->codec->name);
}
|
#tag ⇒ Object
Returns the FourCC tag.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'ext/ffruby/ffrubystream.c', line 61
static VALUE ffrs_tag(VALUE self)
{
char tag[4];
signed int i, j;
AVStream *stream = ffrs_get_stream(self);
i = stream->codec->codec_tag;
for (j = 3; j >= 0; j -= 1)
{
tag[j] = i >> (j * 8);
i -= tag[j] << (j * 8);
}
for (j = 3; j >= 0; j -= 1)
{
if (tag[j] != '\0')
break;
}
return rb_str_new(tag, j + 1);
}
|