About
The MAXON API handles media data using Media Sessions. Such a session is used to connect a media source with a media output. This way one can load and save image files and convert media data.
Media Converter
maxon::MediaConverterInterface is the base interface for both maxon::MediaInputInterface and maxon::MediaOutputInterface (see below). It itself is based on:
maxon::MediaConverterInterface itself gives access to data streams. Typically one does not use these functions directly but with a maxon::MediaSessionInterface.
Media Inputs
maxon::MediaInputInterface gives access to the data of a given media source. It is based on maxon::MediaConverterInterface.
Typically one creates a media input by loading a media file. maxon::FileFormatDetectionInterface can be used to get the type of such a media file. Then maxon::FileFormatHandlerInterface::CreateHandler() is used to create a handler to access that media file.
Media Outputs
maxon::MediaOutputInterface allows to write media data into a given destination. It is based on maxon::MediaConverterInterface.
The typical destination is a media file which is represented by the maxon::MediaOutputUrlInterface. An instance can be obtained from the maxon::ImageSaverClasses namespace.
The utility function maxon::MediaSessionImport() can be used to read a media file and to write the data into the given media output.
Also image data can be written into a maxon::ImageTextureInterface. Such a target image is represented as a maxon::MediaOutputTextureInterface:
MediaSessionInterface
The maxon::MediaSessionInterface is used to connect a media input and an output and to perform the desired conversion:
Technical Details
A MediaConverterRef connects media inputs and outputs. The inputs create media streams which can be subscribed by the output. This way the input must only provide the information that is actually needed by the connected output.
Within the converter the media data is handled like this:
Analzye Phase:
- The output's Analyze() function calls all inputs to invoke their Analyze() function (see below). After that it checks all streams provided by the inputs. It searches for a suitable stream or streams and subscribes to it.
- The input's Analyze() function checks the source (e.g. a file) and creates the available media streams (maxon::MediaStreamInterface).
Execution Phase:
- The output's PrepareExecute() function calls the PrepareExecute() function of all inputs.
- The input's PrepareExecute() function checks if any of the created streams are subscribed. If so, a progress job is added (maxon::MediaSessionProgressInterface).
- The output's Execute() function calls the Execute() function of all inputs. Then it reads the media data accessible in the subscribed streams.
- The inputs Execute() function writes all data in the subscribed streams (maxon::MediaStreamPropertiesInterface, maxon::SetPixelHandlerStruct). When done, the progress is updated.
Examples
{
if (url.IsEmpty())
const maxon::FileFormatHandler importFileFormat = maxon::FileFormatDetectionInterface::Detect<maxon::MediaInputRef>(url)
iferr_return;
const maxon::MediaInputRef
source = importFileFormat.CreateHandler<maxon::MediaInputRef>(url)
iferr_return;
const maxon::MediaOutputTextureRef destination = maxon::MediaOutputTextureClass().Create()
iferr_return;
destination.SetOutputTexture(targetTexture, maxon::ImagePixelStorageClasses::Normal())
iferr_return;
const maxon::MediaSessionRef session = maxon::MediaSessionObject().Create()
iferr_return;
}
The TimeValue class encapsulates a timer value.
Definition: timevalue.h:33
const Py_UNICODE * source
Definition: unicodeobject.h:54
return OK
Definition: apibase.h:2690
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
#define iferr_scope
Definition: resultbase.h:1384
#define iferr_return
Definition: resultbase.h:1519
{
if (url.IsEmpty() || image.IsEmpty())
const maxon::MediaOutputUrlRef destination = maxon::ImageSaverClasses::Png().Create()
iferr_return;
maxon::MediaSessionRef session = maxon::MediaSessionObject().Create()
iferr_return;
}
@ RUNONLYANALYZE
run only the analyze but not the execute pass.
{
if (url.IsEmpty() || images.
IsEmpty() || invalidFps)
maxon::DataDictionary exportSettings;
const maxon::ImageRef firstImage = images[0];
const maxon::ImageTextureRef
source = maxon::ImageTextureClasses::TEXTURE().Create()
iferr_return;
const maxon::ImageRef imageData = firstImage;
const maxon::Id MP4 = maxon::MEDIASESSION::MP4::EXPORT::GetId();
if (correctedSize != inputSize)
{
}
maxon::MediaSessionRef session = maxon::MediaSessionObject().Create()
iferr_return;
for (auto& image : images)
{
currentTime += frameDuration;
}
return session.Close();
}
Definition: basearray.h:412
MAXON_ATTRIBUTE_FORCE_INLINE Bool IsEmpty() const
Definition: collection.h:348
Definition: apibaseid.h:253
Byte value in megabytes.
Definition: bytesvalue.h:402
void SetSeconds(Float64 seconds)
Definition: timevalue.h:225
Float64 Float
Definition: apibase.h:197
bool Bool
boolean type, possible values are only false/true, 8 bit
Definition: apibase.h:181
int32_t Int32
32 bit signed integer datatype.
Definition: apibase.h:176
Result< void > CopyImageData(const ImageBaseRef &source, const ImageRef &dest, Bool allowDifferentSize)
@ IMAGE
Adds a subImage to a texture. Images are only allowed under Textures.
QUALITY
Various qualities.
Definition: macros.h:23
const Class< R > & Get(const Id &cls)
Definition: objectbase.h:2073
Size of a window/drawing operation.
Definition: gfx_basictypes.h:16
{
if (folder.IsEmpty() || images.
IsEmpty())
sequenceURL.
Set(maxon::URLFLAGS::IMAGESEQUENCE_FIRSTFRAME, firstFrame)
iferr_return;
sequenceURL.
Set(maxon::URLFLAGS::IMAGESEQUENCE_LASTFRAME, lastFrame)
iferr_return;
const maxon::FileFormatHandler imageSequence = maxon::FileFormatHandlers::MovieImageSequence();
const maxon::MediaInputRef
source = imageSequence.CreateHandler<maxon::MediaInputRef>(sequenceURL)
iferr_return;
const maxon::ImageTextureRef texture = maxon::ImageTextureClasses::TEXTURE().Create()
iferr_return;
const maxon::MediaOutputTextureRef destination = maxon::MediaOutputTextureClass().Create()
iferr_return;
destination.SetOutputTexture(texture, maxon::ImagePixelStorageClasses::Normal())
iferr_return;
const maxon::MediaSessionRef session = maxon::MediaSessionObject().Create()
iferr_return;
{
currentTime += frameDuration;
}
return session.Close();
}
const char const char * name
Definition: abstract.h:195
PyCompilerFlags const char * filename
Definition: ast.h:15
MAXON_ATTRIBUTE_FORCE_INLINE Int GetCount() const
Definition: basearray.h:573
Definition: string.h:1235
Result< void > Set(KEY &&key, T &&data, Bool persistent=true)
Definition: url.h:1051
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:188
ImageRef GetImageOf(const ImageBaseRef &bmp)
PyFrameObject * frame
Definition: pycore_traceback.h:92
Further Reading