Skip to content

Commit 736e17f

Browse files
author
Clement Champetier
committed
pyTest: added testAddSeveralInputsToCreateOneOutput
Added vector<InputStreamDesc> in the SWIG interface.
1 parent 41ca620 commit 736e17f

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

src/AvTranscoder/transcoder/transcoder.i

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
%}
66

77
%template(StreamTranscoderVector) std::vector< avtranscoder::StreamTranscoder* >;
8+
%template(InputStreamDescVector) std::vector< avtranscoder::InputStreamDesc >;
89

910
%include <AvTranscoder/transcoder/InputStreamDesc.hpp>
1011
%include <AvTranscoder/transcoder/StreamTranscoder.hpp>

test/pyTest/testTranscoderAdd.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,43 @@ def testAddAllStreamsOfFileWhichDoesNotExist():
5151

5252
# process
5353
transcoder.process()
54+
55+
56+
def testAddSeveralInputsToCreateOneOutput():
57+
"""
58+
Add several audio inputs and create one output stream.
59+
"""
60+
# inputs
61+
inputs = av.InputStreamDescVector()
62+
inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE']
63+
inputFile = av.InputFile(inputFileName)
64+
src_audioStream = inputFile.getProperties().getAudioProperties()[0]
65+
src_audioStreamIndex = src_audioStream.getStreamIndex()
66+
inputs.append(av.InputStreamDesc(inputFileName, src_audioStreamIndex, (0,1)))
67+
inputs.append(av.InputStreamDesc(inputFileName, src_audioStreamIndex, (2,3)))
68+
inputs.append(av.InputStreamDesc(inputFileName, src_audioStreamIndex, (4,5)))
69+
70+
# output
71+
outputFileName = "testAddSeveralInputsToCreateOneOutput.mov"
72+
ouputFile = av.OutputFile(outputFileName)
73+
74+
transcoder = av.Transcoder(ouputFile)
75+
transcoder.addStream(inputs, "wave24b48kstereo")
76+
77+
# process
78+
processStat = transcoder.process()
79+
80+
# check process stat returned
81+
audioStat = processStat.getAudioStat(0)
82+
assert_equals(src_audioStream.getDuration(), audioStat.getDuration())
83+
84+
# get dst file of transcode
85+
dst_inputFile = av.InputFile(outputFileName)
86+
dst_properties = dst_inputFile.getProperties()
87+
dst_audioStream = dst_properties.getAudioProperties()[0]
88+
89+
assert_equals( "pcm_s24le", dst_audioStream.getCodecName() )
90+
assert_equals( "s32", dst_audioStream.getSampleFormatName() )
91+
assert_equals( "signed 32 bits", dst_audioStream.getSampleFormatLongName() )
92+
assert_equals( 48000, dst_audioStream.getSampleRate() )
93+
assert_equals( 2, dst_audioStream.getNbChannels() )

0 commit comments

Comments
 (0)