Skip to content

Commit

Permalink
Merge pull request #18 from gumgum/frame-extractor-fixes
Browse files Browse the repository at this point in the history
Frame extractor fixes
  • Loading branch information
magreenberg1 authored Jun 14, 2019
2 parents b8d8bca + f2d47fb commit 7e1d687
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
16 changes: 12 additions & 4 deletions multivitamin/applications/images/frame_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import boto3
import glog as log
import numpy as np
import traceback
from PIL import Image

from multivitamin.module import PropertiesModule

from multivitamin.module import PropertiesModule, Codes
from multivitamin.utils.work_handler import WorkerManager
from multivitamin.media import MediaRetriever
from multivitamin.data.response.utils import get_current_time
Expand Down Expand Up @@ -186,7 +188,15 @@ def process_properties(self):
# log.info('Getting hash')
# video_hash = hashfileobject(filelike, hexdigest=True)
self.video_url = self.response.request.url
self.med_ret = MediaRetriever(self.video_url)
try:
log.info(f"Loading media from url: {self.response.request.url}")
self.med_ret = MediaRetriever(self.video_url)
except Exception as e:
log.error(e)
log.error(traceback.print_exc())
self.code = Codes.ERROR_LOADING_MEDIA
return

self.contents_file_key = get_contents_file_s3_key(self.video_url,
self._sample_rate)
video_id = self.contents_file_key.split("/")[0]
Expand Down Expand Up @@ -249,11 +259,9 @@ def process_properties(self):
if self._local_dir is not None:
self._add_contents_to_local(contents)

self.response.url_original = self.video_url
new_url = self._s3_url_format.format(
bucket=self._s3_bucket, s3_key=self.contents_file_key
)
self.response.url = new_url
p = Property(
server=self.name,
ver=self.version,
Expand Down
3 changes: 0 additions & 3 deletions multivitamin/media/pims_media_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,13 @@ def _create_video_capture(self):

return self._cap

@property
def _get_fps_from_video_capture(self):
return self.video_capture.frame_rate

@property
def _get_num_frames(self):
"""Get the total number of frames."""
return len(self.video_capture)

@property
def _get_video_frame_shape(self):
"""Get height by width by channels for frames."""
shape = self.video_capture.frame_shape
Expand Down

0 comments on commit 7e1d687

Please sign in to comment.