|
| 1 | +import os |
| 2 | + |
| 3 | +# Check if environment is setup to run the tests |
| 4 | +if os.environ.get('AVTRANSCODER_TEST_AUDIO_WAVE_FILE') is None or \ |
| 5 | + os.environ.get('AVTRANSCODER_TEST_AUDIO_MOV_FILE') is None: |
| 6 | + from nose.plugins.skip import SkipTest |
| 7 | + raise SkipTest("Need to define environment variables " |
| 8 | + "AVTRANSCODER_TEST_AUDIO_WAVE_FILE and " |
| 9 | + "AVTRANSCODER_TEST_AUDIO_MOV_FILE") |
| 10 | + |
| 11 | +from nose.tools import * |
| 12 | + |
| 13 | +from pyAvTranscoder import avtranscoder as av |
| 14 | + |
| 15 | + |
| 16 | +@raises(IndexError) |
| 17 | +def testAccessOfUnknownAudioCodecOptions(): |
| 18 | + """ |
| 19 | + Check access to an unknown codec option. |
| 20 | + """ |
| 21 | + optionName = 'a' |
| 22 | + inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] |
| 23 | + inputFile = av.InputFile(inputFileName) |
| 24 | + audioProperties = inputFile.getProperties().getAudioProperties()[0] |
| 25 | + |
| 26 | + audioProperties.getCodecOption(optionName) |
| 27 | + |
| 28 | + |
| 29 | +def testAccessOfKnownCodecOptionInAudioStream(): |
| 30 | + """ |
| 31 | + Check access to a known codec option from an audio stream. |
| 32 | + """ |
| 33 | + optionName = 'b' |
| 34 | + inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] |
| 35 | + inputFile = av.InputFile(inputFileName) |
| 36 | + audioProperties = inputFile.getProperties().getAudioProperties()[0] |
| 37 | + |
| 38 | + option = audioProperties.getCodecOption(optionName) |
| 39 | + |
| 40 | + # common attributes |
| 41 | + assert_equals(option.getName(), optionName) |
| 42 | + assert_equals(option.getHelp(), 'set bitrate (in bits/s)') |
| 43 | + assert_equals(option.getType(), av.eOptionBaseTypeInt) |
| 44 | + assert_greater(option.getOffset(), 0) |
| 45 | + assert_equals(option.getMin(), 0.0) |
| 46 | + assert_greater(option.getMax(), 0.0) |
| 47 | + assert_greater(option.getMax(), 0.0) |
| 48 | + |
| 49 | + # flags |
| 50 | + assert_equals(option.isEncodingOpt(), True) |
| 51 | + assert_equals(option.isDecodingOpt(), False) |
| 52 | + assert_equals(option.isAudioOpt(), True) |
| 53 | + assert_equals(option.isVideoOpt(), True) |
| 54 | + assert_equals(option.isSubtitleOpt(), False) |
| 55 | + |
| 56 | + # value |
| 57 | + assert_equals(option.getInt(), audioProperties.getBitRate()) |
| 58 | + assert_equals(option.getDefaultInt(), 200000) # see AV_CODEC_DEFAULT_BITRATE |
| 59 | + |
| 60 | + # childs |
| 61 | + assert_equals(option.hasChild(), False) |
| 62 | + assert_equals(len(option.getChilds()), 0) |
| 63 | + |
| 64 | + |
| 65 | +def testAccessOfKnownCodecOptionInVideoStream(): |
| 66 | + """ |
| 67 | + Check access to a known codec option from a video stream. |
| 68 | + """ |
| 69 | + optionName = 'flags' |
| 70 | + inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE'] |
| 71 | + inputFile = av.InputFile(inputFileName) |
| 72 | + videoProperties = inputFile.getProperties().getVideoProperties()[0] |
| 73 | + |
| 74 | + option = videoProperties.getCodecOption(optionName) |
| 75 | + |
| 76 | + # common attributes |
| 77 | + assert_equals(option.getName(), optionName) |
| 78 | + assert_equals(option.getUnit(), optionName) |
| 79 | + assert_equals(option.getType(), av.eOptionBaseTypeGroup) |
| 80 | + |
| 81 | + # flags |
| 82 | + assert_equals(option.isEncodingOpt(), True) |
| 83 | + assert_equals(option.isDecodingOpt(), True) |
| 84 | + assert_equals(option.isAudioOpt(), True) |
| 85 | + assert_equals(option.isVideoOpt(), True) |
| 86 | + assert_equals(option.isSubtitleOpt(), True) |
| 87 | + |
| 88 | + # value |
| 89 | + assert_equals(option.getInt(), 0) |
| 90 | + assert_equals(option.getDefaultInt(), 0) |
| 91 | + |
| 92 | + # childs |
| 93 | + assert_equals(option.hasChild(), True) |
| 94 | + assert_greater(len(option.getChilds()), 0) |
| 95 | + # check if all the childs have a name |
| 96 | + for child in option.getChilds(): |
| 97 | + assert_greater(len(child.getName()), 0) |
0 commit comments