|
1 | 1 | import os
|
2 | 2 |
|
3 | 3 | # Check if environment is setup to run the tests
|
4 |
| -if os.environ.get('AVTRANSCODER_TEST_AUDIO_WAVE_FILE') is None: |
| 4 | +if os.environ.get('AVTRANSCODER_TEST_AUDIO_WAVE_FILE') is None or \ |
| 5 | + os.environ.get('AVTRANSCODER_TEST_AUDIO_WAVE_MONO_FILE') is None: |
5 | 6 | from nose.plugins.skip import SkipTest
|
6 |
| - raise SkipTest("Need to define environment variable AVTRANSCODER_TEST_AUDIO_WAVE_FILE") |
| 7 | + raise SkipTest("Need to define environment variables " |
| 8 | + "AVTRANSCODER_TEST_AUDIO_WAVE_FILE and" |
| 9 | + "AVTRANSCODER_TEST_AUDIO_WAVE_MONO_FILE") |
7 | 10 |
|
8 | 11 | from nose.tools import *
|
9 | 12 |
|
10 | 13 | from pyAvTranscoder import avtranscoder as av
|
11 | 14 |
|
12 | 15 |
|
| 16 | +def testTranscodeExtractOneChannelFromMono(): |
| 17 | + """ |
| 18 | + Extract one audio channel from a stream of one channel. |
| 19 | + """ |
| 20 | + inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_MONO_FILE'] |
| 21 | + outputFileName = "testTranscodeExtractOneChannelFromMono.wav" |
| 22 | + |
| 23 | + ouputFile = av.OutputFile(outputFileName) |
| 24 | + transcoder = av.Transcoder(ouputFile) |
| 25 | + |
| 26 | + inputFile = av.InputFile(inputFileName) |
| 27 | + src_audioStream = inputFile.getProperties().getAudioProperties()[0] |
| 28 | + audioStreamIndex = src_audioStream.getStreamIndex() |
| 29 | + transcoder.addStream(av.InputStreamDesc(inputFileName, audioStreamIndex, 0)) |
| 30 | + |
| 31 | + processStat = transcoder.process() |
| 32 | + |
| 33 | + # check process stat returned |
| 34 | + audioStat = processStat.getAudioStat(0) |
| 35 | + assert_equals(src_audioStream.getDuration(), audioStat.getDuration()) |
| 36 | + |
| 37 | + # get dst file of transcode |
| 38 | + dst_inputFile = av.InputFile(outputFileName) |
| 39 | + dst_properties = dst_inputFile.getProperties() |
| 40 | + dst_audioStream = dst_properties.getAudioProperties()[0] |
| 41 | + |
| 42 | + assert_equals(dst_audioStream.getCodecName(), src_audioStream.getCodecName()) |
| 43 | + assert_equals(dst_audioStream.getSampleFormatName(), src_audioStream.getSampleFormatName()) |
| 44 | + assert_equals(dst_audioStream.getSampleFormatLongName(), src_audioStream.getSampleFormatLongName()) |
| 45 | + assert_equals(dst_audioStream.getSampleRate(), src_audioStream.getSampleRate()) |
| 46 | + assert_equals(dst_audioStream.getNbChannels(), 1) |
| 47 | + |
| 48 | + |
13 | 49 | def testTranscodeWave24b48k5_1():
|
14 | 50 | """
|
15 | 51 | Transcode one audio stream (profile wave24b48k5_1).
|
|
0 commit comments