|
OpenShot Library | libopenshot
0.6.0
|
Go to the documentation of this file.
13 #ifndef OPENSHOT_FRAME_H
14 #define OPENSHOT_FRAME_H
17 #define int64 opencv_broken_int
18 #define uint64 opencv_broken_uint
19 #include <opencv2/imgproc/imgproc.hpp>
42 class AudioBufferSource;
92 std::shared_ptr<QImage> image;
93 std::shared_ptr<QImage> wave_image;
95 std::shared_ptr<QApplication> previewApp;
96 std::recursive_mutex addingImageMutex;
97 std::recursive_mutex addingAudioMutex;
105 int64_t max_audio_sample;
106 bool audio_is_increasing;
113 int constrain(
int color_value);
116 std::shared_ptr<juce::AudioBuffer<float>>
audio;
126 Frame(int64_t
number,
int width,
int height, std::string color);
132 Frame(int64_t
number,
int width,
int height, std::string color,
int samples,
int channels);
144 void AddColor(
int new_width,
int new_height, std::string new_color);
147 void AddColor(
const QColor& new_color);
150 void AddImage(
int new_width,
int new_height,
int bytes_per_pixel, QImage::Format type,
const unsigned char *pixels_);
153 void AddImage(std::shared_ptr<QImage> new_image);
156 void AddImage(std::shared_ptr<QImage> new_image,
bool only_odd_lines);
159 void AddAudio(
bool replaceSamples,
int destChannel,
int destStartSample,
const float* source,
int numSamples,
float gainToApplyToSource);
165 void ApplyGainRamp(
int destChannel,
int destStartSample,
int numSamples,
float initial_gain,
float final_gain);
187 float GetAudioSample(
int channel,
int sample,
int magnitude_range);
219 bool CheckPixel(
int row,
int col,
int red,
int green,
int blue,
int alpha,
int threshold);
231 std::shared_ptr<QImage>
GetWaveform(
int width,
int height,
int Red,
int Green,
int Blue,
int Alpha);
234 const unsigned char*
GetWaveformPixels(
int width,
int height,
int Red,
int Green,
int Blue,
int Alpha);
246 void SampleRate(
int orig_sample_rate) { sample_rate = orig_sample_rate; };
252 void Save(std::string
path,
float scale, std::string format=
"PNG",
int quality=100);
264 void Thumbnail(std::string
path,
int new_width,
int new_height, std::string mask_path, std::string overlay_path,
265 std::string background_color,
bool ignore_aspect, std::string format=
"png",
int quality=100,
272 cv::Mat
Qimage2mat( std::shared_ptr<QImage>& qimage);
276 std::shared_ptr<QImage>
Mat2Qimage(cv::Mat img);
const unsigned char * GetWaveformPixels(int width, int height, int Red, int Green, int Blue, int Alpha)
Get an audio waveform image pixels.
int SampleRate()
Get the original sample rate of this frame's audio data.
Header file for ChannelLayout class.
Frame & operator=(const Frame &other)
Assignment operator.
Header file for Fraction class.
float * GetAudioSamples(int channel)
Get an array of sample data (and optional reverse the sample values)
void SetFrameNumber(int64_t number)
Set frame number.
bool has_audio_data
This frame has been loaded with audio data.
This namespace is the default namespace for all code in the openshot library.
This class represents a fraction.
openshot::Fraction GetPixelRatio()
Set Pixel Aspect Ratio.
This class represents a single frame of video (i.e. image & audio data)
void ChannelsLayout(openshot::ChannelLayout new_channel_layout)
bool has_image_data
This frame has been loaded with pixel data.
void AddAudioSilence(int numSamples)
Add audio silence.
int64_t GetBytes()
Get the size in bytes of this frame (rough estimate)
void ResizeAudio(int channels, int length, int sample_rate, openshot::ChannelLayout channel_layout)
Resize audio container to hold more (or less) samples and channels.
const unsigned char * GetPixels()
Get pixel data (as packets)
void AddImage(int new_width, int new_height, int bytes_per_pixel, QImage::Format type, const unsigned char *pixels_)
Add (or replace) pixel data to the frame.
void ApplyGainRamp(int destChannel, int destStartSample, int numSamples, float initial_gain, float final_gain)
Apply gain ramp (i.e. fading volume)
int GetAudioChannelsCount()
Get number of audio channels.
int GetHeight()
Get height of image.
int GetSamplesPerFrame(openshot::Fraction fps, int sample_rate, int channels)
Calculate the # of samples per video frame (for the current frame number)
float * GetInterleavedAudioSamples(int *sample_count)
Get an array of sample data (all channels interleaved together), using any sample rate.
@ SCALE_FIT
Scale the clip until either height or width fills the canvas (with no cropping)
bool CheckPixel(int row, int col, int red, int green, int blue, int alpha, int threshold)
Check a specific pixel color value (returns True/False)
std::shared_ptr< QImage > GetWaveform(int width, int height, int Red, int Green, int Blue, int Alpha)
Get an audio waveform image.
void AddAudio(bool replaceSamples, int destChannel, int destStartSample, const float *source, int numSamples, float gainToApplyToSource)
Add audio samples to a specific channel.
void SampleRate(int orig_sample_rate)
Set the original sample rate of this frame's audio data.
void Thumbnail(std::string path, int new_width, int new_height, std::string mask_path, std::string overlay_path, std::string background_color, bool ignore_aspect, std::string format="png", int quality=100, float rotate=0.0, ScaleType scale_mode=SCALE_FIT)
int GetWidth()
Get height of image.
std::shared_ptr< juce::AudioBuffer< float > > audio
Header file for TextReader class.
void ClearWaveform()
Clear the waveform image (and deallocate its memory)
void SetPixelRatio(int num, int den)
Set Pixel Aspect Ratio.
void Save(std::string path, float scale, std::string format="PNG", int quality=100)
Save the frame image to the specified path. The image format can be BMP, JPG, JPEG,...
std::shared_ptr< QImage > GetImage()
Get pointer to Qt QImage image object.
void SetAudioDirection(bool is_increasing)
Set the direction of the audio buffer of this frame.
cv::Mat GetImageCV()
Get pointer to OpenCV Mat image object.
openshot::ChannelLayout ChannelsLayout()
juce::AudioBuffer< float > * GetAudioSampleBuffer()
ScaleType
This enumeration determines how clips are scaled to fit their parent container.
ChannelLayout
This enumeration determines the audio channel layout (such as stereo, mono, 5 point surround,...
void Play()
Play audio samples for this frame.
void DeepCopy(const Frame &other)
Copy data and pointers from another Frame instance.
float GetAudioSample(int channel, int sample, int magnitude_range)
Get magnitude of range of samples (if channel is -1, return average of all channels for that sample)
int64_t number
This is the frame number (starting at 1)
std::shared_ptr< QImage > Mat2Qimage(cv::Mat img)
Convert OpenCV Mat to QImage.
void SetImageCV(cv::Mat _image)
Set pointer to OpenCV image object.
void Display()
Display the frame image to the screen (primarily used for debugging reasons)
virtual ~Frame()
Destructor.
cv::Mat Qimage2mat(std::shared_ptr< QImage > &qimage)
Convert Qimage to Mat.
Frame()
Constructor - blank frame.
int GetAudioSamplesCount()
Get number of audio samples.
void AddColor(int new_width, int new_height, std::string new_color)
Add (or replace) pixel data to the frame (based on a solid color)
void DisplayWaveform()
Display the wave form.