Inserting ad breaks

This page explains how to programmatically insert keyframes for ad breaks in a transcoded video. The Transcoder API does not insert or play ads, or stop media playback; video player clients are responsible for handling the keyframe.

Use the adBreaks array to insert ad break keyframes in the output video. You can add this configuration to a job template or include it in an ad-hoc job configuration .

The following REST/JSON configuration inserts ad break keyframes at 4, 7, and 11 seconds in the timeline of the output video:

  "adBreaks" 
 : 
  
 [ 
  
 { 
  
 "startTimeOffset" 
 : 
  
 "4s" 
  
 }, 
  
 { 
  
 "startTimeOffset" 
 : 
  
 "7s" 
  
 }, 
  
 { 
  
 "startTimeOffset" 
 : 
  
 "11s" 
  
 } 
 ], 
 

You can use a tool like ffprobe to verify that the keyframes were inserted. The following output shows a sample output video without ad break keyframes inserted:

 $  
ffprobe  
-loglevel  
error  
-skip_frame  
nokey  
-select_streams  
v:0  
-show_entries  
 \ 
  
 frame 
 = 
pkt_pts_time  
-of  
 csv 
 = 
 print_section 
 = 
 0 
  
hd.mp4 0 
.000000 3 
.000000 6 
.000000 9 
.000000 12 
.000000
... 

The following output shows the same output video timeline with ad break keyframes inserted:

 $  
ffprobe  
-loglevel  
error  
-skip_frame  
nokey  
-select_streams  
v:0  
-show_entries  
 \ 
  
 frame 
 = 
pkt_pts_time  
-of  
 csv 
 = 
 print_section 
 = 
 0 
  
hd.mp4 0 
.000000 3 
.000000 4 
.000000 <<< 
Inserted  
keyframe  
here 6 
.000000 7 
.000000 <<< 
Inserted  
keyframe  
here 9 
.000000 11 
.000000 <<< 
Inserted  
keyframe  
here 12 
.000000
... 

You can also check the output manifest file to verify that the ad break tags were inserted.

Create a Mobile Website
View Site in Mobile | Classic
Share by: