Casparcg Flash Templates Download
Flash Templates Download
TRANSCRIPT
From CasparCG Wiki
1 Video1.1 Video Codecs1.2 Sample Videos
2 Flash Templates2.1 Requirements for Creating Flash Templates2.2 Typical Workflow2.3 Special Properties of Flash Templates2.4 Interlacing via the Flash Producer2.5 Best Practices for Flash Templates2.6 Improving Performance of Flash Templates2.7 Generate FT File2.8 3D in Flash2.9 FLV
2.9.1 FLV Pixel Aspect Ratio2.9.2 Recommended FLV Render Settings2.9.3 FLV Limitations
2.10 TemplateGenerator2.10.1 What the TemplateGenerator Does2.10.2 TemplateGenerator Installation2.10.3 TemplateGenerator Installation on Mixed-language Systems
2.10.3.1 The Process2.10.3.1.1 The Panel
2.10.3.1.1.1 Generate FT File2.10.3.1.1.2 Author2.10.3.1.1.3 Template info2.10.3.1.1.4 =Optimization=2.10.3.1.1.5 Text Anti-aliasing2.10.3.1.1.6 Limitations2.10.3.1.1.7 To do2.10.3.1.1.8 Notes
2.11 SWF2.12 Tutorial: Loading Dynamic Images in a Flash Template2.13 Creating Advanced Flash Templates
2.13.1 The Document Class2.13.2 Public Methods2.13.3 CasparTemplate()=
2.13.3.1 Play():void2.13.3.2 Stop():void2.13.3.3 Next():void2.13.3.4 SetData(xmlData:XML):void2.13.3.5 GotoLabel(label:String):void2.13.3.6 ExecuteMethod(methodName:String):void2.13.3.7 GetDescription():String
2.13.3.8 initialize(context:ITemplateContext):void2.13.3.9 postInitialize():void2.13.3.10 registerComponent(instance:ICasparComponent):void2.13.3.11 dispose():void2.13.3.12 preDispose():void
2.13.4 public properties2.13.4.1 movieClip:MovieClip2.13.4.2 originalWidth:Number2.13.4.3 originalHeight:Number2.13.4.4 originalFrameRate:Number2.13.4.5 stopOnFirstFrame:Boolean2.13.4.6 communicationManager:ICommunicationManager2.13.4.7 description:XML2.13.4.8 version:String2.13.4.9 layer:int
2.13.5 Custom Parameters2.13.6 Creating A Custom Caspar Component2.13.7 Communication Manager2.13.8 Best Practices2.13.9 Generate FT File
2.14 Creating Templates without using Flash Professional3 Images4 Audio
4.1 Sampling Rate4.2 Audio Producers4.3 Audio Consumers4.4 Audio Channels
4.4.1 Audio Channel Layouts4.4.2 Rearranging and up/down mixing4.4.3 Audio Mix Configs
4.5 Audio Output4.6 Audio Limitations
5 Frame Rate and Resolution5.1 Real-time Scaling via the Flash Producer5.2 Flash Content Output to SDI or HDMI
5.2.1 Flash Content Output to Screen5.2.2 Video Content Output to SDI, HDMI or Screen
6 Interlacing6.1 Interlaced Content6.2 De-interlacing
7 Interlacing7.1 Interlaced Content7.2 De-interlacing
8 Chroma Subsampling9 Pixel-aspect Ratio10 Bit Depth
10.1 Producer Bit Depths10.2 Consumer Bit Depths
11 Color Levels12 Color Space
12.1 Embedded Color Profiles13 Color Depth
13.1 Rendering Bit Depth Limitations
13.1.1 Producer Bit Depths14 File Names15 Channels
15.1 Fill Channels15.2 Key / Alpha Channel
Pre-rendered video and audio is normally played via the FFmpeg Producer directly from the file system.
An alternative is to embed audio and/or video in an FT file and play with the Flash Producer.
The FFmpeg Producer can play all the codecs that FFmpeg (http://ffmpeg.org/) supports.
The CasparCG Download page (http://casparcg.com/download/) has links to several packages with sample videofiles.
Dynamic media is played by the CasparCG Servers Flash Producer, so everything that the Adobe FlashPlayer(http://adobe.com/products/flashplayer/) can handle can be played. This includes Flash animations SWF and Flashvideo FLV as well as audio, all via the FT file (which is just a SWF that has gone through TemplateGenerator.)
Since you have full control over everything in Flash, you can dynamically change texts and control individualanimations, and all ActionScript execution works (unlike when you import SWF:s into other tools such as AdobeAfter Effects (http://adobe.com/products/aftereffects/) .)
Many existing SWF:s are built on the assumption that they will be stored on a web server and embedded in a webpage. If the SWF requires any sort of interaction such as mouse clicks, it wont be very suited for CasparCGplayback. However, all features of the Flash Player (such as ActionScripted downloading of RSS feeds, for example)is fully functional when played by CasparCG.
An FT file is just a Flash file that has gone through automated checks and been renamed.
To prepare a Flash SWF file for playback by the CasparCG Server, it normally goes through an automated process inthe TemplateGenerator extension inside Adobe's Flash Professional (http://adobe.com/products/flash/) authoringapplication.
To create a Flash template for CasparCG you will need the Flash Professional (http://adobe.com/products/flash)authoring environment (CS4 and above recommended) and the TemplateGenerator panel.
Create your design in Adobe Photoshop, Adobe After Effects or some similar software.Import the .psd into FlashSelect the text fields you wish to expose to CasparCG and give them instance names (make sure not to beginwith the letter 'x' since this will make CasparCG ignore this particular instance.)Create your animationsPress the generate button in the TemplateGenerator panel (make sure that you have entered your name in thepanel.)
If everything is correct, the .ft file will bee generated and you are ready to test it in CasparCG Server.
You can create labels in your main time line that can be accessed from CasparCG with the Invoke command. If youcreate a label named 'outro', CasparCG will automatically go to and play this label when a Stop command isreceived. This is used to create outro animations. The #TemplateGenerator will look for any stop() command placedafter the outro label. If found, the generator will inject a removeTemplate() call on the same keyframe which willremove the template from the TemplateHost. If there is no Stop() command after the outro label, theremoveTemplate() call will be injected in the last frame of the layer that contains the outro label. This is important toknow, so that you make sure that this layer has its last keyframe on the frame you want the template to be removed.
By changing the frame rate in the #Flash Document Properties inside Adobe's Flash Professional (http://adobe.com/products/flash/) to the rate, the Flash Producer and a consumer will output interlaced dynamic output.Please see the tables in the #Frame Rates section for examples and guidelines.
Try to avoid several instances with the same instance name since it can be hard to keep track of the project. Ifyou create a timeline animation for a text field; convert the instance to a movie clip before you create thekeyframes.If you need to use ActionScript in your template (other then basic stop() commands and alike), you shouldfollow the guide lines in #Creating Advanced Flash Templates.
Flash Player may be a CPU bottleneck when playing high resolution channels. You might notice a major drop inperformance between 720p5000 and 1080i5000 channels. One common solution is to let Flash Player run at a lowerresolution and then upscale the final render from Flash in Caspar GPU Mixer. To do this, just override theTemplateHost section of your config file. Here you can specify what TemplateHost to load for each resolution. Belowis an example of forcing 720p5000 Flash content to be rendered at any 1080i5000 channel. The GPU upscaling isautomatically maintained.
1080i5000 cg20.fth.720p5000 1280 720
You can actually override several template hosts this way within the same config. Below is a complete section foroverriding every 1080-format to corresponding 720-TemplateHost.
1080i5000 cg20.fth.720p5000 1280 720 1080i5994 cg20.fth.720p5994 1280 720 1080i6000 cg20.fth.720p6000 1280 720 1080p2398 cg20.fth.720p2398 1280 720 1080p2400 cg20.fth.720p2400 1280 720 1080p2500 cg20.fth.720p2500 1280 720 1080p2997 cg20.fth.720p2997 1280 720 1080p3000 cg20.fth.720p3000 1280 720 1080p5000 cg20.fth.720p5000 1280 720 1080p6000 cg20.fth.720p6000 1280 720 1080i6000 cg20.fth.720p6000 1280 720
To create the .ft file file, you use the #TemplateGenerator.
Using Adobe Flash Player 10 (http://adobe.com/products/flashplayer/) and later, you can use Flash's built-in camerasand 2.5D abilities in your Flash templates.
There are also 3rd party Flash 3D engines such as Papervision3D (http://papervision3d.org/) that can be used. Avery 15 tab dividers template definitions.
You can use FLV (http://www.adobe.com/devnet/flv/) videos in Flash Templates and by using the alpha channel inthe FLV you can have transparent pre-rendered video controlled by Flash.
FLV Pixel Aspect Ratio
Flash content played by CasparCG_Server#Flash Producer is scaled on-the-fly at render time (matched to theconsumer when the Flash Producer is instanced,) so an FT Flash template can have either a square pixel aspect ratioor a non-square pixel aspect ratio used in common broadcast resolutions for SD output.
If you are outputting to SDI via the Bluefish Consumer, you can choose to set up your FT's #Flash DocumentProperties to match:
the final output resolution (for SD normally a non-square pixel aspect ratio) the square pixel aspect ratio equivalent and have the Flash Producer scale it.
This choice of Flash's #Flash Document Properties resolution should be made before choosing how to render the FLVvideo clips that will be played in the FT. We recommend working with a square pixel aspect ratio size and (ifnecessary) have that be squished to SD broadcast resolution on playback to SDI.
If you experience performance issues with Flash content, note that the on-the-fly scaling comes at a performancepenalty. To avoid scaling at render time you can resize the Flash content (by scaling the document resolution and thenscaling and re-saving all imported bitmaps, FLVs, vector graphics and such in a program outside Flash, andreimporting it.
While it is convenient to work with content, there is currently a special case caused by a bugin [Flash Player (http://adobe.com/products/flashplayer/) ]. It has a rounding calculation error that causes on-the-flyscaled output that is animated horizontally to 'jump' at certain intervals, making movements such as ticker texts toappear less smooth.
Recommendation for PAR: Video non-square Flash square (with exception)
Recommended FLV Render Settings
To increase the performance you should use lower compression in the FLV since decompression is harder thanreading a larger file from disk.
FLV Limitations
Audio embedded in an FLV can currently only be encoded with 44.1 kHz sampling rate, meaning that it will notmatch the standard broadcast sampling rate of 48 kHz. For short sound effects, this shouldn't cause any real problems,but beware when using longer FLV videos with sound. An alternative solution would be the import the 48 kHz audiofile into , and sync it to the silent FLV video on the timeline.
What the TemplateGenerator Does
The TemplateGenerator executes a script brew1_8.jsf (http://github.com/CasparCG/Tools/blob/master/as3/TemplateGenerator/trunk/build/jsfl/brew2_0.jsfl) that injects code into the current Flash project to make itcompatible with CasparCG Server. The project is then compiled and the SWF is renamed to .ft which is aconfirmation that the file is prepared to be played by CasparCG Server.
It will scan the main timeline and the timeline of any MovieClip items in the library and insert the following code atthe end of each frame where it finds an element of type 'text' which is dynamic and has an instance name that doesn'tbegin with 'x'. The code will register the component as a CasparTextField which is a CasparComponent.
From line 735 of brew1_8.jsf (http://github.com/CasparCG/Tools/blob/master/as3/TemplateGenerator/trunk/build/jsfl/brew2_0.jsfl)
thisFrame.actionScript += 'n(root as CasparTemplate).registerComponent(new CasparTextField(' + allElements[elementNr
Note that he CasparTextField (http://sourceforge.net/p/casparcg/code/3801/tree/framework/as3/TemplateHost/trunk/src/se/svt/caspar/template/components/CasparTextField.as) class will clear any text that is already set in the textfieldwhen it is constructed. This means if you want to add an instance name to a text field so that you can manage it withActionScript but don't want to be able to update it from CasparCG Server with UPDATE, you should always add thex at the beginning of the instance name, so that this code is not injected.
TemplateGenerator Installation
The TemplateGenerator is distributed as an Adobe Flash extension (.mxp). You will need the Adobe ExtensionManager (http://www.adobe.com/exchange/em_download/) to be able to install the extension. To install theTemplateGenerator just double click on the TemplateGenerator.mxp file and it should open the Extension Managerautomatically. When you have installed the package it should show up as 'TemplateGenerator' in the ExtensionManager. You will need to restart flash (if it is open) before you can start to generate flash templates. TheTemplateGenerator panel can be found at Window -> Other Panels.
The extension will also automatically install the class library that is needed to generate flash templates. The first timea flash template is generated the TemplateGenerator will automatically add the class path to this class library. If youare creating advanced flash templates and uses an external code editor you might need to set this class path manually.The library is installed at . The $(LocalData) can be found at:
Windows:
Macintosh:
Finally, the extension will install some project templates with some of the common formats used in broadcast. Youcan use these when you create a template from scratch by choosing
TemplateGenerator Installation on Mixed-language Systems
If you installed either the OS or Flash Professional in a non-US language, the TemplateGenerator may install properlybut you won't be able to see it in Flash Professional. Please see this forum thread for a solution(http://www.casparcg.com/forum/viewtopic.php?f=5&t=297&p=813#p810) .
The Process
All modifications to the Flash project file is reverted when the generation is finished. This is what happens to a Flashproject during the process:
All dynamic text fields in the project (any timeline) are exposed (converted to CasparTextField) so that theycan be accessed from CasparCG. The font is automatically embedded. If there is a dynamic text field that hasno instance name the script will throw an error. If the instance name begins with the letter 'x' the field will notbe exposed to CasparCG and it will be treated as a normal text field.All CasparCG Flash components are exposed so that they can be accessed from CasparCG.The document class is set to se.svt.caspar.template.CasparTemplate unless you have entered your own.In that case; be sure to use the CasparTemplate as the super class. Have a look at #Creating Advanced FlashTemplates for more info.A description of the template will be generated from the content in the document and the info in the panel.Depending on your choices in the panel, certain objects will be optimized for CasparCG. (read more about thisfurther down).
The Panel Garritan jazz and big band 3 download.
There are some settings in the panel you should know about:
Generate FT File
When you press this button the process will begin with the settings provided in the panel.
Author
Here you enter your name (required) and your e-mail (optional) for easy backtracking. This information will bestored in the template description.
Template info
Here you can enter information, e.g. a short description of the template, that will be stored in the template description.This is optional.
=Optimization=
These are automatic optimization of different objects that uses the best settings for rendering on CasparCG.
Optimize images If this option is checked (default) all images in the project will have their compression set to
'lossless' and the property 'allow smoothing' will be set to true.
Optimize text fields If this option is checked (default) all text fields will be rendered on even pixels.
Optimize embedded videos If this option is checked (default) all embedded videos will have the propertiessmoothing set to true and deblocking set to 4.
Text Anti-aliasing
The global thickness and sharpness for all the text fields in the document.
Limitations
If some unexpected error occurs when the script is executed there may be a possibility that the execution ishalted before the project is reverted (since there is no try catch in jsfl). If you have a project where thegeneration does not work, check in the timeline(s) for injected code that may interfere with the process.
Avoid working with scenes in flash since this is untested.
To do
Create a cache file for the template info.
Notes
This extension used to be called the Brewer, CasparTools and FT Generator in previous versions.
The CasparCG Server's Flash Producer supports and plays all types of SWF files, since it uses Adobe's FlashPlayer(http://adobe.com/products/flashplayer/) for rendering. That includes all types of ActionScript methods andcommands.
Many existing SWF's are built on the assumption that they will be stored on a web server and embedded in a webpage. If the SWF requires any sort of interaction such as mouse clicks, it wont be very suited for CasparCGplayback. However, all features of the Flash Player (such as #ActionScripted downloading of RSS feeds, forexample) is fully functional when played by CasparCG.
To prepare a SWF file for playback by the CasparCG Server, it normally goes through an automated process in theTemplateGenerator extension inside Adobe's Flash Professional (http://adobe.com/products/flash/) authoringapplication, generating an FT file (which is just an file that has gone through TemplateGenerator and beenrenamed.)
Getting a Flash template to load and dynamically display bitmaps from disk is very useful for lots of applications.Here's a quick explanation on how to display different flags in a volleyball scoreboard.
Download the source files used for this tutorial (http://casparcg.com/wp-content/uploads/tutorials
/Tutorial_Loading_Dynamic_Images_in_Flash_Templates.zip) .
Open the file in Flash Professional, and you can see that the dynamic text fields are just normaldynamic text with an instance name. The flags are UILoader components:
Open the (Ctrl+F7) and create two UILoaders and place and size them correctly. Remember togive them individual and unique instance names. In the example project they are called Image1 and Image2,respectively.
Then create a new ActionScript file and let it extend and let the animation point to the class like this:
Please refer to Creating Advanced Flash Templates for further details about extending .
In the ActionScript file (place it in the folder as the .fla file) you have to have at least the followingcode (the text is available in the source files (http://casparcg.com/wp-content/uploads/tutorials/Tutorial_Loading_Dynamic_Images_in_Flash_Templates.zip) .)
Important in the above code is line 20 and 24 respectively, where the green texts are the variable names of theimages. Use these variable names to send the image filenames to the template. In line 22 and 26 respectively, theUILoader components get their source property set to the name of the file. All the other dynamic text fields get theirdata to the call on line 29.
Finally, you have to send the template variables formatted as a correct URL. The file path
D:Beach_VolleyWorld_Flags_2013World_Flags_BIG_40pxSwitzerland.png
..should be entered as:
file:///D:/Beach_Volley/World_Flags_2013/World_Flags_BIG_40px/Switzerland.png
To create an advanced Flash template for CasparCG you will need the Flash Professional (http://www.adobe.com
/products/flash/) authoring environment (CS4 and above recommended) and the TemplateGenerator panel.
For more information on how Flash templates are hosted inside CasparCG Server, please see the TemplateHostsection.
The Document Class
The document class must extend the se.svt.caspar.template.CasparTemplate class (or another class that extendsit). The CasparTemplate class contains methods and properties used by CasparCG and you can override some of thedefault implementation.
Public Methods
CasparTemplate()=
Creates a new CasparCG template.
Play():void
This method will be called from the TemplateHost when a PLAY command is sent from CasparCG. By default it willtry to play the main time line in the Flash file (if there is no stop() on the first frame). The template will not bevisible until the Play command is sent from CasparCG. To override this method do the following:
override public function Play():void{ //Your code here}
Stop():void
This method will be called from the TemplateHost when a Stop command is sent from CasparCG. By default it willlook in the main time line if there is a label named 'outro'. If not it will call the removeTemplate method that marksthe template for removal. If it finds an outro label it will goto and play that label and when the outro is ready theremoveTemplate will be called. When you override this method it is very important that you either callsuper.Stop() or removeTemplate() when you are finished.
To override this method do the following:
override public function Stop():void { //Your code here //THEN super.Stop(); //OR removeTemplate();}
override public function Stop():void { myOutroFunction(); }
private function myOutroFunction():void
{ try { //Do some codebased animation myAnimationEngine.doMyOutroAnimation(); myAnimationEngine.onComplete(myCompleteFunction); } catch(e:Error) { myCompleteFunction(); }}
private function myCompleteFunction():void{ super.Stop(); //OR removeTemplate();}
Next():void
This method will be called from the TemplateHost when a Next command is sent from CasparCG. It is used to stepforward in the template. By default this method will make the template continue from the current frame. Thecommand will be ignored if the current frame label is 'outro', then Stop() must be called. To override this methoddo the following:
override public function Next():void { //Your code here}
SetData(xmlData:XML):void
This method will be called from the TemplateHost when a SetData command is sent from CasparCG. SetData isused to set data to the components or parameters that are exposed in the FT file. The data is buffered by theComponentDataBuffer which makes it possible to set data to a component that is not yet instantiated. When thecomponent later is instantiated it calls registerComponent (this is automatically done for all CasparCG componentson the stage) which then checks if there are any buffered data for the component and it that case it sends the data to it.
The XML format that is sent from CasparCG looks like this:
'instance 1' is a regular CasparTextField and it takes one parameter called 'text' and sets the value in the attribute'value' to the text parameter in the CasparTextField. 'instance2' demonstrates a possible CasparCG component thattakes an image path and and an alpha value. 'customParameter1' is a custom parameter defined in the document classand it will receive the value 'true'.
Some of the reasons to override SetData:
You want to do stuff before data is set to the componentsYou want to know when a specific component is populated with dataYou have code based custom parameters (read more about this in 'Custom paramers')
Here are some examples of overriding SetData:
//This override checks if instance1 is getting datapublic override function SetData(xmlData:XML):void { //loop trough the xml for each (var element:XML in xmlData.children()) { //check if the componentData atrribute 'id' is 'instance1' if (element.@id 'instance1') { //if found and not a empty string if (element.data.@value != ') { //..call a function 'setCurrentState' that accepts two parameters: the current state and the text receive setCurrentState('Text received', element.data.@value); break; } } } //pass on the xmlData to the default implementation which will send it to the ComponentDataBuffer. super.SetData(xmlData);}
//This override check for data to the custom parameter 'customParameter1'public override function SetData(xmlData:XML):void { //loop trough the xml for each (var element:XML in xmlData.children()) { //check if the componentData atrribute 'id' is 'customParameter1' if (element.@id 'customParameter1') { //if found, check if true or false if (element.data.@value 'true') { //call a function 'myFunction' and pass 'true'. myFunction(true); } else if(element.data.@value 'false') { //call a function 'myFunction' and pass 'false'. myFunction(false); } break; } } //pass on the xmlData to the default implementation which will send it to the ComponentDataBuffer. super.SetData(xmlData);}
GotoLabel(label:String):void
[final] This method will be called from the TemplateHost when a Invoke command is sent from CasparCG. It willfirst try this method, if it generates an error the TemplateHost will try ExecuteMethod instead. GotoLabel takes oneparameter, a label, and it will try to go to and play that label on the main timeline. If there is no label with that name itwill throw an error.
ExecuteMethod(methodName:String):void
[final] This method will be called from the TemplateHost when a Invoke command is sent from CasparCG and theGotoLabel command generated an error. It will try to execute a method on the template with the name specified in'methodName'. If there is no method with that name it will throw an error. To expose a method that can be executedvia Invoke/ExecuteMethod you simply create a public function in the document class. The method does not take any
parameters. If you need to receive specific parameters you should use 'Custom Parameters' that is described furtherdown.
GetDescription():String
[final] This method can be called by CasparCG and returns an XML description of the template. The description isautomatically generated by the TemplateGenerator.
initialize(context:ITemplateContext):void
[final] This method is called when a template is instantiated and provides the template with an instance of theCommunicationManager and what layer the template is loaded on to.
postInitialize():void
This method is called by initialize right after initialization is complete. Override this method to be able to access theCommunicationManager and/or the layer.
override public function postInitialize():void {{ communicationManager.sharedData.addSubscriber(this, 'testData'));}
registerComponent(instance:ICasparComponent):void
[final] This method is called by a component when initialized. It will tell the ComponentDataBuffer that the instanceis ready to receive data.
dispose():void
[final] This method is called by the TemplateHost before the template is removed. It will dispose all the loadedcomponents.
preDispose():void
This method is called by dispose just before the components are disposed. Override this method to be able to clean upeverything you need before the template is removed.
override public function preDispose():void { removeAllMyListeners(); stopAllTimers(); disposeAllMyObjects(); makeFinalNotifications();}
public properties
movieClip:MovieClip
[final][read-only] A reference to the template as a MovieClip. Used by the TemplateHost.
originalWidth:Number
[final] The original width of the template. This is set by TemplateGenerator and should normally be set manually.This property is used by the TemplateHost.
originalHeight:Number
[final] The original height of the template. This is set by TemplateGenerator and should normally be set manually.This property is used by the TemplateHost.
originalFrameRate:Number
[final] The original frame rate of the template. This is set by TemplateGenerator and should normally be setmanually. This property is used by the TemplateHost.
stopOnFirstFrame:Boolean
[final] A property that is true if there is a stop() on the first frame on the main timeline. This is set byTemplateGenerator and should normally be set manually. This property is used by the TemplateHost.
communicationManager:ICommunicationManager
[final][read-only] This is a reference to the communication manager and it is accessible in the postInitializemethod.
description:XML
[final] This is a reference to the description XML that describes the template. This is set by TemplateGenerator andshould normally be set manually. This property is used by the TemplateHost.
version:String
[final][read-only] The version of the template. This is set by TemplateGenerator and should normally be setmanually. This property is used by the TemplateHost.
layer:int
[final][read-only] The layer that the template is playing on. This is set by the TemplateHost and it is accessible in thepostInitialize method.
Custom Parameters
If you need to use custom parameters you can expose them by adding the following constant in your document class:
private const customParameterDescription:XML =
;
You will have to use the exact syntax described above for the TemplateGenerator to recognize it. The parameters willbe included in the template description and can then be externally accessed. The parameter types should be set toeither boolean, number, string or xml.
private const customParameterDescription:XML =
;..override public function SetData(xmlData:XML):void { for each (var element:XML in xmlData.children()) { if (element.@id 'resultData') { populateResultTable(element.data); } } super.SetData(xmlData);}
Creating A Custom Caspar Component
You can pass custom XML to your template. But it's suggested sticking to the form of componentData and thenputting your custom xml inside the tags because then in the flash template you can still use thedefault setData implementation and still have the option to make custom caspar component's, which would thenreceive your custom xml. Instead of putting everything on the stage put it in a movieclip instead which would thenimplement ICasparComponent (or you could do everything from actionscript).
Here is the interface you need to implement: [1] (http://sourceforge.net/p/casparcg/code/3801/tree/framework/as3/TemplateHost/trunk/src/se/svt/caspar/template/components/ICasparComponent.as)
Simply put the content inside a class which extends Sprite or MovieClip and implements ICasparComponent. Then itneeds to implement a SetData function which will receive the custom xml inside the componentData tag which has anid matching the component id, a destroy function which cancels any timers etc so that everything can be garbagecollected, and a 'get name()' function which should return the string which should be the id that you use to send datato it in the tag.
Then in the document class you just need to do something like:
var component:ICasparComponent = new ComponentClassName();addChild(component);registerComponent(component);
The registerComponent function is part of the CasparTemplate class and is what enables the relevant template data tobe sent to the relevant caspar component.
The advantages of doing it this way are that the ComponentDataBuffer will still be used, and that it is easier to addmore components to the same template later on if you wanted, or transfer components between different projects.
The component data buffer holds back any xml that it has received with an id that hasn't been registered withregisterComponent() and then sends it after registerComponent() has been called. So it means if a component isn'tloaded until after a few frames and data has already been sent to it, its SetData function will receive it immediatelyafter registerComponent() has been called and it won't get lost.
Communication Manager
More information soon..
Best Practices
Before you deliver a .ft file you should omit all you traces.
If you have custom parameters you should define them as described above.Remove any instances that are not used.
Generate FT File
To create the .ft file you use the TemplateGenerator.
One of the great things with CasparCG is that it is free, with the exception that you are forced to use Adobe FlashProfessional to create your templates, until now! Well, actually, this have always been possible to do but has not beenvery clear.
WHAT YOU'LL NEED
1. You will need Flash Develop (http://www.flashdevelop.org/) since this example is created in this wonderful freeeditor. The project is compiled with the Flex compiler which is installed together with the program. Just press Ctrl +Enter as usual.
2. Basic coding skills in AS3. The code is pretty well commented but you will need to know some of the basics.
WHAT YOU'LL GET
1. A pretty ugly template that you can play with.
2. Hopefully a better understanding of how to create templates without using the CasparCG TemplateGenerator.
3. An example on how to use the inbuilt component flow to create custom components so you don't need to overrideSetData and doing all the xml-parsing in the document class.
SOME NOTES As you might notice the output file is suffixed with .ft. This is not the act of magic as with theCasparCG TemplateGenerator, it is merely a setting in the properties for the project. I have just changed the 'SWF'to 'ft'.
I hope this will make CasparCG even more accessible than before! Of course you can use any editor/IDE with thismethod, it's just that I prefer Flash Develop.
Download example file for Flash Develop (http://sourceforge.net/projects/casparcg/files/Flash_Templates/TemplateWithoutFlashPro.zip/download)
CasparCG Server 2.0 can play out all the RGB and RGBA image formats that the FreeImage(http://freeimage.sourceforge.net/features.html) component can play.
Make sure that you convert CMYK images to RGB before trying to play them with CasparCG Server.
With CasparCG Server's Image Scroll you can automatically animate bitmaps with horizontal or vertical scrolling.
CasparCG Server 2.0.3 and earlier works with 32-bit, 2-channel stereo sound.Embedded SDI audio via BlackMagic Design's cards is 32-bit, 2-channel stereo sound.Embedded SDI audio via Bluefish cards is 16-bit, 2-channel stereo sound.System audio (via the computer's sound card) is 16-bit, 2-channel stereo sound.
The preferred sampling rate of audio is 48 kHz which conforms with broadcast standards, however other samplingrates, such as 44.1 kHz (CD Audio) also work.
Audio inputs that are not 48 kHz, 32-bit stereo are automatically transcoded in real-time.
The FFmpeg producer and the DeckLink producer can both handle audio.
The FFmpeg producer tries to determine the channel layout of the source file, but sometimes cannot do so correctly.Therefore the possibility to specify the channel layout of a file exists. It can be done like this:
PLAY 1-0 surround_file CHANNEL_LAYOUT SMPTE
..or by using a custom on-the-fly generated channel layout:
PLAY 1-0 surround_file CHANNEL_LAYOUT '5.1:Ls Rs L R C LFE'
The DeckLink producer by default assumes 'stereo' as the channel layout, but can be told to use another layout:
PLAY 1-0 DECKLINK DEVICE 2 FORMAT 720p5000 CHANNEL_LAYOUT SMPTE
..or a custom layout with the same syntax as expected by the FFmpeg producer:
PLAY 1-0 DECKLINK DEVICE 2 FORMAT 720p5000 CHANNEL_LAYOUT '5.1:Ls Rs L R C LFE'
All consumers receive audio data in the channel layout used by the audio mixer, but can convert it to another layout.Here is how the relevant (those consuming audio in any way) consumers handles incoming audio:
system-audio Always converts to stereodecklink Defaults to stereo but can be told to use another via the element in or the CHANNEL_LAYOUT parameter. Note that the actual output on the SDI cable will always be 2channels, 8 channels or 16 channels. So for example a 5.1 channel layout will cause 8 channels to be sent butwith the two last channels silent. In the case of mono, channel 1 will be duplicated to channel 2.bluefish Defaults to stereo but can be told to use another via the element in casparcg.configor the CHANNEL_LAYOUT parameter.ffmpeg Always uses the same audio layout as the audio mixer. Note that the default audio codec for a givencontainer type might not support the encoding of more than 2 channels, in which case the FFmpeg consumerwill fail to initialize. A custom -acodec must be given in those cases which supports the number of channelsused by the video channel.
2-channel stereo is supported in CasparCG Server 2.0.3 and earlier.
Mono and up to 16 channel audio input and output is supported from CasparCG Server version 2.0.4.
Audio Channel Layouts
The audio pipeline works with a concept called channel layouts. It is a mapping between a numbered audio channeland the corresponding speaker it is supposed to be directed to. The following are the predefined layouts in CasparCGServer 2.0.4 and later:
Name Type Layout------------ ------------- ---------------------------------mono 1.0 Cstereo 2.0 L Rdts 5.1 C L R Ls Rs LFEdolbye 5.1+stereomix L R C LFE Ls Rs Lmix Rmixdolbydigital 5.1 L C R Ls Rs LFEsmpte 5.1 L R C LFE Ls Rspassthru 16ch (will just pass everything as is)
The channel layout type like for example '5.1' is a string selected by convention to describe what set of channels toexpect in the layout. This means that for example dts and smpte are directly translatable, just by rearranging the orderof the channels.
The channel layout concept is used in the following areas:
The frames produced by a producer has a channel layout.The audio mixer mixes in a specific channel layout. The mixer automatically converts incoming audio to thecorrect channel layout if necessary before mixing.A consumer might convert the frames delivered from the audio mixer to any other channel layout beforeoutputting the audio.
A channel layout can be redefined or added by adding an element in casparcg.config in the configuration/audio/channel-layouts element. The element name is used as the layout name:
4.0 4 L R Ls Rs
Rearranging and up/down mixing
If a file played by the FFmpeg producer has the channel layout 'dolbydigital' and the audio_mixer channel layout is'smpte', the audio mixer will recognise that no upmixing or downmixing is required to adapt the incoming data onthe FFmpeg layer (both 'dolbydigital' and 'smpte' share the same layout type '5.1'), so it just rearranges the channelorder:
0 => 0 (L) 1 => 2 (C) 2 => 1 (R) 3 => 4 (Ls) 4 => 5 (Rs) 5 => 3 (LFE)
If on the other hand the layouts are of different types, a so called mix config will be used in order to determine how toconvert the audio channels.
Audio Mix Configs
A mix config specifies how to convert audio of a channel layout type (for example '5.1') to another layout type (forexample '2.0'). The default mix config for '5.1 => 2.0' looks like this (configurable in casparcg.config):
5.1 2.0 average L L 1.0 R R 1.0 C L 0.707 C R 0.707 Ls L 0.707 Rs R 0.707
The mix-element determines what strategy should be used when multiple source channels are mixed into a singledestination channel. Two strategies are available:
add -- Adds the samples together (can cause clipping).average -- Uses the average of all source samples (can cause too low volume).[/list]
Each mapping defines the source channel and the destination channel as well as the 'influence' the source channelshould have on the destination channel. Lowering the 'influence' can be useful to help avoiding clipping when the'add' strategy is used.
With the DeckLink Consumer you can decide if you want audio output via HDMI, SDI or the audio jacks of thecard(s).
With the Screen Consumer, audio is played via the regular audio output of the machine.
With the Bluefish Consumer, audio is either played via the regular audio output of the machine, or embedded in theSDI stream.
Audio embedded in an FLV can currently only be encoded with 44.1 kHz sampling rate, meaning that it will notmatch the standard broadcast sampling rate of 48 kHz. For short sound effects, this shouldn't cause any real problems,but beware when using longer FLV videos with sound. An alternative solution would be the import the 48 kHz audiofile into as a separate audio file, and sync it to the silent video on the same timeline.
The biggest drawback of using audio inside a Flash template is that it can only be played through the system audiooutput, which means it will not be embedded in SDI/HDMI output, and it will not be in perfect sync. If you need aFlash template to play audio and/or video, we recommend you use the CasparCG AS3 Server Connection library
(available from the Download page) to have the Flash template send the appropriate AMCP commands to load andplay audio (and/or video) through the FFmpeg producer.
The frame rate and resolution used for a channel is primarily set in the CasparCG Server configuration, but it mustalso match the content your are playing. The frame rate and resolution of content is changed:
In the Bluefish Feature App if you are using the Bluefish Consumer for SDI output.In the DeckLink control panel if you are using the DeckLink Consumer for SDI output.In the pre-rendered video file if played by the FFmpeg Producer.In the Flash Professional's Document Properties if you are making an FT for playback via the Flash Producer.
The maximum frame rate that a CasparCG system is capable of depends on many factors such as resolution, framerate, bit rate, codec and which producers and consumers you use, plus the performance of your hardware.
Flash templates are automatically scaled to the resolution determined by the consumer used. That means you canwork in square-pixel documents in Flash and they are scaled properly to fit the consumer. This also means that aslong as you are only using vector graphics and text, you can reuse SD templates in HD outputs.
If you don't have 1 to 1 ratio between your video resolution and the template resolution, Flash will scale it, whichcosts a lot of performance. Instead you can use the Mixer Module to scale it for you on the GPU. Add the followinglines to your config. Don't forget to replace FORMAT and RESOLUTION:
1080i5000 cg20.fth.FORMAT RESOLUTION RESOLUTION
FORMAT = One of the CasparCG Server's supported resolution and frame rates.
RESOLUTION = Your template's resolution.
For Flash content played by the Flash Producer and output to an SDI or HDMI consumer that is capable of interlacedoutput:
Expected Playback Frame Rate and Mode: Set the Flash DocumentProperties Frame Rate:
Render FLVs as:
23.976p 23.976 fps 23.976progressive fps
24p (film / movie /cinema for progressive playback) 24 fps 24 progressive fps
25p (progressive PAL SD and HD ) 25 fps 25 progressive fps29.976p (progressive NTSC SD , HD
and HD )
(sometimes mistakenly called , and )
29.976 fps 29.976progressive fps
50p (progressive PAL SD , and ) 50 fps 50 progressive fps50i (interlaced PAL SD and ) 50 fps 50 progressive fps59.94p (progressive NTSC SD , HD and HD )
(sometimes mistakenly called , and )
59.94 fps 59.94 progressivefps
59.94i (interlaced NTSC SD , HD andHD )
(sometimes mistakenly called , and )
59.94 fps 59.94 progressivefps
Flash Content Output to Screen
For Flash content played by the Flash Producer and output to an non-interlaced consumer such as the ScreenConsumer:
Expected Playback Frame Rate and Mode: Set the Flash DocumentProperties Frame Rate:
Render FLVs as:
23.976p 23.976 fps 23.976progressive fps
24p (film / movie /cinema for progressive playback) 24 fps 24 progressive fps
25p (progressive PAL SD , HD and HD)
25 fps 25 progressive fps
29.976p (progressive NTSC SD , HD and HD )
(sometimes mistakenly called , and )
29.976 fps 29.976progressive fps
50p (progressive PAL SD , and ) 50 fps 50 progressive fps
59.94p (progressive NTSC SD , HD and HD )
(sometimes mistakenly called , and )
59.94 fps 59.94 progressivefps
Video Content Output to SDI, HDMI or Screen
For video content played by the FFmpeg Producer and output to an SDI or HDMI consumer that is capable ofinterlaced output:
Expected Playback Frame Rateand Mode:
RenderVideo as:
Render Video with Field Dominance:
23.976p 23.976 fps Progressive
24p (film / movie /cinema forprogressive playback)
24 fps Progressive
25p (progressive PAL SD andHD )
25 fps Progressive
29.976p (progressive NTSC SD, HD and HD)
(sometimes mistakenly called , and )
29.976 fps Progressive
50p (progressive PAL SD , and )
50 fps Progressive
50i (interlaced PAL SD and)
25 fps Interlaced upper/odd'
.')
59.94p (progressive NTSC SD, HD and HD)
(sometimes mistakenly called , and )
59.94 fps Progressive
59.94i (interlaced NTSC SD, HD and HD)
(sometimes mistakenly called , and )
29.976 fps Interlaced upper/odd (unless rendering to a DV(http://en.wikipedia.org/wiki/DV) codec, in which case youshould render lower/even.)
You can have interlaced output of both dynamic Flash content and pre-rendered videos and images to SDI, HD-SDIor HDMI via several available consumers.
CasparCG Server 2.0 supports yadif (http://avisynth.org.ru/yadif/yadif.html) de-interlacing for the FFmpeg producerand the DeckLink producer. Yadif de-interlacing
.De-interlacing is automatically enabled when playing clips with incompatible encoding, e.g. 1080i50 -> 1080p50,720p50 -> 1080i50.
It is possible to manually activate de-interlacing for clips by providing the extra arguments to the LOAD and PLAYcommands with a FILTER YADIF=1:-1 command, for example:
LOADBG 1-1 MYCLIP FILTER YADIF=1:-1
You can have interlaced output of both dynamic Flash content and pre-rendered videos and images to SDI, HD-SDIor HDMI via several available consumers.
CasparCG Server 2.0 supports yadif (http://avisynth.org.ru/yadif/yadif.html) de-interlacing for the FFmpeg producerand the DeckLink producer. Yadif de-interlacing
.
De-interlacing is automatically enabled when playing clips with incompatible encoding, e.g. 1080i50 -> 1080p50,720p50 -> 1080i50.
It is possible to manually activate de-interlacing for clips by providing the extra arguments to the LOAD and PLAYcommands with a FILTER YADIF=1:-1 command, for example:
LOADBG 1-1 MYCLIP FILTER YADIF=1:-1
All rendering in all producers is done at 8-bit color depth in RGB color levels and with 4:4:4 chroma sampling.Content with lower will of course be played 'as-is.'
Read more about Chroma Subsampling (http://en.wikipedia.org/wiki/Chroma_subsampling) at Wikipedia.
Read more about pixel aspect ratio at Wikipedia (http://en.wikipedia.org/wiki/Pixel_aspect_ratio) .
Each producer and consumer has its own bit depth limitation. If you try to play/render content with a higher bit depth(for example 10-bit DPX, 16-bit TIFF or 32-bit EXR) you will not get predictable or even working results.
Currently we recommend you use 8 bpc (24-bit plus optional 8-bit alpha channel) content for best performance andstable operation.
The Flash Producer is currently limited to 8 bits per RGB channel plus an 8 bit alpha/key, since this is alimitation in Adobes FlashPlayer.
The FFmpeg Producer is limited to 8 bits per RGB channel plus an 8 bit alpha/key, since this is a currentlimitation of the FFmpeg (http://FFmpeg.org/) library.
The Image Producer is limited to 8 bits per RGB channel plus an 8 bit alpha/key.
The Color Producer is limited to 8 bits per RGB channel.
The Bluefish Consumer currently supports 8 bits per channel rendering for RGB/fill, plus an 8 bitalpha/key, even though the Bluefish cards support 10 bit output.
The Screen Consumer currently supports 8 bits per channel rendering for RGB/fill and no key/alpha channel.
All rendering in all producers is done at 8-bit RGB levels, meaning is black and is white.
This makes it easier to work with and preview content on a computer monitor, and facilitates using the same contentfor both broadcast and web consumption.
To comply with broadcast standards such as CCIR 601 (http://en.wikipedia.org/wiki/CCIR_601) and Rec. 709(http://en.wikipedia.org/wiki/Rec._709) the 0-255 RGB levels rendered by the producers is automatically convertedto the correct broadcast format (for example a range of 16-235) by the consumer based on the setting in theCasparCG_Server#Card_Configuration.
All content must be in RGB color space. Content in CMYK color space is not supported in any current producers.
Conversion from the internal RGB colorspace to output color space is handled by each consumer. For broadcastcolorspace YCbCr, Rec 601, Rec 709 and other broadcast colorspaces is handled by the supported video output cards.
Currently, no producers read or use any embedded color space profiles.
Each producer and consumer has an individual bit depth limitation. If you try to play/render content with a higher bitdepth (for example 10-bit DPX, 16-bit TIFF or 32-bit EXR) you will not get predictable or even working results.
Producer Bit Depths
The Flash Producer is currently limited to 8 bits per RGB channel plus an 8 bit alpha/key, since this is alimitation in Adobes FlashPlayer.
The FFmpeg Producer is limited to 8 bits per RGB channel plus an 8 bit alpha/key, since this is a currentlimitation of the FFmpeg (http://FFmpeg.org/) library.
TheCasparCG_Server#Image_Producer is limited to 8 bits per RGB channel plus an 8 bit alpha/key.
The Color Producer is limited to 8 bits per RGB channel.
You are advised to keep file names used with all the producers short, using only standard Latin characters andnumerals. Even though most support Unicode characters, there are some limitations in the FFmpeg Producer thatcauses media not to be found if it contains less common characters and even spaces.
Recommended:
May cause problems:
The Fill channels is another name for the color channels that make up the image that you actually see when playing avideo or image. CasparCG Server outputs the standard three color channels Red, Green and Blue of content at 8 bitsper channel.
CasparCG Server 2.0 assumes that all content has pre-multiplied alpha. Version 2.0.4 added support for straight alphablending in the compositing stage.
CasparCG Server automatically generates a key signal on the the key output of your DeckLink or Bluefish card. Ifyour video files have an embedded alpha channel, that will be used. Everything that cover the stage background inyour Flash template graphics (even FLV video or PNG sequences) will become your key signal. When you play bothvideo (one layer) and several Flash layers at once, CasparCG Server handles the compositing and outputs thecombined fill and key signals separately.
Content played by the Flash Producer is always pre-multiplied against black (no matter what the color is set to.) When composited on top or between other content (either Flash content in FTs or pre-rendered videosplayed by the FFmpeg Producer, Flash's Stage will become transparent and reveal underlying layers. The alphachannel in videos played by the FFmpeg Producer should be premultiplied so you can play content from any otherproducer on top and have everything correctly composited.
The alpha channel in videos played by the FFmpeg Producer should be premultiplied so you can play content fromany other producer on top and have everything correctly composited.
Retrieved from 'http://casparcg.com/wiki/Content_/_Media'
This page was last modified on 7 January 2014, at 18:48.Content is available under GNU Free Documentation License 1.2.
Free Flash Templates Download
Apr 13, 2017 Download CasparCG: Pro Video & Graphics Play-Out for free. Pro Video & Graphics Play-Out SW, proven in 24/7 broadcasts since 2006. Playback and record video, graphics and audio to multiple screens via DVI/HDMI/SDI in SD, HD, 2K and 4K.