Exemple #1
0
 def test_video_defaults(self):
     """Ensure that default video options are properly generated."""
     built = Stream(1, 'video', FAKE_CODEC)
     assert built.build_options() == [
         '-c:v:0', 'libx264', '-preset', defaults.PRESET, '-crf',
         str(defaults.CRF), '-pix_fmt', 'yuv420p'
     ]
Exemple #2
0
 def test_subtitle_transcode(self):
     """Ensure that subtitle options are properly generated for
     transcoding."""
     built = Stream(1, 'subtitle', FAKE_CODEC)
     assert built.build_options() == ['-c:s:0', defaults.C_SUBS]
     assert built.option_summary == ('transcode -> {}'.format(
         defaults.C_SUBS))
Exemple #3
0
 def test_stream_ops_transcode_num(self):
     """Ensure that Stream.build_options properly includes the stream number
     when generating stream transcoding options."""
     for number in range(0, 10, 3):
         for stream_type in ['audio', 'video', 'subtitle']:
             built = Stream(number // 2, stream_type, FAKE_CODEC)
             options = built.build_options(number)
             assert options[0].split(':')[-1] == str(number)
Exemple #4
0
 def test_audio_defaults(self):
     """Ensure that default audio options are properly generated."""
     built = Stream(4, 'audio', FAKE_CODEC)
     assert built.build_options() == [
         '-c:a:0', defaults.C_AUDIO, '-b:a:0',
         str(defaults.BITRATE) + 'k'
     ]
     assert built.option_summary == (
         'transcode -> {}, bitrate={}Kib/s'.format(defaults.C_AUDIO,
                                                   defaults.BITRATE))
Exemple #5
0
 def test_video_custom_crf(self):
     """Ensure that video options are properly generated with a custom
     crf."""
     crf = 11
     built = Stream(2, 'video', FAKE_CODEC, custom_crf=crf)
     assert built.build_options() == [
         '-c:v:0', 'libx264', '-preset', defaults.PRESET, '-crf',
         str(crf), '-pix_fmt', 'yuv420p'
     ]
     assert built.option_summary == ('transcode -> {}, crf={}'.format(
         defaults.C_VIDEO, crf))
Exemple #6
0
 def test_stream_options_copy_number(self):
     """Ensure that Stream.build_options properly includes the stream number
     when generating stream copying options."""
     for number in range(0, 10, 3):
         for stream_type, default in {
                 'audio': defaults.C_AUDIO,
                 'video': defaults.C_VIDEO,
                 'subtitle': defaults.C_SUBS
         }.items():
             built = Stream(number // 2, stream_type, default)
             options = built.build_options(number)
             assert options[0].split(':')[-1] == str(number)
Exemple #7
0
 def test_audio_custom_bitrate(self):
     """Ensure that audio options are properly generated with a custom
     bitrate."""
     bitrate = 512
     built = Stream(5, 'audio', FAKE_CODEC, custom_bitrate=bitrate)
     assert built.build_options() == [
         '-c:a:0', defaults.C_AUDIO, '-b:a:0',
         str(bitrate) + 'k'
     ]
     assert built.option_summary == (
         'transcode -> {}, bitrate={}Kib/s'.format(defaults.C_AUDIO,
                                                   bitrate))
Exemple #8
0
 def test_audio_labels_bitrate(self):
     """Ensure that audio options are properly generated when using the
     labels bitrate."""
     bitrate = 256
     labels = StreamLabel(bitrate=bitrate)
     built = Stream(2, 'audio', FAKE_CODEC, labels=labels)
     assert built.build_options() == [
         '-c:a:0', defaults.C_AUDIO, '-b:a:0',
         str(bitrate) + 'k'
     ]
     assert built.option_summary == (
         'transcode -> {}, bitrate={}Kib/s'.format(defaults.C_AUDIO,
                                                   bitrate))
Exemple #9
0
 def test_minimal(self):
     """Ensure that optional and instance  Stream attrs are properly
     instantiated."""
     built = Stream(2, 'audio', 'mp3')
     attrs = {
         'custom_crf': None,
         'custom_bitrate': None,
         'option_summary': None,
         'labels': StreamLabel()
     }
     for attr, value in attrs.items():
         assert getattr(built, attr) == value
Exemple #10
0
def other_audio_stream():
    """Return an example Stream that should match the non-default audio stream
    from example.json."""
    return Stream(2, 'audio', 'opus', '', '', other_audio_streamlabel())
Exemple #11
0
def example_audio_stream():
    """Return an example Stream which should match the default audio stream
    from example.json."""
    return Stream(1, 'audio', 'vorbis', '', '', example_audio_streamlabel())
Exemple #12
0
 def test_subtitle_copy(self):
     """Ensure that subtitle options are properly generated for copying."""
     built = Stream(3, 'subtitle', defaults.C_SUBS)
     assert built.build_options() == ['-c:s:0', 'copy']
     assert built.option_summary == 'copy'
Exemple #13
0
 def test_match_example_video(self, example_video_stream):
     """Ensure that the example audio instance matches one built from
     example.json."""
     built = Stream.from_dict(EXAMPLE['streams'][0])
     assert example_video_stream == built
Exemple #14
0
 def test_audio_copy(self):
     """Ensure that audio options are properly generated for copying."""
     test = Stream(3, 'audio', defaults.C_AUDIO)
     assert test.build_options() == ['-c:a:0', 'copy']
     assert test.option_summary == 'copy'
Exemple #15
0
 def test_match_example_sub(self, example_sub_stream):
     """Ensure that the example subtitle instance matches one built from
     example.json."""
     built = Stream.from_dict(EXAMPLE['streams'][3])
     assert example_sub_stream == built
Exemple #16
0
def example_video_stream():
    """Return an example Stream which should match the video stream from
    example.json."""
    return Stream(0, 'video', 'vp8', '', '', example_video_streamlabel())
Exemple #17
0
def example_sub_stream():
    """Return an example Stream which should match the subtitle stream from
    example.json."""
    return Stream(3, 'subtitle', 'subrip', '', '', example_sub_streamlabel())
Exemple #18
0
 def test_video_copy(self):
     """Ensure that video options are properly generated for copying."""
     built = Stream(2, 'video', defaults.C_VIDEO)
     assert built.build_options() == ['-c:v:0', 'copy']
     assert built.option_summary == 'copy'