Overlaying compositions with nice video animation used to be a problem for our customers: none of our objects was able to deal with this task perfectly. We have solved this problem by adding a possibility to add video clips as overlay items to the CG.
Previously, our customers had 3 options if they wanted to add a video on top of their existing stream:
- Character Generator, which can overlay a sequence of pictures or Flash items, but both options are slow, and Flash needs to interface to an external ActiveX (which is not the best idea if you are building a 24/7 application).
- MMixer, which can overlay video clips, but does not have other CG stuff like compositions, tickers etc.
MComposer, which is capable of all that, but it's GPU-powered, so you can't have too much instances of it.
Using video items in the Character Generator is very similar to using image overlay items:
// Specify CG item id string graphicsItemId = "my-video-item"; // String that contains information about video file. // It can contain only a file path, or have a complex file properties information string pathToFile = @"<img path='D:\Medialooks\Sample Videos\kingkong_15.mp4' in='10.0' out='12.0' open_props='' border='15' color='white(255)'/>"; // Item position double relativeX = 0.05; double relativeY = 0.05; int isRelative = 1; // Display item flag int isShow = 1; // Add item m_objCharGen.AddNewItem(pathToFile, relativeX, relativeY, isRelative, isShow, ref graphicsItemId);
You can use an XML line with extended video playback options:
"in" and "out" - specifies input and output points in seconds. Please note that you can use double values to specify the points frame accurately. For example to set "in" to 5-th frame and "out" to 10-th frame for PAL you should use in = '0.200' out = "0.400";
"open_props" - specifies the file options, such as crop, video track selection, etc.;
"border" - specifies the border width;
"color" - specifies the border color.
You can operate video overlay items in just the same way as you would with any other CG item, such as define its size, position, etc.
The control of video items is pretty similar to the image sequences and Flas items control:
- [ https://www.medialooks.com/mplatform/docs/hel.../ SetPlayingFrame()]: specify the playing frame number starting form the iin point (set position). Use it to make seeking in existing CG video item.
https://www.medialooks.com/mplatform/docs/hel.../ GetPlayingFrame()]: get playing frame number (get position).
[ https://www.medialooks.com/mplatform/docs/hel.../ SetItemRate()]: unfortunately custom rate is not supported yet, but you can use the "_bOriginalRate" parameter to specify the item playback rate type. Use _bOriginalRate = 1 to play the video item with it's original rate and
_bOriginalRate = 0 to use the underlaying stream rate (one frame of video item will be mixed with one frame of underlaying video).
GetItemRate(): get item playback rate type.
With this update, our CG have also got some new registry settings starting with the "media." prefix. You will find them in the following registry section: [HKEY_CURRENT_USER\Software\MediaLooks\MLCharGen].
media.external_process - enabling this option will force CG to play files in a separate thread.
media.low_delay - enabling this option will force CG to overlay the video item with 0 delay. But we recommend to keep it disabled. When this option is disabled the video items will have 1 frame delay but the scaling performance will be better.
media.scaling_quality - scaling quality for the CG video item. The bigger this value is, the better scaling quality you'll get, but the more CPU power it will consume. The min value is 0, max value is 18. We recommend to keep the default "Auto" value.
media.use_for_images - use the video items playback functionality for images displaying. Gives a bit better performance then the old way. The recommended value is "true", but you can set it to "false" to compare with the old images overlay functionality.
- media.use_for_sequences - use the video items functionality for image sequences displaying. Gives a bit better performance then the old way. The recommended value is "true", but you can set it to "false" to compare with the old image sequences overlay functionality.
Here is the list of functionality that is currently missing for the video items, but can be added by request:
- Effects for items in compositions, for example fade, blur, etc.
- Custom playback rate. You can use only video item original rate or underlaying stream original rate.
- Audio from overlaid items. Current version supports video overlay only ignoring the audio stream.
- External MPlatform/MFormats objects support. Similar to mp:// sources usage.
We hope you'll enjoy using these new features!