Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: How to insert mid-ad (get from own ad server) into the content when using packager HLS stream? #650

Closed
Romantic-LiXuefeng opened this issue Sep 5, 2019 · 13 comments
Labels
status: archived Archived and locked; will not be updated type: question A question from the community

Comments

@Romantic-LiXuefeng
Copy link

Romantic-LiXuefeng commented Sep 5, 2019

ad_cues <start_time[;start_time]>
List of cuepoint markers separated by semicolon. The start_time represents the start of the cue marker in seconds (double precision) relative to the start of the program. This flag preconditions content for Dynamic Ad Insertion with Google Ad Manager. For DASH, multiple periods will be generated with period boundaries at the next key frame to the designated start times; For HLS, segments will be terminated at the next key frame to the designated start times and ‘#EXT-X-PLACEMENT-OPPORTUNITY’ tag will be inserted after the segment in media playlist.

I have some questions about this description.

This flag preconditions content for Dynamic Ad Insertion with Google Ad Manager.

  1. Whether this ad options only works with Google Ad Manager or not.
    Before packager the HLS stream, I have request the pre-ad, mid-ad and post-ad
    from our own ad server. I found ad_cues <start_time[;start_time]> only support
    adding parameter start_time, Can't set the ad url. If not support setting ad url, please
    give some advice how to implement this feature.

For HLS, segments will be terminated at the next key frame to the designated start times and ‘#EXT-X-PLACEMENT-OPPORTUNITY’ tag will be inserted after the segment in media playlist.

  1. I have searched the HLS draft. https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.4.1 . I'm sorry, nothing has found about the #EXT-X-PLACEMENT-OPPORTUNITY tag.
    Also, I searched the ExoPlayer, the player also do nothing about this Tag. Please hope give some useful information.
@Romantic-LiXuefeng Romantic-LiXuefeng changed the title Question: How to insert mid-ad (get from own ad server) into the content when using HLS? Question: How to insert mid-ad (get from own ad server) into the content when using packager HLS stream? Sep 5, 2019
@kqyang
Copy link
Collaborator

kqyang commented Sep 5, 2019

Shaka Packager does not insert the Ads itself. What it does is to precondition the content for Ad insertion.

#EXT-X-PLACEMENT-OPPORTUNITY is a Google extension for Ad Insertion. If you don't use Google Ad Manager, what you can do is to replace #EXT-X-PLACEMENT-OPPORTUNITY with #EXT-X-DISCONTINUITY followed by Ad segments (#EXTINF...) yourself.

@Romantic-LiXuefeng Does that answer your question?

@kqyang kqyang added type: question A question from the community and removed needs triage labels Sep 5, 2019
@Romantic-LiXuefeng
Copy link
Author

Romantic-LiXuefeng commented Sep 6, 2019

Because of the Chine Internet firewall, i can't use the Google Ad Manager, so that I can't run a example with the options ad_cues <start_time[;start_time]> to check the result HLS manifest.

  1. Whether the Shaka Packager only add a #EXT-X-PLACEMENT-OPPORTUNITY Tag. The packager result like this.
#EXTM3U
#EXT-X-VERSION:6
## Generated with https://github.com/google/shaka-packager version <tag>-<hash>-<test>
#EXT-X-TARGETDURATION:2
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-MAP:URI="bear-640x360-video-init.mp4"
#EXTINF:1.001,
bear-640x360-video-1.m4s
#EXTINF:1.001,
bear-640x360-video-2.m4s
#EXT-X-PLACEMENT-OPPORTUNITY
#EXTINF:0.734,
bear-640x360-video-3.m4s
#EXT-X-ENDLIST

from https://github.com/google/shaka-packager/tree/master/packager/app/test/testdata/hls-audio-video-text-with-ad-cues

I want to know when to insert the ad? If not insert ad, the player how to play ?
In my opinion, the Manifest should like this:

#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-VERSION:4
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:10.0,
ad0.ts
#EXTINF:8.0,
ad1.ts
#EXT-X-DISCONTINUITY
#EXTINF:10.0,
movieA.ts
#EXTINF:10.0,
movieB.ts

@kqyang
Copy link
Collaborator

kqyang commented Sep 6, 2019

#EXT-X-PLACEMENT-OPPORTUNITY is the place to insert mid-roll Ads. As mentioned earlier, you can just replace it with your Ad segment tags.

For example, you have a mid-roll ad segment you want to insert: mid_roll_ad.ts

Packager pre-conditioned playlist:

#EXTM3U
#EXT-X-VERSION:6
## Generated with https://github.com/google/shaka-packager version <tag>-<hash>-<test>
#EXT-X-TARGETDURATION:2
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:1.001,
bear-640x360-video-1.ts
#EXTINF:1.001,
bear-640x360-video-2.ts
#EXT-X-PLACEMENT-OPPORTUNITY
#EXTINF:0.734,
bear-640x360-video-3.ts
#EXT-X-ENDLIST

You can replace #EXT-X-PLACEMENT-OPPORTUNITY with your Ad segment:

#EXTM3U
#EXT-X-VERSION:6
## Generated with https://github.com/google/shaka-packager version <tag>-<hash>-<test>
#EXT-X-TARGETDURATION:2
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:1.001,
bear-640x360-video-1.ts
#EXTINF:1.001,
bear-640x360-video-2.ts
#EXT-X-DISCONTINUITY
#EXTINF:1.000,
mid_roll_ad.ts
#EXT-X-DISCONTINUITY
#EXTINF:0.734,
bear-640x360-video-3.ts
#EXT-X-ENDLIST

