Beispiel #1
0
// Constructor for DummyReader.  Pass a framerate and samplerate.
DummyReader::DummyReader(Fraction fps, int width, int height, int sample_rate, int channels, float duration) {

	// Set key info settings
	info.has_audio = false;
	info.has_video = true;
	info.file_size = width * height * sizeof(int);
	info.vcodec = "raw";
	info.fps = fps;
	info.width = width;
	info.height = height;
	info.sample_rate = sample_rate;
	info.channels = channels;
	info.duration = duration;
	info.video_length = duration * fps.ToFloat();
	info.pixel_ratio.num = 1;
	info.pixel_ratio.den = 1;
	info.video_timebase = fps.Reciprocal();
	info.acodec = "raw";

	// Calculate the DAR (display aspect ratio)
	Fraction size(info.width * info.pixel_ratio.num, info.height * info.pixel_ratio.den);

	// Reduce size fraction
	size.Reduce();

	// Set the ratio based on the reduced fraction
	info.display_ratio.num = size.num;
	info.display_ratio.den = size.den;

	// Open and Close the reader, to populate it's attributes (such as height, width, etc...)
	Open();
	Close();
}
Beispiel #2
0
// Calculate time of a frame number, based on a framerate
float Timeline::calculate_time(long int number, Fraction rate)
{
	// Get float version of fps fraction
	float raw_fps = rate.ToFloat();

	// Return the time (in seconds) of this frame
	return float(number - 1) / raw_fps;
}