Exploring In-Stream Video Creatives
New to v1.18 of the DFA API is support for In-Stream video creatives which allow you to serve ads into a publisher’s video player. The way you upload assets and associate them with an In-Stream video creative differs from other types of creatives.
Unlike standard creative assets, you may not upload an in-stream asset unassigned to a creative. Therefore the first step to setting up a new In-Stream video creative has to be making the creative itself. The creative must start off inactive and cannot be activated until at least one media asset is assigned to it. You can start the process using our Java client library like so:
Once the creative exists, you can begin uploading assets for it. This process uses the new InStreamAssetUploadRequest object. The DFA website UI has the capability to transcode video formats during this step, but transcoding is not available through the API. You’ll need to upload media files for all of the video formats you need instead. We’ll start by adding a single media (video) asset since that is all that is required for an In-Stream creative to be activated:
In-Stream video creatives can have video assets associated with them that will not be served. Video assets default to this state when uploaded. You need to choose the video assets you want to be served:
The creative is now ready to be served. You can take the opportunity to add additional types of ads to it. The two options are companion banners - Flash banners that display on the webpage during and after the pre-roll video plays, and non-linear ads - interactive Flash or static image banners that display over the pre-roll video as it’s playing. Both types of additional content follow the same upload workflow using Now that the creative has associated assets, it can be activated:
That’s all there is to it. Complete code examples containing these steps are in our Java, Python, and .NET client libraries. We’re always available to field any of your questions on our forum.
Walk-Through
DfaSession session = new DfaSession.Builder().fromFile().build();
DfaServices dfaServices = new DfaServices();
CreativeRemote creativeService =
dfaServices.get(session, CreativeRemote.class);
// Create the In-Stream video creative.
InStreamVideoCreative inStreamVideoCreative =
new InStreamVideoCreative();
inStreamVideoCreative.setAdvertiserId(advertiserId);
inStreamVideoCreative.setName(creativeName);
inStreamVideoCreative.setVideoDuration(videoDuration);
// In-Stream video creatives have to be created inactive. One can only
// be set active after at least one video media file has been added to
// it.
inStreamVideoCreative.setActive(false);
// Set the video details based on the Video Ad Serving Template (VAST)
// specification.
inStreamVideoCreative.setAdId(adId);
inStreamVideoCreative.setDescription(description);
inStreamVideoCreative.setSurveyUrl(surveyUrl);
inStreamVideoCreative.setClickThroughUrl(clickThroughUrl);
// Save the In-Stream video creative.
CreativeSaveResult creativeSaveResult =
creativeService.saveCreative(inStreamVideoCreative, campaignId);
// Create the In-Stream video creative asset.
CreativeAsset inStreamVideoAsset = new CreativeAsset();
inStreamVideoAsset.setName(assetName);
inStreamVideoAsset.setContent(Media.getMediaDataFromFile(pathToFile));
// Create an upload request to make this asset a media file for an
// existing In-Stream creative.
InStreamAssetUploadRequest inStreamAssetUploadRequest =
new InStreamAssetUploadRequest();
inStreamAssetUploadRequest.setMediaFile(true);
inStreamAssetUploadRequest.setInStreamAsset(inStreamVideoAsset);
inStreamAssetUploadRequest.setCreativeId(creativeSaveResult.getId());
// Save the media file to your In-Stream creative.
InStreamVideoCreative inStreamVideoCreative =
creativeService.uploadInStreamAsset(inStreamAssetUploadRequest);
for (InStreamMediaFile mediaFile : inStreamVideoCreative.getMediaFiles()) {
mediaFile.setPickedToServe(true);
}
InStreamAssetUploadRequest, only instead of setting the
mediaFile flag to
true, you set the
companion or
nonLinear flag instead.
inStreamVideoCreative.setActive(true);
CreativeSaveResult creativeSaveResult =
creativeService.saveCreative(inStreamVideoCreative, campaignId);