Skip to content

Commit 5d4888f

Browse files
author
Clement Champetier
committed
pyTest: add a test to extract one audio channel from a stream of one channel
1 parent da013d4 commit 5d4888f

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

test/pyTest/testTranscoderTranscodeAudioWave.py

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,51 @@
11
import os
22

33
# 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:
56
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")
710

811
from nose.tools import *
912

1013
from pyAvTranscoder import avtranscoder as av
1114

1215

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+
1349
def testTranscodeWave24b48k5_1():
1450
"""
1551
Transcode one audio stream (profile wave24b48k5_1).

tools/appveyor/python.nosetests.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ set AVTRANSCODER_TEST_VIDEO_AVI_FILE=%PWD%\avTranscoder-data/video\BigBuckBunny\
1515
set AVTRANSCODER_TEST_VIDEO_MP4_FILE=%PWD%\avTranscoder-data\video\BigBuckBunny\BigBuckBunny_HD.mp4
1616
set AVTRANSCODER_TEST_VIDEO_MOV_FILE=%PWD%\avTranscoder-data\video\BigBuckBunny\BigBuckBunny_640p_h264.mov
1717
set AVTRANSCODER_TEST_AUDIO_WAVE_FILE=%PWD%\avTranscoder-data\audio\frequenciesPerChannel.wav
18+
set AVTRANSCODER_TEST_AUDIO_WAVE_MONO_FILE=%PWD%\avTranscoder-data\audio\frequenciesOneChannel.wav
1819
set AVTRANSCODER_TEST_AUDIO_MOV_FILE=%PWD%\avTranscoder-data\video\BigBuckBunny\BigBuckBunny_1080p_5_1.mov
1920
set AVTRANSCODER_TEST_IMAGE_PNG_FILE=%PWD%\avTranscoder-data\image\BigBuckBunny\bbb-splash.thumbnail.png
2021
set AVTRANSCODER_TEST_IMAGE_JPG_FILE=%PWD%\avTranscoder-data\image\BigBuckBunny\title_anouncement.thumbnail.jpg

tools/travis/python.nosetests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export AVTRANSCODER_TEST_VIDEO_MP4_FILE=`pwd`/avTranscoder-data/video/BigBuckBun
1414
export AVTRANSCODER_TEST_VIDEO_MOV_FILE=`pwd`/avTranscoder-data/video/BigBuckBunny/BigBuckBunny_640p_h264.mov
1515
export AVTRANSCODER_TEST_VIDEO_RAW_FILE=`pwd`/avTranscoder-data/video/Intro/Intro_raw_1080p.h264
1616
export AVTRANSCODER_TEST_AUDIO_WAVE_FILE=`pwd`/avTranscoder-data/audio/frequenciesPerChannel.wav
17+
export AVTRANSCODER_TEST_AUDIO_WAVE_MONO_FILE=`pwd`/avTranscoder-data/audio/frequenciesOneChannel.wav
1718
export AVTRANSCODER_TEST_AUDIO_MOV_FILE=`pwd`/avTranscoder-data/video/BigBuckBunny/BigBuckBunny_1080p_5_1.mov
1819
export AVTRANSCODER_TEST_IMAGE_PNG_FILE=`pwd`/avTranscoder-data/image/BigBuckBunny/bbb-splash.thumbnail.png
1920
export AVTRANSCODER_TEST_IMAGE_JPG_FILE=`pwd`/avTranscoder-data/image/BigBuckBunny/title_anouncement.thumbnail.jpg

0 commit comments

Comments
 (0)