28 #include "../include/QtImageReader.h" 55 image = std::shared_ptr<QImage>(
new QImage());
56 bool success = image->load(QString::fromStdString(path));
59 image = std::shared_ptr<QImage>(
new QImage(image->convertToFormat(QImage::Format_RGBA8888)));
63 throw InvalidFile(
"File could not be opened.", path);
121 if (cached_image && (cached_image->width() != width && cached_image->height() != height))
123 cached_image.reset();
134 throw ReaderClosed(
"The Image is closed. Call Open() before calling this method.", path);
145 cached_image = std::shared_ptr<QImage>(
new QImage(image->scaled(
max_width,
max_height, Qt::KeepAspectRatio, Qt::SmoothTransformation)));
146 cached_image = std::shared_ptr<QImage>(
new QImage(cached_image->convertToFormat(QImage::Format_RGBA8888)));
153 image_frame->AddImage(cached_image);
164 image_frame->AddImage(image);
183 root[
"type"] =
"QtImageReader";
196 bool success = reader.parse( value, root );
199 throw InvalidJSON(
"JSON could not be parsed (or is invalid)",
"");
209 throw InvalidJSON(
"JSON is invalid (missing keys or invalid data types)",
"");
220 if (!root[
"path"].isNull())
221 path = root[
"path"].asString();
int max_height
The maximium image height needed by this clip (used for optimizations)
Json::Value JsonValue()
Generate Json::JsonValue for this object.
int num
Numerator for the fraction.
CriticalSection getFrameCriticalSection
Section lock for multiple threads.
void Open()
Open File - which is called by the constructor automatically.
QtImageReader(string path)
int width
The width of the video (in pixesl)
This class represents a single frame of video (i.e. image & audio data)
float duration
Length of time (in seconds)
void SetJsonValue(Json::Value root)
Load Json::JsonValue into this object.
string acodec
The name of the audio codec used to encode / decode the video stream.
void SetJson(string value)
Load JSON string into this object.
Exception when a reader is closed, and a frame is requested.
bool has_video
Determines if this file has a video stream.
Fraction display_ratio
The ratio of width to height of the video stream (i.e. 640x480 has a ratio of 4/3) ...
int64_t file_size
Size of file (in bytes)
bool has_audio
Determines if this file has an audio stream.
int64_t video_length
The number of frames in the video stream.
int height
The height of the video (in pixels)
Exception for files that can not be found or opened.
This class represents a fraction.
string Json()
Get and Set JSON methods.
bool has_single_image
Determines if this file only contains a single image.
void SetMaxSize(int width, int height)
Set Max Image Size (used for performance optimization)
virtual Json::Value JsonValue()=0
Generate Json::JsonValue for this object.
virtual void SetJsonValue(Json::Value root)=0
Load Json::JsonValue into this object.
ReaderInfo info
Information about the current media file.
Fraction fps
Frames per second, as a fraction (i.e. 24/1 = 24 fps)
Fraction video_timebase
The video timebase determines how long each frame stays on the screen.
Fraction pixel_ratio
The pixel ratio of the video stream as a fraction (i.e. some pixels are not square) ...
This namespace is the default namespace for all code in the openshot library.
Exception for invalid JSON.
std::shared_ptr< Frame > GetFrame(int64_t requested_frame)
string vcodec
The name of the video codec used to encode / decode the video stream.
int den
Denominator for the fraction.
int channels
The number of audio channels used in the audio stream.
int max_width
The maximum image width needed by this clip (used for optimizations)
int GetSamplesPerFrame(Fraction fps, int sample_rate, int channels)
Calculate the # of samples per video frame (for the current frame number)
double ToDouble()
Return this fraction as a double (i.e. 1/2 = 0.5)
int sample_rate
The number of audio samples per second (44100 is a common sample rate)