Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2 from xwu2git/master
Browse files Browse the repository at this point in the history
merge master
  • Loading branch information
xwu2git authored Jan 29, 2020
2 parents c3e598e + aed79c5 commit e51c9cd
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 33 deletions.
19 changes: 7 additions & 12 deletions ad-insertion/ad-transcode/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
import traceback

adinsert_archive_root="/var/www/adinsert"
segment_dash_root=adinsert_archive_root+"/segment/dash"
segment_hls_root=adinsert_archive_root+"/segment/hls"
adsegment_archive_root="/var/www/adsegment"
dash_root=adinsert_archive_root+"/dash"
hls_root=adinsert_archive_root+"/hls"
zk_segment_prefix="/ad-insertion-segment"
Expand Down Expand Up @@ -57,21 +56,18 @@

def ADPrefetch(ad_uri):
# retrive the ad from the ad content and save to local adinsert_archive_root firstly and return the local stream name
#ad_uri = ad_content_server+"/" +"GibfM0FYj_g.mp4"
target=adinsert_archive_root+"/" + ad_uri.split("/")[-1]
#print(target)
if ad_uri.find("http://") != -1:
try:
print("Retrieve "+ad_uri, flush=True)
r = requests.get(ad_uri,timeout=timeout)
if r.status_code == 200:
with open(target, "wb") as f:
f.write(r.content)
return target
except requests.exceptions.RequestException as e: # This is the correct syntax
print("Error sending status request in ADPrefetch()" + str(e), flush=True)
elif not isfile(ad_uri):
print("The ad content uri %s is not a file!"+ad_uri)
return None
except:
print(traceback.format_exc(), flush=True)
return None

def ADClipDecision(msg, db):
duration = msg.time_range[1]-msg.time_range[0]
Expand Down Expand Up @@ -122,9 +118,7 @@ def __init__(self, kafkamsg):
self.width = self.msg["ad_config"]["resolution"]["width"]
self.bitrate = self.msg["ad_config"]["bandwidth"]
self.bench_mode = self.msg["bench_mode"]
self.segment_path = segment_hls_root
if self.streaming_type=="dash":
self.segment_path = segment_dash_root
self.segment_path = adsegment_archive_root+"/"+self.streaming_type

def GetRedition(self):
redition = ([self.width, self.height, self.bitrate, 128000],)
Expand Down Expand Up @@ -170,6 +164,7 @@ def ADTranscode(kafkamsg, db):
else:
try:
stream_folder = msg.segment_path + "/" + stream.split("/")[-1]
print("Checking pre-transcoded stream: "+stream_folder, flush=True)
if isdir(stream_folder): # pre-transcoded AD exists
print("Prefetch the AD segment {} \n".format(stream_folder),flush=True)
CopyADSegment(msg,stream)
Expand Down
3 changes: 1 addition & 2 deletions deployment/docker-swarm/ad-insertion.m4
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
ad-insertion-service:
image: ssai_ad_insertion_frontend:latest
volumes:
- ${AD_DASH_VOLUME}:/var/www/adinsert/dash:ro
- ${AD_HLS_VOLUME}:/var/www/adinsert/hls:ro
- ${AD_CACHE_VOLUME}:/var/www/adinsert:ro
- ${AD_STATIC_VOLUME}:/var/www/adstatic:ro
environment:
AD_INTERVALS: 12
Expand Down
6 changes: 2 additions & 4 deletions deployment/docker-swarm/ad-transcode.m4
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
NO_PROXY: "*"
no_proxy: "*"
volumes:
- ${AD_DASH_VOLUME}:/var/www/adinsert/dash:rw
- ${AD_HLS_VOLUME}:/var/www/adinsert/hls:rw
- ${AD_SEGMENT_DASH_VOLUME}:/var/www/adinsert/segment/dash:ro
- ${AD_SEGMENT_HLS_VOLUME}:/var/www/adinsert/segment/hls:ro
- ${AD_CACHE_VOLUME}:/var/www/adinsert:rw
- ${AD_SEGMENT_VOLUME}:/var/www/adsegment:ro
networks:
- appnet
deploy:
Expand Down
3 changes: 1 addition & 2 deletions deployment/docker-swarm/content-provider.m4
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
no_proxy: "*"
volumes:
- ${VIDEO_ARCHIVE_VOLUME}:/var/www/archive:ro
- ${VIDEO_DASH_VOLUME}:/var/www/video/dash:ro
- ${VIDEO_HLS_VOLUME}:/var/www/video/hls:ro
- ${VIDEO_CACHE_VOLUME}:/var/www/video:ro
networks:
- appnet
deploy:
Expand Down
3 changes: 1 addition & 2 deletions deployment/docker-swarm/content-transcode.m4
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
no_proxy: "*"
volumes:
- ${VIDEO_ARCHIVE_VOLUME}:/var/www/archive:ro
- ${VIDEO_DASH_VOLUME}:/var/www/video/dash:rw
- ${VIDEO_HLS_VOLUME}:/var/www/video/hls:rw
- ${VIDEO_CACHE_VOLUME}:/var/www/video:rw
networks:
- appnet
deploy:
Expand Down
20 changes: 9 additions & 11 deletions deployment/docker-swarm/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,22 @@

