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`](https://docs.cloud.google.com/transcoder/docs/reference/rest/v1/JobConfig.md.txt) array to
insert
[ad break keyframes](https://docs.cloud.google.com/transcoder/docs/reference/rest/v1/JobConfig.md.txt#adbreak)
in the output video. You can add this configuration to a
[job template](https://docs.cloud.google.com/transcoder/docs/how-to/job-templates.md.txt) or include it in an
[ad-hoc job configuration](https://docs.cloud.google.com/transcoder/docs/how-to/jobs.md.txt#create_jobs_ad_hoc).

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

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

You can use a tool like
[`ffprobe`](https://ffmpeg.org/ffprobe.html) to verify that the
keyframes were inserted. The following output shows a sample output video
*without* ad break keyframes inserted:

```bash
$ 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:

```bash
$ 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](https://docs.cloud.google.com/transcoder/docs/reference/rest/v1/JobConfig.md.txt#manifest) to
verify that the ad break tags were inserted.