18 : device(device), is_open(false), g_videoModeIndex(video_mode), g_audioChannels(channels), g_audioSampleDepth(sample_depth)
22 selectedDisplayMode = bmdModeNTSC;
23 pixelFormat = bmdFormat8BitYUV;
26 foundDisplayMode =
false;
27 pthread_mutex_init(&sleepMutex, NULL);
28 pthread_cond_init(&sleepCond, NULL);
32 case 0: pixelFormat = bmdFormat8BitYUV;
break;
33 case 1: pixelFormat = bmdFormat10BitYUV;
break;
34 case 2: pixelFormat = bmdFormat10BitRGB;
break;
35 case 3: pixelFormat = bmdFormat8BitARGB;
break;
37 throw DecklinkError(
"Pixel format is not valid (must be 0,1,2,3).");
48 deckLinkIterator = CreateDeckLinkIteratorInstance();
50 if (!deckLinkIterator)
51 throw DecklinkError(
"This application requires the DeckLink drivers installed.");
54 for (
int device_count = 0; device_count <= device; device_count++)
57 result = deckLinkIterator->Next(&deckLink);
61 if (device_count == device)
65 if (deckLink->QueryInterface(IID_IDeckLinkOutput, (
void**)&deckLinkOutput) != S_OK)
69 result = deckLinkOutput->GetDisplayModeIterator(&displayModeIterator);
71 throw DecklinkError(
"Could not obtain the video output display mode iterator.");
73 if (g_videoModeIndex < 0)
77 const char *displayModeName;
78 BMDTimeValue frameRateDuration, frameRateScale;
80 while (displayModeIterator->Next(&displayMode) == S_OK)
82 if (g_videoModeIndex == displayModeCount)
84 BMDDisplayModeSupport result;
86 foundDisplayMode =
true;
87 displayMode->GetName(&displayModeName);
88 selectedDisplayMode = displayMode->GetDisplayMode();
92 displayMode->GetFrameRate(&frameRateDuration, &frameRateScale);
105 if (!foundDisplayMode)
106 throw DecklinkError(
"Invalid video mode. No matching ones found.");
109 unsigned long m_framesPerSecond = (
unsigned long)((frameRateScale + (frameRateDuration-1)) / frameRateDuration);
115 deckLinkOutput->SetScheduledFrameCompletionCallback(delegate);
119 if (deckLinkOutput->EnableVideoOutput(displayMode->GetDisplayMode(), bmdVideoOutputFlagDefault) != S_OK)
120 throw DecklinkError(
"Failed to enable video output. Is another application using the card?");
181 deckLinkOutput->StopScheduledPlayback(0, NULL, 0);
182 deckLinkOutput->DisableAudioOutput();
183 deckLinkOutput->DisableVideoOutput();
186 displayMode->Release();
188 if (displayModeIterator != NULL)
190 displayModeIterator->Release();
191 displayModeIterator = NULL;
194 if (deckLinkOutput != NULL)
196 deckLinkOutput->Release();
197 deckLinkOutput = NULL;
200 if (deckLink != NULL)
206 if (deckLinkIterator != NULL)
207 deckLinkIterator->Release();
219 throw WriterClosed(
"The DecklinkWriter is closed. Call Open() before calling this method.");
228 for (
int number = start; number <= length; number++)
231 std::shared_ptr<Frame> f = reader->
GetFrame(number);
void WriteFrame(std::shared_ptr< Frame > frame)
This method is required for all derived classes of WriterBase. Write a Frame to the video file...
int num
Numerator for the fraction.
Header file for DecklinkWriter class.
WriterInfo info
Information about the current media file.
Implementation of the Blackmagic Decklink API (used by the DecklinkWriter)
int64_t video_length
The number of frames in the video stream.
openshot::Fraction display_ratio
The ratio of width to height of the video stream (i.e. 640x480 has a ratio of 4/3) ...
double ToDouble() const
Return this fraction as a double (i.e. 1/2 = 0.5)
This abstract class is the base class, used by all readers in libopenshot.
int width
The width of the video (in pixels)
openshot::Fraction video_timebase
The video timebase determines how long each frame stays on the screen.
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)
virtual std::shared_ptr< openshot::Frame > GetFrame(int64_t number)=0
float duration
Length of time (in seconds)
Exception when accessing a blackmagic decklink card.
This class represents a fraction.
DecklinkWriter(int device, int video_mode, int pixel_format, int channels, int sample_depth)
bool has_video
Determines if this file has a video stream.
void WriteFrame(std::shared_ptr< openshot::Frame > frame)
Custom method to write new frames.
void Open()
Open device and video stream - which is called by the constructor automatically.
This namespace is the default namespace for all code in the openshot library.
void Close()
Close the device and video stream.
bool has_audio
Determines if this file has an audio stream.
std::string vcodec
The name of the video codec used to encode / decode the video stream.
Exception when too many seek attempts happen.
int height
The height of the video (in pixels)
int den
Denominator for the fraction.
openshot::Fraction fps
Frames per second, as a fraction (i.e. 24/1 = 24 fps)