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.
183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'ext/ffruby/ffrubystream.c', line 183
static VALUE ffrs_initialize(VALUE self, VALUE file, VALUE index)
{
AVFormatContext *fmt;
unsigned int i = FIX2UINT(index);
Data_Get_Struct(file, AVFormatContext, fmt);
if (i >= fmt->nb_streams)
rb_raise(rb_eIndexError, "Stream index out of range!");
DATA_PTR(self) = fmt->streams[i];
return self;
}
|
Instance Method Details
#bit_rate ⇒ Object
Returns the bit rate.
95 96 97 98 99 |
# File 'ext/ffruby/ffrubystream.c', line 95
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.
63 64 65 66 67 68 |
# File 'ext/ffruby/ffrubystream.c', line 63
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.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'ext/ffruby/ffrubystream.c', line 71
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);
}
|