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

Commit

Permalink
fix(ffmpeg): fix issue for start and durtion argument position
Browse files Browse the repository at this point in the history
  • Loading branch information
felix committed Aug 27, 2019
1 parent 1ea487f commit 0215c6b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 7 additions & 0 deletions gnes/preprocessor/io_utils/ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,15 @@ def compile_args(input_fn: str = 'pipe:',
if fmt:
input_args += ['-f', fmt]

start_time = input_options.pop('ss', None)
duration = input_options.pop('t', None)

input_args += kwargs_to_cmd_args(input_options)
input_args += ['-i', input_fn]
if start_time is not None:
input_args += ['-ss', str(start_time)]
if duration is not None:
input_args += ['-t', str(duration)]

vf_args = []
if len(video_filters) > 0:
Expand Down
6 changes: 4 additions & 2 deletions tests/test_ffmpeg_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ def test_capture_audio(self):
self.assertEqual(audio_data1.shape, audio_data2.shape)

def test_split_audio(self):
audio.split_audio(input_fn=self.video_path)
chunks1 = audio.split_audio(input_fn=self.video_path)
with open(self.video_path, 'rb') as f:
data = f.read()
audio.split_audio(input_data=data)
chunks2 = audio.split_audio(input_data=data)
self.assertEqual(len(chunks1), len(chunks2))
self.assertEqual(chunks1[0].shape, chunks2[0].shape)

0 comments on commit 0215c6b

Please sign in to comment.