As for pre-roll and post-roll ads, you can just insert it before all media segments and after all media segments respectively. They don't really need ads pre-conditioning.

If not insert ad, the player how to play ?

It should just work as the player ignores unrecognized tags according to HLS specification.

@Romantic-LiXuefeng
Copy link
Author

ok! Thanks for your help.

@Romantic-LiXuefeng
Copy link
Author

Romantic-LiXuefeng commented Sep 19, 2019

@kqyang Just doing as your suggestions to insert the mid ad. Not play correctly using ExoPlayer. I have report a issue to ExoPlayer. But I can't confirm whether the bug of ExoPlayer. # google/ExoPlayer#6444

@kqyang
Copy link
Collaborator

kqyang commented Sep 19, 2019

Have you tried Shaka Player?

@Romantic-LiXuefeng
Copy link
Author

Romantic-LiXuefeng commented Sep 20, 2019

@kqyang I'm sorry. I'm not familiar with Shaka Player, and try to play with it. If have some result, I will report. I also have sent the content to shaka-packager-issues@google.com.

@Romantic-LiXuefeng
Copy link
Author

@kqyang I followed the description in https://github.com/google/shaka-player/blob/master/docs/tutorials/basic-usage.md. Can't start to play. I also start to play the stream using Safari browser. It plays well.

@kqyang
Copy link
Collaborator

kqyang commented Sep 20, 2019

@Romantic-LiXuefeng You can just use the demo player at: https://shaka-player-demo.appspot.com/demo/#audiolang=en-US;textlang=en-US;uilang=en-US;panel=HOME;build=uncompiled.

Looks like ExoPlayer team has already figured out where the problem is :)

@Romantic-LiXuefeng
Copy link
Author

@kqyang The ExoPlayer team has fixed the problem. Hope to support muxing all the streams into TS container for reducing the process of demuxing ads into separate streams.

Also, there is a bug, Using Docker with latest version to insert multi mid ads, e.g. 60s and 120s. Only the first mid ad can generate #EXT-X-PLACEMENT-OPPORTUNITY Tag. others failed.

/ # packager 'in=/media/google_io_2017.mp4,stream=video,segment_template=/media/mp4_to_hls/h264_1080p/h264/$Number$.ts,playlist_name=/h264_1080p/h264.m3u8' \
>    'in=/media/google_io_2017.mp4,stream=audio,segment_template=/media/mp4_to_hls/h264_1080p/aac/$Number$.aac,playlist_name=/h264_1080p/aac.m3u8' \
>     --ad_cues 60;120 \
>             --segment_duration 10 \
>     --hls_master_playlist_output /media/mp4_to_hls/h264_master.m3u8
[0923/015017:INFO:demuxer.cc(88)] Demuxer::Run() on file '/media/google_io_2017.mp4'.
[0923/015017:INFO:demuxer.cc(160)] Initialize Demuxer for file '/media/google_io_2017.mp4'.
Packaging completed successfully.
/bin/sh: 120: not found

@kqyang kqyang reopened this Sep 23, 2019
@kqyang
Copy link
Collaborator

kqyang commented Sep 23, 2019

@Romantic-LiXuefeng Can you provide the source stream you were using? We can try if we can re-produce the problem.

@Romantic-LiXuefeng
Copy link
Author

Romantic-LiXuefeng commented Sep 24, 2019

@kqyang I have sent the source stream to shaka-packager-issues@google.com.

@kqyang
Copy link
Collaborator

kqyang commented Sep 25, 2019

@Romantic-LiXuefeng It works for me. Note that ";" is a special character in some Linux shells, so remember to enclose it (e.g. enclose in '': '60;120') or skip it (i.e. 60;120) if you run the command in Linux shells.

#EXTM3U
#EXT-X-VERSION:6
## Generated with https://github.com/google/shaka-packager version 3aa0bd6938-debug
#EXT-X-TARGETDURATION:20
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:10.000,
1.ts
#EXTINF:16.000,
2.ts
#EXTINF:10.000,
3.ts
#EXTINF:10.000,
4.ts
#EXTINF:10.000,
5.ts
#EXTINF:9.800,
6.ts
#EXT-X-PLACEMENT-OPPORTUNITY
#EXTINF:10.680,
7.ts
#EXTINF:10.000,
8.ts
#EXTINF:10.000,
9.ts
#EXTINF:10.000,
10.ts
#EXTINF:12.440,
11.ts
#EXTINF:10.000,
12.ts
#EXT-X-PLACEMENT-OPPORTUNITY
#EXTINF:10.000,
13.ts
#EXTINF:10.000,
14.ts
#EXTINF:19.920,
15.ts
#EXTINF:9.960,
16.ts
#EXTINF:0.360,
17.ts
#EXTINF:10.000,
18.ts
#EXTINF:9.960,
19.ts
#EXTINF:3.680,
20.ts
#EXT-X-ENDLIST

@kqyang kqyang closed this as completed Sep 25, 2019
@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Nov 24, 2019
@shaka-project shaka-project locked and limited conversation to collaborators Nov 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated type: question A question from the community
Projects
None yet
Development

No branches or pull requests

3 participants