Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Commit

Permalink
fix auto generated images ffmpeg command
Browse files Browse the repository at this point in the history
EDUCATOR-2294
  • Loading branch information
muhammad-ammar committed Feb 12, 2018
1 parent 0529c52 commit 4e5144a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
1 change: 1 addition & 0 deletions video_worker/tests/data/test_instance_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ celery_deliver_queue: ""
global_timeout: 40

instance_prefix: ""
ffmpeg_compiled: "ffmpeg"
23 changes: 19 additions & 4 deletions video_worker/tests/test_video_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,25 @@ def setUp(self):
with open(TEST_INSTANCE_YAML, 'r') as stream:
self.settings = yaml.load(stream)

@patch.object(video_images.VideoImages, 'generate', return_value = ['a/1.png'])
@patch.object(video_images.VideoImages, 'upload', return_value = ['s3://images/a/1.png'])
@patch.object(video_images.VideoImages, 'update_val')
def test_create_and_update(self, mock_update_val, mock_upload, mock_generate):
"""
Verify that VideoImages.create_and_update method works as expected.
"""
video_images.VideoImages(
video_object=MockVideo,
work_dir=self.work_dir,
source_file=self.source_file,
jobid=101,
settings=self.settings
).create_and_update()

self.assertTrue(mock_generate.called)
mock_upload.assert_called_with(['a/1.png'])
mock_update_val.assert_called_with(['s3://images/a/1.png'])

@data(
{
'duration': 10, 'positions': [1, 4, 7],
Expand All @@ -57,10 +76,6 @@ def test_calculate_positions(self, duration, positions):
"""
self.assertEqual(video_images.VideoImages.calculate_positions(duration), positions)

@unittest.skipIf(
'TRAVIS' in os.environ and os.environ['TRAVIS'] == 'true',
'Skipping this test on Travis CI due to unavailability of required ffmpeg version.'
)
def test_generate(self):
"""
Verify that VideoImages.generate method works as expected.
Expand Down
6 changes: 2 additions & 4 deletions video_worker/video_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,8 @@ def generate(self):
generated_images.append(
os.path.join(self.work_dir, '{}.png'.format(uuid4().hex))
)
command = ('{ffmpeg} -ss {position} -i {video_file} -vf '
r'select="gt(scene\,0.4)",scale={width}:{height}'
' -vsync 2 -vframes 1 {output_file}'
' -hide_banner -y'.format(
command = ('{ffmpeg} -ss {position} -i {video_file} -y -vf scale={width}:{height}'
' -vsync 2 -vframes 1 {output_file}'.format(
ffmpeg=self.settings['ffmpeg_compiled'],
position=position,
video_file=self.source_video_file,
Expand Down

0 comments on commit 4e5144a

Please sign in to comment.