Skip to content

Commit c609ac8

Browse files
author
Valentin Noel
committed
Tests: add silent audio channels muxing tests
1 parent cc755ba commit c609ac8

File tree

1 file changed

+153
-1
lines changed

1 file changed

+153
-1
lines changed

test/pyTest/testMuxAudioChannels.py

Lines changed: 153 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def testMuxAudioChannelsFromDifferentFormatInputs_20():
6060

6161
def testMuxAudioChannelsFromDifferentFormatInputs_51():
6262
"""
63-
Mux audio channels from different formats files, and generate one audio stereo stream
63+
Mux audio channels from different formats files, and generate one audio 5.1 stream
6464
"""
6565
# inputs
6666
inputFileName1 = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE']
@@ -107,3 +107,155 @@ def testMuxAudioChannelsFromDifferentFormatInputs_51():
107107
dst_audioProperties = dst_inputFile.getProperties().getAudioProperties()
108108
assert_equals(1, len(dst_audioProperties))
109109
assert_equals(6, dst_audioProperties[0].getNbChannels())
110+
111+
112+
def testMuxAudioChannelsWithSilence_20():
113+
"""
114+
Mux audio channels with generated silence, and generate one audio stereo stream
115+
"""
116+
# input
117+
inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE']
118+
119+
inputs = av.InputStreamDescVector()
120+
inputs.append(av.InputStreamDesc(inputFileName, 0, 0))
121+
inputs.append(av.InputStreamDesc("", 0, 0)) # empty filename to generate silence
122+
123+
# output
124+
outputFileName = "testMuxAudioChannelsWithSilence_20.wav"
125+
ouputFile = av.OutputFile(outputFileName)
126+
127+
transcoder = av.Transcoder(ouputFile)
128+
transcoder.addStream(inputs, "wave24b48kstereo")
129+
130+
progress = av.ConsoleProgress()
131+
processStat = transcoder.process( progress )
132+
133+
# check process stat returned
134+
audioStat = processStat.getAudioStat(0)
135+
136+
inputFile = av.InputFile(inputFileName)
137+
138+
src_audioStream = inputFile.getProperties().getAudioProperties()[0]
139+
140+
assert_equals(src_audioStream.getDuration(), audioStat.getDuration())
141+
142+
# check dst file properties
143+
dst_inputFile = av.InputFile(outputFileName)
144+
dst_fileProperties = dst_inputFile.getProperties()
145+
assert_equals(src_audioStream.getDuration(), dst_fileProperties.getDuration())
146+
147+
# check dst audio streams
148+
dst_audioProperties = dst_fileProperties.getAudioProperties()
149+
assert_equals(1, len(dst_audioProperties))
150+
assert_equals(2, dst_audioProperties[0].getNbChannels())
151+
152+
def testMuxAudioChannelsWithSilenceProfileFromInput_20():
153+
"""
154+
Mux audio channels with generated silence, and generate one audio stereo stream
155+
"""
156+
# input
157+
inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE']
158+
159+
inputs = av.InputStreamDescVector()
160+
inputs.append(av.InputStreamDesc(inputFileName, 0, 0))
161+
inputs.append(av.InputStreamDesc("", 0, 0)) # empty filename to generate silence
162+
163+
# output
164+
outputFileName = "testMuxAudioChannelsWithSilenceNoProfile_20.wav"
165+
ouputFile = av.OutputFile(outputFileName)
166+
167+
transcoder = av.Transcoder(ouputFile)
168+
transcoder.addStream(inputs)
169+
170+
progress = av.ConsoleProgress()
171+
processStat = transcoder.process( progress )
172+
173+
# check process stat returned
174+
audioStat = processStat.getAudioStat(0)
175+
176+
inputFile = av.InputFile(inputFileName)
177+
178+
src_audioStream = inputFile.getProperties().getAudioProperties()[0]
179+
180+
assert_equals(src_audioStream.getDuration(), audioStat.getDuration())
181+
182+
# check dst file properties
183+
dst_inputFile = av.InputFile(outputFileName)
184+
dst_fileProperties = dst_inputFile.getProperties()
185+
assert_equals(src_audioStream.getDuration(), dst_fileProperties.getDuration())
186+
187+
# check dst audio streams
188+
dst_audioProperties = dst_fileProperties.getAudioProperties()
189+
assert_equals(1, len(dst_audioProperties))
190+
assert_equals(2, dst_audioProperties[0].getNbChannels())
191+
192+
def testMuxAudioChannelsWithSilenceProfileFromInput_51():
193+
"""
194+
Mux audio channels with generated silence, and generate one audio 5.1 stream
195+
"""
196+
# inputs
197+
inputFileName1 = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE']
198+
inputFileName2 = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE']
199+
assert_not_equals(inputFileName1, inputFileName2)
200+
201+
inputs = av.InputStreamDescVector()
202+
inputs.append(av.InputStreamDesc("", 0, 0)) # empty filename to generate silence
203+
inputs.append(av.InputStreamDesc(inputFileName1, 1, 0))
204+
inputs.append(av.InputStreamDesc(inputFileName2, 0, 2))
205+
inputs.append(av.InputStreamDesc("", 0, 0)) # empty filename to generate silence
206+
inputs.append(av.InputStreamDesc(inputFileName2, 0, 1))
207+
inputs.append(av.InputStreamDesc("", 0, 0)) # empty filename to generate silence
208+
209+
# output
210+
outputFileName = "testMuxAudioChannelsWithSilenceProfileFromInput_51.wav"
211+
ouputFile = av.OutputFile(outputFileName)
212+
213+
transcoder = av.Transcoder(ouputFile)
214+
transcoder.addStream(inputs)
215+
216+
progress = av.ConsoleProgress()
217+
processStat = transcoder.process( progress )
218+
219+
# check process stat returned
220+
audioStat = processStat.getAudioStat(0)
221+
222+
inputFile1 = av.InputFile(inputFileName1)
223+
inputFile2 = av.InputFile(inputFileName2)
224+
225+
src_audioStream1 = inputFile1.getProperties().getAudioProperties()[0]
226+
src_audioStream2 = inputFile2.getProperties().getAudioProperties()[0]
227+
228+
min_src_duration = min(src_audioStream1.getDuration(), src_audioStream2.getDuration())
229+
230+
assert_equals(min_src_duration, audioStat.getDuration())
231+
232+
# check dst file properties
233+
dst_inputFile = av.InputFile(outputFileName)
234+
dst_fileProperties = dst_inputFile.getProperties()
235+
assert_equals(min_src_duration, dst_fileProperties.getDuration())
236+
237+
# check dst audio streams
238+
dst_audioProperties = dst_inputFile.getProperties().getAudioProperties()
239+
assert_equals(1, len(dst_audioProperties))
240+
assert_equals(6, dst_audioProperties[0].getNbChannels())
241+
242+
@raises(RuntimeError)
243+
def testMuxAudioChannelsWithSilenceOnly_20():
244+
"""
245+
Mux audio channels with generated silence, and generate one audio stereo stream
246+
"""
247+
# input
248+
inputs = av.InputStreamDescVector()
249+
inputs.append(av.InputStreamDesc("", 0, 0)) # empty filename to generate silence
250+
inputs.append(av.InputStreamDesc("", 0, 0)) # empty filename to generate silence
251+
252+
# output
253+
outputFileName = "testMuxAudioChannelsWithSilenceOnly_20.wav"
254+
ouputFile = av.OutputFile(outputFileName)
255+
256+
transcoder = av.Transcoder(ouputFile)
257+
transcoder.addStream(inputs, "wave24b48kstereo")
258+
259+
progress = av.ConsoleProgress()
260+
processStat = transcoder.process( progress )
261+

0 commit comments

Comments
 (0)