Skip to main content

An Explanation of Context-Based Ad Optimization Technology

Introduction​


This article outlines a method for identifying the best moments to insert commercials by analyzing the context of drama scenes, all in a single query.

A mid-episode commercial is one that briefly interrupts the drama to air an advertisement. What this article focuses on is timing for commercials that flow naturally from the preceding scene.

  • Insert a liquor commercial right after a drinking scene ends.
  • Insert a car commercial right after a scene where someone gets out of a car ends.

I didn’t create a separate service to find ad placement points. I use the same scheduling process as for short-form videos and compilation videos, but adapt the queries specifically for ads. The scheduling system selects scenes that match the query and returns them as clips. In an ad query, this clip is the “scene that appears immediately before the ad,” and the exact moment the clip ends is the ad placement point.

image

The scheduling process itself was covered in “Designing a Langgraph-Based Broadcast Workflow” and “Implementation of the Compilation Service.” This article explains how to write ad queries, what the scheduling process reads, and what results it produces. The results in Sections 3–6 were obtained by scheduling the first episode and episodes 1–10 of a drama on October 20, 2026.


1. How to Write an Ad Query​

An ad query consists of three parts.

  • Ad Type and Number: What type of ad to insert and how many ad slots to find
  • Following Scene: The scene that follows the ad in context
  • Break Point: Where in the scene to pause

image

  • "One segment" means to find only one ad placement. The scheduling process converts the number specified in the query into numerical values during the interpretation phase, and the code—not the model—ensures that this number is maintained.
  • "The end of the segment is the ad insertion point" is a statement that defines how the resulting clip will be used. The end time of the resulting clip is interpreted as the ad insertion point.
  • The following scene is described using the actions visible on screen, such as “a toast, a scene of drinking soju or beer.” This is because the cut descriptions read by the scheduling system also include actions, such as “clinking soju glasses and drinking” (Section 2).
  • The scheduling department provides the episode number and the start and end times of the clip. They do not specify the length of the commercial (15 seconds, 30 seconds, etc.). The scheduling department only answers “where to place it.”

There are three key points regarding Episode 1 in this article.

  • Alcohol: “One segment immediately preceding the best spot to insert an alcohol ad. It’s best right after a toast or a scene of drinking soju or beer ends naturally and just before the location changes. The end of that segment is the ad insertion point.”
  • Automobiles: “One segment to be placed before a passenger car advertisement. The ideal point is where scenes involving driving, the road, or getting in and out of the car end.”
  • Swimming Pool Supplies: “One segment to place before a swimming pool supplies ad. The point where scenes of the pool or water play end.”

2. Information Read by the Scheduler​

The scheduler does not rewatch the footage. They read the text and dialogue notes attached to the scenes and cuts in the previous step.

image

  • A scene is a continuous sequence set in the same time and place. It includes the location, a summary, and a type. There are five types: main story, previous episode recap, next episode preview, credits, and commercials.
  • A cut is a segment that lasts until the next shot. Each cut is labeled with start and end times, the shot type, location, and a one-sentence description. The description includes actions such as “clinking soju glasses” or “after a man in a suit exits through the back door,” and phrases matching the actions described in the commercial script appear here.
  • When dividing segments, the editor arranges the screen descriptions and dialogue within a scene in chronological order, line by line, and selects the starting and ending lines. Consequently, the beginning and end of a clip align with the boundaries between cuts or lines of dialogue.

Ad types and ad timings are different

  • The “ad” type for cuts and scenes refers to ad screens that were already included in the original broadcast. Since the video used for analysis is the broadcast version, there are segments at the beginning and end of each episode where the screen is split to display footage of advertised products alongside the drama. This type was designated to distinguish these screens from the drama footage.
  • The ad placements discussed in this article refer to new spots where ads will be inserted. These are separate from the original ad locations, and both ad placements mentioned in this article occurred within scenes of the main program.

3. Alcohol Advertising​

