36 : device(device), is_open(false), g_videoModeIndex(video_mode), g_audioChannels(channels), g_audioSampleDepth(sample_depth)
40 selectedDisplayMode = bmdModeNTSC;
41 pixelFormat = bmdFormat8BitYUV;
44 foundDisplayMode =
false;
45 pthread_mutex_init(&sleepMutex, NULL);
46 pthread_cond_init(&sleepCond, NULL);
50 case 0: pixelFormat = bmdFormat8BitYUV;
break;
51 case 1: pixelFormat = bmdFormat10BitYUV;
break;
52 case 2: pixelFormat = bmdFormat10BitRGB;
break;
53 case 3: pixelFormat = bmdFormat8BitARGB;
break;
55 throw DecklinkError(
"Pixel format is not valid (must be 0,1,2,3).");
66 deckLinkIterator = CreateDeckLinkIteratorInstance();
68 if (!deckLinkIterator)
69 throw DecklinkError(
"This application requires the DeckLink drivers installed.");
72 for (
int device_count = 0; device_count <= device; device_count++)
75 result = deckLinkIterator->Next(&deckLink);
79 if (device_count == device)
83 if (deckLink->QueryInterface(IID_IDeckLinkOutput, (
void**)&deckLinkOutput) != S_OK)
87 result = deckLinkOutput->GetDisplayModeIterator(&displayModeIterator);
89 throw DecklinkError(
"Could not obtain the video output display mode iterator.");
91 if (g_videoModeIndex < 0)
95 const char *displayModeName;
96 BMDTimeValue frameRateDuration, frameRateScale;
98 while (displayModeIterator->Next(&displayMode) == S_OK)
100 if (g_videoModeIndex == displayModeCount)
102 BMDDisplayModeSupport result;
104 foundDisplayMode =
true;
105 displayMode->GetName(&displayModeName);
106 selectedDisplayMode = displayMode->GetDisplayMode();
110 displayMode->GetFrameRate(&frameRateDuration, &frameRateScale);
123 if (!foundDisplayMode)
124 throw DecklinkError(
"Invalid video mode. No matching ones found.");
127 unsigned long m_framesPerSecond = (
unsigned long)((frameRateScale + (frameRateDuration-1)) / frameRateDuration);
133 deckLinkOutput->SetScheduledFrameCompletionCallback(delegate);
137 if (deckLinkOutput->EnableVideoOutput(displayMode->GetDisplayMode(), bmdVideoOutputFlagDefault) != S_OK)
138 throw DecklinkError(
"Failed to enable video output. Is another application using the card?");
199 deckLinkOutput->StopScheduledPlayback(0, NULL, 0);
200 deckLinkOutput->DisableAudioOutput();
201 deckLinkOutput->DisableVideoOutput();
204 displayMode->Release();
206 if (displayModeIterator != NULL)
208 displayModeIterator->Release();
209 displayModeIterator = NULL;
212 if (deckLinkOutput != NULL)
214 deckLinkOutput->Release();
215 deckLinkOutput = NULL;
218 if (deckLink != NULL)
224 if (deckLinkIterator != NULL)
225 deckLinkIterator->Release();
237 throw WriterClosed(
"The DecklinkWriter is closed. Call Open() before calling this method.");
246 for (
int number = start; number <= length; number++)
249 std::shared_ptr<Frame> f = reader->
GetFrame(number);
Header file for DecklinkWriter class.
Implementation of the Blackmagic Decklink API (used by the DecklinkWriter)
void WriteFrame(std::shared_ptr< openshot::Frame > frame)
Custom method to write new frames.
Exception when accessing a blackmagic decklink card.
void Close()
Close the device and video stream.
void WriteFrame(std::shared_ptr< Frame > frame)
This method is required for all derived classes of WriterBase. Write a Frame to the video file.
void Open()
Open device and video stream - which is called by the constructor automatically.
DecklinkWriter(int device, int video_mode, int pixel_format, int channels, int sample_depth)
This class represents a fraction.
int num
Numerator for the fraction.
double ToDouble() const
Return this fraction as a double (i.e. 1/2 = 0.5)
void Reduce()
Reduce this fraction (i.e. 640/480 = 4/3)
int den
Denominator for the fraction.
This abstract class is the base class, used by all readers in libopenshot.
virtual std::shared_ptr< openshot::Frame > GetFrame(int64_t number)=0
WriterInfo info
Information about the current media file.
Exception when too many seek attempts happen.
This namespace is the default namespace for all code in the openshot library.
int height
The height of the video (in pixels)
bool has_audio
Determines if this file has an audio stream.
int64_t video_length
The number of frames in the video stream.
float duration
Length of time (in seconds)
std::string vcodec
The name of the video codec used to encode / decode the video stream.
bool has_video
Determines if this file has a video stream.
openshot::Fraction fps
Frames per second, as a fraction (i.e. 24/1 = 24 fps)
openshot::Fraction video_timebase
The video timebase determines how long each frame stays on the screen.
openshot::Fraction display_ratio
The ratio of width to height of the video stream (i.e. 640x480 has a ratio of 4/3)
int width
The width of the video (in pixels)
openshot::Fraction pixel_ratio
The pixel ratio of the video stream as a fraction (i.e. some pixels are not square)
int64_t file_size
Size of file (in bytes)