|
| 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 | +def testMuxAudioChannelsFromDifferentFormatInputs_20(): |
| 16 | + """ |
| 17 | + Mux audio channels from different formats files, and generate one audio stereo stream |
| 18 | + """ |
| 19 | + # inputs |
| 20 | + inputFileName1 = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE'] |
| 21 | + inputFileName2 = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] |
| 22 | + assert_not_equals(inputFileName1, inputFileName2) |
| 23 | + |
| 24 | + inputs = av.InputStreamDescVector() |
| 25 | + inputs.append(av.InputStreamDesc(inputFileName1, 1, 1)) |
| 26 | + inputs.append(av.InputStreamDesc(inputFileName2, 0, 2)) |
| 27 | + |
| 28 | + # output |
| 29 | + outputFileName = "testMuxAudioChannelsFromDifferentFormatInputs_20.wav" |
| 30 | + ouputFile = av.OutputFile(outputFileName) |
| 31 | + |
| 32 | + transcoder = av.Transcoder(ouputFile) |
| 33 | + transcoder.addStream(inputs, "wave24b48kstereo") |
| 34 | + |
| 35 | + progress = av.ConsoleProgress() |
| 36 | + processStat = transcoder.process( progress ) |
| 37 | + |
| 38 | + # check process stat returned |
| 39 | + audioStat = processStat.getAudioStat(0) |
| 40 | + |
| 41 | + inputFile1 = av.InputFile(inputFileName1) |
| 42 | + inputFile2 = av.InputFile(inputFileName2) |
| 43 | + |
| 44 | + src_audioStream1 = inputFile1.getProperties().getAudioProperties()[0] |
| 45 | + src_audioStream2 = inputFile2.getProperties().getAudioProperties()[0] |
| 46 | + |
| 47 | + min_src_duration = min(src_audioStream1.getDuration(), src_audioStream2.getDuration()) |
| 48 | + |
| 49 | + assert_equals(min_src_duration, audioStat.getDuration()) |
| 50 | + |
| 51 | + # check dst audio streams |
| 52 | + dst_inputFile = av.InputFile(outputFileName) |
| 53 | + dst_audioProperties = dst_inputFile.getProperties().getAudioProperties() |
| 54 | + assert_equals(1, len(dst_audioProperties)) |
| 55 | + assert_equals(2, dst_audioProperties[0].getNbChannels()) |
| 56 | + |
| 57 | +def testMuxAudioChannelsFromDifferentFormatInputs_51(): |
| 58 | + """ |
| 59 | + Mux audio channels from different formats files, and generate one audio stereo stream |
| 60 | + """ |
| 61 | + # inputs |
| 62 | + inputFileName1 = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE'] |
| 63 | + inputFileName2 = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] |
| 64 | + assert_not_equals(inputFileName1, inputFileName2) |
| 65 | + |
| 66 | + inputs = av.InputStreamDescVector() |
| 67 | + inputs.append(av.InputStreamDesc(inputFileName1, 1, 1)) |
| 68 | + inputs.append(av.InputStreamDesc(inputFileName1, 1, 0)) |
| 69 | + inputs.append(av.InputStreamDesc(inputFileName2, 0, 2)) |
| 70 | + inputs.append(av.InputStreamDesc(inputFileName2, 0, 5)) |
| 71 | + inputs.append(av.InputStreamDesc(inputFileName2, 0, 1)) |
| 72 | + inputs.append(av.InputStreamDesc(inputFileName2, 0, 3)) |
| 73 | + |
| 74 | + # output |
| 75 | + outputFileName = "testMuxAudioChannelsFromDifferentFormatInputs_51.wav" |
| 76 | + ouputFile = av.OutputFile(outputFileName) |
| 77 | + |
| 78 | + transcoder = av.Transcoder(ouputFile) |
| 79 | + transcoder.addStream(inputs, "wave24b48k5_1") |
| 80 | + |
| 81 | + progress = av.ConsoleProgress() |
| 82 | + processStat = transcoder.process( progress ) |
| 83 | + |
| 84 | + # check process stat returned |
| 85 | + audioStat = processStat.getAudioStat(0) |
| 86 | + |
| 87 | + inputFile1 = av.InputFile(inputFileName1) |
| 88 | + inputFile2 = av.InputFile(inputFileName2) |
| 89 | + |
| 90 | + src_audioStream1 = inputFile1.getProperties().getAudioProperties()[0] |
| 91 | + src_audioStream2 = inputFile2.getProperties().getAudioProperties()[0] |
| 92 | + |
| 93 | + min_src_duration = min(src_audioStream1.getDuration(), src_audioStream2.getDuration()) |
| 94 | + |
| 95 | + assert_equals(min_src_duration, audioStat.getDuration()) |
| 96 | + |
| 97 | + # check dst audio streams |
| 98 | + dst_inputFile = av.InputFile(outputFileName) |
| 99 | + dst_audioProperties = dst_inputFile.getProperties().getAudioProperties() |
| 100 | + assert_equals(1, len(dst_audioProperties)) |
| 101 | + assert_equals(6, dst_audioProperties[0].getNbChannels()) |
0 commit comments