image

  • The result is one clip: Episode 1, 0:33:18–0:33:22 (4 seconds). The ad timing is 0:33:22.
  • The clip contains two shots. One shot shows three men sitting around a round table, clinking their soju glasses and drinking, and another shows a man in a suit wearing glasses raising his soju glass to drink. The beginning and end of the clip align with the shot boundaries and fall within 1 second of them.
  • Actions described in the inquiry, such as “toasting and drinking soju or beer,” are depicted in these two shots. The point where the shot of clinking glasses and drinking ends marks the advertisement’s timing.
  • This scene is part of the bar scene (0:31:51–0:35:29). The scene continues for about 2 more minutes after the advertisement timing. Although the inquiry stated “just before the location changes,” the ad’s timing was set not at the point where the location changes, but at the end of the drinking shot.

4. Car Commercial​

image

  • The result is one clip: Episode 1, 0:59:50–1:00:04 (14 seconds). The commercial break occurs at 1:00:04.
  • The scene in the clip shows a taxi pulling up on the road in front of the school, a character getting out through the back door, walking down the school hallway, and entering a classroom.
  • The cut description reads, “After the taxi drives down the road and a man in a suit gets out through the back door.” This is the same action described in the query as “the scene of getting in and out of a car.” Although the query specified a “passenger car,” the vehicle in the selected scene is a taxi.
  • The clip begins at 0:59:50, where the previous scene (at home) ends. The first scene transitioning from the house scene to the school scene is the one where the character gets out of the car.
  • The scene of getting out of the car ends at 0:59:58, and the clip continues with shots of the hallway and classroom for another 6 seconds, ending at 1:00:04. The ad placement was set 6 seconds later than the “end of the car scene” requested by the inquirer, at the exact moment the classroom scene begins.

5. When There Are No Matching Scenes​

  • If you request an ad for swimming pool supplies in the same Episode 1, the search will return no results.
  • There are no swimming pool or water play scenes in Episode 1. Nothing matches in the scene’s location, summary, or cut descriptions.
  • We do not forcefully select a nonexistent scene to create a placement. If there is no matching scene, there is no ad placement either.

6. Searching Across Multiple Episodes​

  • You can bundle any number of episodes into a single scheduling request. The same applies to ad inquiries.
  • Episodes 1–10 were grouped to request alcohol advertising slots. The query was: “Find advertising slots suitable for alcohol ads. Places where ads can be inserted after alcohol scenes.” The phrasing differs from the query in Section 1, and there is no specified quantity (“one slot”).

image

  • The results were 20 clips totaling 6 minutes and 41 seconds. At least one clip was found in all ten episodes, with the highest counts being 7 in Episode 3 and 4 in Episode 8.
  • Of the 20 clips, 13 are scenes where alcohol (soju, beer, whiskey, toasts, etc.) appears in the cut description.
  • The remaining 7 clips do not feature alcohol in their descriptions. They include a mix of scenes such as conversations in a car, a meal in a traditional Korean house, drinking from a beverage carton by the river, and a standoff inside a vehicle.
  • The final seconds of each clip are potential candidates for ad placement. However, since scenes unrelated to alcohol are mixed in, it is difficult to use these results directly as a list of alcohol ad placement points. Unlike the query for Episode 1, which specified the number of scenes and cut points, this query contained fewer sentences to narrow down the scope.

Conclusion​

The current process for identifying advertising spots is structured as follows:

  • We use the same curation process as for short-form content and compilations, but only adapt the queries for advertising purposes. There is no separate step dedicated solely to advertising.
  • Queries consist of three parts: the type and number of ads, the following scene, and the cut point.
  • For scheduling, the system reads the location, summary, description, and dialogue associated with scenes and cuts, then cuts the clip at the boundary of that line.
  • The end of the clip marks the ad timing. If no matching scene is found, the result is empty.

Certain behaviors were also observed in the case study.

  • Since the ad timing uses the exact end of the clip, it sometimes fell in the middle of a scene (e.g., alcoholic beverages) or a few seconds after the point specified in the query (e.g., automobiles).
  • In queries with few sentences that grouped multiple episodes and narrowed the range, scenes unrelated to the query were included in the results.
  • The ad type is manually entered by the user in the query. There is no automated process for matching the ad list with specific scenes.
  • The results are limited to a list of ad timestamps. The process of actually creating a video with the ads inserted is not integrated.

Reference link)

This article presents the results of research conducted with support from the Ministry of Science and ICT and the National IT Industry Promotion Agency’s “2026 Open-Source AI and Software Development and Utilization Support Project.”