DIR=$(dirname $(readlink -f "$0"))
export AD_ARCHIVE_VOLUME=$(readlink -f "$DIR/../../volume/ad/archive")
export AD_DASH_VOLUME=$(readlink -f "$DIR/../../volume/ad/cache/dash")
export AD_HLS_VOLUME=$(readlink -f "$DIR/../../volume/ad/cache/hls")
export AD_SEGMENT_ARCHIVE_VOLUME=$(readlink -f "$DIR/../../volume/ad/segment/archive")
export AD_SEGMENT_DASH_VOLUME=$(readlink -f "$DIR/../../volume/ad/segment/dash")
export AD_SEGMENT_HLS_VOLUME=$(readlink -f "$DIR/../../volume/ad/segment/hls")
export AD_CACHE_VOLUME=$(readlink -f "$DIR/../../volume/ad/cache")
export AD_SEGMENT_VOLUME=$(readlink -f "$DIR/../../volume/ad/segment")
export AD_STATIC_VOLUME=$(readlink -f "$DIR/../../volume/ad/static")
export VIDEO_ARCHIVE_VOLUME=$(readlink -f "$DIR/../../volume/video/archive")
export VIDEO_DASH_VOLUME=$(readlink -f "$DIR/../../volume/video/cache/dash")
export VIDEO_HLS_VOLUME=$(readlink -f "$DIR/../../volume/video/cache/hls")
export VIDEO_CACHE_VOLUME=$(readlink -f "$DIR/../../volume/video/cache")

docker container prune -f
docker volume prune -f
docker network prune -f

rm -rf "${AD_DASH_VOLUME}" "${AD_HLS_VOLUME}"
mkdir -p "${AD_DASH_VOLUME}" "${AD_HLS_VOLUME}"
mkdir -p "${AD_SEGMENT_DASH_VOLUME}" "${AD_SEGMENT_HLS_VOLUME}"
mkdir -p "${VIDEO_DASH_VOLUME}" "${VIDEO_HLS_VOLUME}"
for mode in dash hls; do
rm -rf "${AD_CACHE_VOLUME}/$mode"
mkdir -p "${AD_CACHE_VOLUME}/$mode"
mkdir -p "${AD_SEGMENT_VOLUME}/$mode"
mkdir -p "${VIDEO_CACHE_VOLUME}/$mode"
done

yml="$DIR/docker-compose.$(hostname).yml"
test -f "$yml" || yml="$DIR/docker-compose.yml"
Expand Down
6 changes: 6 additions & 0 deletions deployment/kubernetes/ad-transcode.yaml.m4
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ spec:
volumeMounts:
- mountPath: /var/www/adinsert
name: ad-cache
- mountPath: /var/www/adsegment
name: ad-segment
readOnly: true
volumes:
- name: ad-cache
persistentVolumeClaim:
claimName: ad-cache
- name: ad-segment
persistentVolumeClaim:
claimName: ad-segment

0 comments on commit e51c9cd

Please sign in to comment.