def test_Mandatory(self): opts = encoder.OptionSet(encoder.ChoiceOption(['foo', 'bar'])) self.assertFalse(opts.AllMandatoryOptions()) opts = encoder.OptionSet( encoder.ChoiceOption(['foo', 'bar']).Mandatory()) self.assertEquals( set([opt.name for opt in opts.AllMandatoryOptions()]), set(['foo/bar']))
def __init__(self, name='vp8'): super(Vp8Codec, self).__init__(name) self.extension = 'webm' self.options = [ encoder.Option('overshoot-pct', ['0', '15', '30', '45']), encoder.Option('undershoot-pct', ['0', '25', '50', '75', '100']), # CQ mode is not considered for end-usage at the moment. encoder.Option('end-usage', ['cbr', 'vbr']), # End-usage cq doesn't really make sense unless we also set q to something # between min and max. This is being checked. # encoder.Option('end-usage', ['cbr', 'vbr', 'cq']), encoder.Option('end-usage', ['cbr', 'vbr']), encoder.Option('min-q', ['0', '2', '4', '8', '16', '24']), encoder.Option('max-q', ['32', '56', '63']), encoder.Option( 'buf-sz', ['200', '500', '1000', '2000', '4000', '8000', '16000']), encoder.Option( 'buf-initial-sz', ['200', '400', '800', '1000', '2000', '4000', '8000', '16000' ]), encoder.Option('max-intra-rate', ['100', '200', '400', '600', '800', '1200']), encoder.ChoiceOption(['good', 'best', 'rt']), ] self.start_encoder = encoder.Encoder( self, """ --lag-in-frames=0 \ --kf-min-dist=3000 \ --kf-max-dist=3000 --cpu-used=0 --static-thresh=0 \ --token-parts=1 --drop-frame=0 --end-usage=cbr --min-q=2 --max-q=56 \ --undershoot-pct=100 --overshoot-pct=15 --buf-sz=1000 \ --buf-initial-sz=800 --buf-optimal-sz=1000 --max-intra-rate=1200 \ --resize-allowed=0 --drop-frame=0 --passes=1 --good --noise-sensitivity=0 """ )
def __init__(self, name='vp8'): super(Vp8Codec, self).__init__(name) self.extension = 'webm' self.option_set = encoder.OptionSet( encoder.Option('overshoot-pct', ['0', '15', '30', '45']), encoder.Option('undershoot-pct', ['0', '25', '50', '75', '100']), # CQ mode is not considered for end-usage at the moment. encoder.Option('end-usage', ['cbr', 'vbr']), # End-usage cq doesn't really make sense unless we also set q to something # between min and max. This is being checked. # encoder.Option('end-usage', ['cbr', 'vbr', 'cq']), encoder.Option('end-usage', ['cbr', 'vbr']), encoder.Option('min-q', ['0', '2', '4', '8', '16', '24']), encoder.Option('max-q', ['32', '56', '63']), encoder.Option( 'buf-sz', ['200', '500', '1000', '2000', '4000', '8000', '16000']), encoder.Option( 'buf-initial-sz', ['200', '400', '800', '1000', '2000', '4000', '8000', '16000' ]), encoder.Option('max-intra-rate', ['100', '200', '400', '600', '800', '1200']), encoder.ChoiceOption(['good', 'best', 'rt']), encoder.IntegerOption('cpu-used', -16, 16), )
def test_ChangeValue(self): opts = encoder.OptionSet(encoder.ChoiceOption(['foo', 'bar'])) valueset = encoder.OptionValueSet(opts, '--foo') newset = valueset.ChangeValue('foo/bar', 'bar') self.assertEqual('--bar', newset.ToString()) # Check that old set is not modified. self.assertEqual('--foo', valueset.ToString())
def __init__(self, name='x264', formatter=None): super(X264Codec, self).__init__( name, formatter=(formatter or encoder.OptionFormatter(prefix='--', infix=' '))) self.extension = 'mkv' self.option_set = encoder.OptionSet( encoder.Option('preset', [ 'ultrafast', 'superfast', 'veryfast', 'faster', 'fast', 'medium', 'slow', 'slower', 'veryslow', 'placebo' ]), encoder.Option('rc-lookahead', ['0', '30', '60']), encoder.Option('vbv-init', ['0.5', '0.8', '0.9']), encoder.Option('ref', ['1', '2', '3', '16']), encoder.ChoiceOption(['use-vbv-maxrate']), encoder.Option('profile', ['baseline', 'main', 'high']), encoder.Option('tune', ['psnr', 'ssim']), # Experimentation on a 6-core, 12-thread system shows some gains on # large videos for thread values up to the thread count, and up to the # core count on smaller videos. # There is some damage to PSNR with more threads. encoder.IntegerOption('threads', 1, 6).Mandatory(), encoder.DummyOption('vbv-maxrate'), encoder.DummyOption('vbv-bufsize'), )
def __init__(self, name='vp9'): super(Vp9Codec, self).__init__(name) self.extension = 'webm' self.option_set = encoder.OptionSet( encoder.IntegerOption('cpu-used', 0, 16), # The "best" option gives encodes that are too slow to be useful. encoder.ChoiceOption(['good', 'rt']), )
def __init__(self, name='vp8-mpeg'): super(Vp8CodecMpegMode, self).__init__(name) # Set the parts that are different from the VP8 codec. self.option_set = encoder.OptionSet( encoder.IntegerOption('fixed-q', 0, 63).Mandatory(), encoder.IntegerOption('gold-q', 0, 63).Mandatory(), encoder.IntegerOption('key-q', 0, 63).Mandatory(), encoder.ChoiceOption(['good', 'best', 'rt']), ) # The start encoder is exactly the same as for VP8, # except that fixed-q, gold-q, alt-q and key-q parameters are set. # TODO(hta): Remove the options that have no effect in this mode. self.start_encoder_parameters = """ --lag-in-frames=0 \
def __init__(self): super(Vp8CodecCqMode, self).__init__('vp8-cq') # Set the parts that are different from the VP8 codec. self.options = [ encoder.IntegerOption('min-q', 0, 63), encoder.ChoiceOption(['good', 'best', 'rt']), ] # The start encoder is exactly the same as for VP8, # except that min-q and max-q have the same value. # TODO(hta): Remove the options that have no effect in this mode. self.start_encoder = encoder.Encoder( self, """ --lag-in-frames=0 \ --kf-min-dist=3000 \ --kf-max-dist=3000 --cpu-used=0 --static-thresh=0 \ --token-parts=1 --drop-frame=0 --end-usage=cbr --min-q=32 --max-q=32 \ --undershoot-pct=100 --overshoot-pct=15 --buf-sz=1000 \ --buf-initial-sz=800 --buf-optimal-sz=1000 --max-intra-rate=1200 \ --resize-allowed=0 --passes=1 --best --noise-sensitivity=0 """)
def __init__(self, name='x264', formatter=None): super(X264Codec, self).__init__( name, formatter=(formatter or encoder.OptionFormatter(prefix='--', infix=' '))) self.extension = 'mkv' self.option_set = encoder.OptionSet( encoder.Option('preset', [ 'ultrafast', 'superfast', 'veryfast', 'faster', 'fast', 'medium', 'slow', 'slower', 'veryslow', 'placebo' ]), encoder.Option('rc-lookahead', ['0', '30', '60']), encoder.Option('vbv-init', ['0.5', '0.8', '0.9']), encoder.Option('ref', ['1', '2', '3', '16']), encoder.ChoiceOption(['use-vbv-maxrate']), encoder.Option('profile', ['baseline', 'main', 'high']), encoder.Option('tune', ['psnr', 'ssim']), encoder.DummyOption('vbv-maxrate'), encoder.DummyOption('vbv-bufsize'), )
def test_ChoiceOption(self): option = encoder.ChoiceOption(['foo', 'bar']) # Check FlagIsValidValue function. self.assertFalse(option.FlagIsValidValue('baz')) self.assertTrue(option.FlagIsValidValue('foo'))
def test_ChangeValueOfUnknownOption(self): opts = encoder.OptionSet(encoder.ChoiceOption(['foo', 'bar'])) valueset = encoder.OptionValueSet(opts, '--foo') with self.assertRaises(encoder.Error): # pylint: disable=W0612 newset = valueset.ChangeValue('nosuchname', 'bar')
def test_FlagsSorted(self): opts = encoder.OptionSet(encoder.ChoiceOption(['foo'])) valueset = encoder.OptionValueSet(opts, '--foo --bar') self.assertEqual('--bar --foo', valueset.ToString())
def test_UnknownFlagPreserved(self): opts = encoder.OptionSet(encoder.ChoiceOption(['foo'])) valueset = encoder.OptionValueSet(opts, '--bar') self.assertEqual('--bar', valueset.ToString())
def test_ReproduceFlag(self): opts = encoder.OptionSet(encoder.ChoiceOption(['foo'])) valueset = encoder.OptionValueSet(opts, '--foo') self.assertEqual('--foo', valueset.ToString())
def test_Format(self): opts = encoder.OptionSet(encoder.ChoiceOption(['foo', 'bar'])) self.assertEquals( '--foo', opts.Format('foo/bar', 'foo', encoder.OptionFormatter()))
def test_FindFlagOption(self): opts = encoder.OptionSet(encoder.ChoiceOption(['foo', 'bar'])) self.assertIsNone(opts.FindFlagOption('baz')) self.assertEquals('foo/bar', opts.FindFlagOption('foo').name)