31 #ifndef OPENSHOT_FRAME_H 32 #define OPENSHOT_FRAME_H 37 #include <QtWidgets/QApplication> 38 #include <QtGui/QImage> 39 #include <QtGui/QColor> 40 #include <QtGui/QBitmap> 41 #include <QtCore/QString> 42 #include <QtCore/QVector> 43 #include <QtGui/QPainter> 44 #include <QtWidgets/QHBoxLayout> 45 #include <QtWidgets/QWidget> 46 #include <QtWidgets/QLabel> 54 #include "JuceHeader.h" 55 #ifdef USE_IMAGEMAGICK 109 std::shared_ptr<QImage> image;
110 std::shared_ptr<QImage> wave_image;
111 std::shared_ptr<juce::AudioSampleBuffer> audio;
112 std::shared_ptr<QApplication> previewApp;
113 juce::CriticalSection addingImageSection;
114 juce::CriticalSection addingAudioSection;
115 const unsigned char *qbuffer;
123 int64_t max_audio_sample;
126 int constrain(
int color_value);
138 Frame(int64_t number,
int width,
int height, std::string color);
141 Frame(int64_t number,
int samples,
int channels);
144 Frame(int64_t number,
int width,
int height, std::string color,
int samples,
int channels);
156 void AddColor(
int new_width,
int new_height, std::string new_color);
159 void AddImage(
int new_width,
int new_height,
int bytes_per_pixel, QImage::Format type,
const unsigned char *pixels_);
162 void AddImage(std::shared_ptr<QImage> new_image);
165 void AddImage(std::shared_ptr<QImage> new_image,
bool only_odd_lines);
167 #ifdef USE_IMAGEMAGICK 173 void AddAudio(
bool replaceSamples,
int destChannel,
int destStartSample,
const float* source,
int numSamples,
float gainToApplyToSource);
179 void ApplyGainRamp(
int destChannel,
int destStartSample,
int numSamples,
float initial_gain,
float final_gain);
204 float GetAudioSample(
int channel,
int sample,
int magnitude_range);
229 #ifdef USE_IMAGEMAGICK 244 bool CheckPixel(
int row,
int col,
int red,
int green,
int blue,
int alpha,
int threshold);
256 std::shared_ptr<QImage>
GetWaveform(
int width,
int height,
int Red,
int Green,
int Blue,
int Alpha);
259 const unsigned char*
GetWaveformPixels(
int width,
int height,
int Red,
int Green,
int Blue,
int Alpha);
271 void SampleRate(
int orig_sample_rate) { sample_rate = orig_sample_rate; };
274 void Save(std::string
path,
float scale, std::string format=
"PNG",
int quality=100);
284 void Thumbnail(std::string path,
int new_width,
int new_height, std::string mask_path, std::string overlay_path,
285 std::string background_color,
bool ignore_aspect, std::string format=
"png",
int quality=100,
float rotate=0.0);
openshot::Fraction GetPixelRatio()
Set Pixel Aspect Ratio.
void AddMagickImage(std::shared_ptr< Magick::Image > new_image)
Add (or replace) pixel data to the frame from an ImageMagick Image.
int GetWidth()
Get height of image.
Header file for Fraction class.
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 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)
void ResizeAudio(int channels, int length, int sample_rate, openshot::ChannelLayout channel_layout)
Resize audio container to hold more (or less) samples and channels.
This class represents a single frame of video (i.e. image & audio data)
std::shared_ptr< Magick::Image > GetMagickImage()
Get pointer to ImageMagick image object.
const unsigned char * GetWaveformPixels(int width, int height, int Red, int Green, int Blue, int Alpha)
Get an audio waveform image pixels.
Header file for MagickUtilities (IM6/IM7 compatibility overlay)
juce::AudioSampleBuffer * GetAudioSampleBuffer()
const unsigned char * GetPixels()
Get pixel data (as packets)
void Play()
Play audio samples for this frame.
Header file for AudioBufferSource class.
void DeepCopy(const Frame &other)
Copy data and pointers from another Frame instance.
void AddAudio(bool replaceSamples, int destChannel, int destStartSample, const float *source, int numSamples, float gainToApplyToSource)
Add audio samples to a specific channel.
void Display()
Display the frame image to the screen (primarily used for debugging reasons)
int64_t number
This is the frame number (starting at 1)
Frame & operator=(const Frame &other)
Assignment operator.
int GetSamplesPerFrame(openshot::Fraction fps, int sample_rate, int channels)
Calculate the # of samples per video frame (for the current frame number)
void ClearWaveform()
Clear the waveform image (and deallocate its memory)
float * GetPlanarAudioSamples(int new_sample_rate, openshot::AudioResampler *resampler, int *sample_count)
float * GetAudioSamples(int channel)
Get an array of sample data.
void SetFrameNumber(int64_t number)
Set frame number.
Header file for AudioResampler class.
void AddAudioSilence(int numSamples)
Add audio silence.
bool has_audio_data
This frame has been loaded with audio data.
float * GetInterleavedAudioSamples(int new_sample_rate, openshot::AudioResampler *resampler, int *sample_count)
Get an array of sample data (all channels interleaved together), using any sample rate...
This class represents a fraction.
Header file for ZeroMQ-based Logger class.
Header file for ChannelLayout class.
static void cleanUpBuffer(void *info)
Clean up buffer after QImage is deleted.
ChannelLayout
This enumeration determines the audio channel layout (such as stereo, mono, 5 point surround...
void ChannelsLayout(openshot::ChannelLayout new_channel_layout)
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.
Frame()
Constructor - blank frame (300x200 blank image, 48kHz audio silence)
void ApplyGainRamp(int destChannel, int destStartSample, int numSamples, float initial_gain, float final_gain)
Apply gain ramp (i.e. fading volume)
void DisplayWaveform()
Display the wave form.
void SetPixelRatio(int num, int den)
Set Pixel Aspect Ratio.
int GetAudioChannelsCount()
Get number of audio channels.
This namespace is the default namespace for all code in the openshot library.
openshot::ChannelLayout ChannelsLayout()
std::shared_ptr< QImage > GetImage()
Get pointer to Qt QImage image object.
std::shared_ptr< QImage > GetWaveform(int width, int height, int Red, int Green, int Blue, int Alpha)
Get an audio waveform image.
int64_t GetBytes()
Get the size in bytes of this frame (rough estimate)
virtual ~Frame()
Destructor.
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) ...
bool has_image_data
This frame has been loaded with pixel data.
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, PNG, PPM, XBM, XPM.
int GetHeight()
Get height of image.
void SampleRate(int orig_sample_rate)
Set the original sample rate of this frame's audio data.
int SampleRate()
Get the original sample rate of this frame's audio data.
This class is used to resample audio data for many sequential frames.
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)