GitBucket
4.21.2
Toggle navigation
Snippets
Sign in
Files
Branches
2
Releases
1
Issues
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
nigel.stanger
/
process_podcast
Browse code
Added initial tests for FFmpegConcatCommand (ref #31).
master
1 parent
b23d406
commit
d1eb1e1a32529da4260f60c68564fa4f4b082b54
Nigel Stanger
authored
on 20 Sep 2018
Patch
Showing
1 changed file
test_ffmpeg_concat_command.py
Ignore Space
Show notes
View
test_ffmpeg_concat_command.py
0 → 100644
import shutil from pathlib import Path import tempfile import unittest from unittest.mock import MagicMock from segment import Segment from shell_command import FFmpegConcatCommand from test_shared import ShellCommandSharedTestCase class FFmpegConcatCommandTestCase(ShellCommandSharedTestCase): """Test the FFmpegConcatCommand class.""" # What about testing different permutations of audio and video? def setUp(self): """Set up for test.""" # Make sure the input and output options are explicitly set, # otherwise they hang around from previous tests. self.command = FFmpegConcatCommand( input_options=["-i", "in.mov"], output_options=["out.mov"], has_video=True, has_audio=True, quiet=True) self.expected_executable = shutil.which("ffmpeg") self.expected_base_options = ["-y", "-nostdin",] self.expected_input_options = ["-i", "in.mov"] self.expected_filter_options = ["-filter_complex", ""] self.expected_output_options = [ "-codec:a", self.command.audio_codec, "-ac", "1", "-map", "[anorm]", "-codec:v", self.command.video_codec, "-pix_fmt", "yuv420p", "-map", "[vconc]", "out.mov" ] def tearDown(self): """Clean up after test.""" self.command = None def test_append_filter(self): """Test appending to the filter list.""" # append empty filter => no change with self.subTest(msg="empty"): filters = [] self.command.append_filter("") self.assertEqual(self.command.filters, filters) # append an actual filter with self.subTest(msg="normal"): filters = ["this_is_a_weird_filter"] self.command.append_filter("this_is_a_weird_filter") self.assertEqual(self.command.filters, filters) def test_append_normalisation_filter(self): """Test appending a normalisation filter.""" filters = ["[aconc] dynaudnorm=r=0.25:f=10:b=y [anorm]"] self.command.append_normalisation_filter() self.assertEqual(self.command.filters, filters) def test_append_concat_filter_0(self): """Test appending a concat filter with no segments.""" self.command.append_concat_filter(type="a", segments=[]) with self.subTest(msg="audio"): self.assertEqual(self.command.filters, []) self.command.append_concat_filter(type="v", segments=[]) with self.subTest(msg="video"): self.assertEqual(self.command.filters, []) self.command.append_concat_filter(type="f", segments=[]) with self.subTest(msg="frame"): self.assertEqual(self.command.filters, []) def test_append_concat_filter_f(self): """Test appending a concat filter with a frame segment.""" self.command.append_concat_filter(type="f", segments=[Segment()]) self.assertEqual( self.command.filters, [], msg="frame segments should be ignored") # def test_append_concat_filter_1_a(self): # """Test appending a concat filter with 1 audio segment.""" # self.command.append_concat_filter( # type="a", # segments=[Segment(file="a.mov", punch_in=10, # punch_out=20, input_stream=1)]) # with self.subTest(msg="audio"): # self.assertEqual(self.command.filters, []) # def test_append_concat_filter_1_v(self): # """Test appending a concat filter with 1 video segment.""" # concat = # self.command.append_concat_filter(type="v", # segments=[Segment(file="v.mov", punch_in=10, # punch_out=20, input_stream=1)]) # with self.subTest(msg="audio"): # self.assertEqual() # def test_append_concat_filter_2(self): # """Test appending a concat filter with >1 segment.""" # def test_build_complex_filter(self): # """Test building the complex filter.""" # Remove ShellCommandSharedTestCase from the namespace so we don't run # the shared tests twice. See <https://stackoverflow.com/a/22836015>. del(ShellCommandSharedTestCase)
Show line notes below