OpenShot Library | libopenshot
0.2.5
|
Go to the documentation of this file.
32 #ifdef USE_IMAGEMAGICK
34 #include "../include/ImageReader.h"
64 image = std::shared_ptr<Magick::Image>(
new Magick::Image(path));
67 image->backgroundColor(Magick::Color(
"none"));
70 catch (
const Magick::Exception& e) {
72 throw InvalidFile(
"File could not be opened.", path);
126 throw ReaderClosed(
"The FFmpegReader is closed. Call Open() before calling this method.", path);
129 std::shared_ptr<Frame> image_frame(
new Frame(requested_frame, image->size().width(), image->size().height(),
"#000000", 0, 2));
150 root[
"type"] =
"ImageReader";
167 catch (
const std::exception& e)
170 throw InvalidJSON(
"JSON is invalid (missing keys or invalid data types)");
181 if (!root[
"path"].isNull())
182 path = root[
"path"].asString();
192 #endif //USE_IMAGEMAGICK
const Json::Value stringToJson(const std::string value)
virtual Json::Value JsonValue() const =0
Generate Json::Value for this object.
void AddMagickImage(std::shared_ptr< Magick::Image > new_image)
Add (or replace) pixel data to the frame from an ImageMagick Image.
virtual void SetJsonValue(const Json::Value root)=0
Load Json::Value into this object.
This namespace is the default namespace for all code in the openshot library.
This class represents a fraction.
openshot::ReaderInfo info
Information about the current media file.
ImageReader(std::string path)
void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
float duration
Length of time (in seconds)
This class represents a single frame of video (i.e. image & audio data)
bool has_video
Determines if this file has a video stream.
int width
The width of the video (in pixesl)
std::string Json() const override
Get and Set JSON methods.
int64_t video_length
The number of frames in the video stream.
int height
The height of the video (in pixels)
int num
Numerator for the fraction.
int den
Denominator for the fraction.
void Reduce()
Reduce this fraction (i.e. 640/480 = 4/3)
bool has_audio
Determines if this file has an audio stream.
Exception for invalid JSON.
int64_t file_size
Size of file (in bytes)
void Open()
Open File - which is called by the constructor automatically.
void SetJson(const std::string value)
Load JSON string into this object.
std::shared_ptr< Frame > GetFrame(int64_t requested_frame)
bool has_single_image
Determines if this file only contains a single image.
openshot::Fraction video_timebase
The video timebase determines how long each frame stays on the screen.
Exception for files that can not be found or opened.
#define MAGICK_IMAGE_ALPHA(im, a)
std::string vcodec
The name of the video codec used to encode / decode the video stream.
Exception when a reader is closed, and a frame is requested.
openshot::Fraction fps
Frames per second, as a fraction (i.e. 24/1 = 24 fps)
Json::Value JsonValue() const
Generate Json::Value for this object.
double ToDouble()
Return this fraction as a double (i.e. 1/2 = 0.5)
openshot::Fraction pixel_ratio
The pixel ratio of the video stream as a fraction (i.e. some pixels are not square)
openshot::Fraction display_ratio
The ratio of width to height of the video stream (i.e. 640x480 has a ratio of 4/3)