forked from avTranscoder/avTranscoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestMuxAudioChannels.py
More file actions
261 lines (194 loc) · 9.5 KB
/
Copy pathtestMuxAudioChannels.py
File metadata and controls
261 lines (194 loc) · 9.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
import os
# Check if environment is setup to run the tests
if os.environ.get('AVTRANSCODER_TEST_AUDIO_WAVE_FILE') is None or \
os.environ.get('AVTRANSCODER_TEST_AUDIO_MOV_FILE') is None:
from nose.plugins.skip import SkipTest
raise SkipTest("Need to define environment variables "
"AVTRANSCODER_TEST_AUDIO_WAVE_FILE and "
"AVTRANSCODER_TEST_AUDIO_MOV_FILE")
from nose.tools import *
from pyAvTranscoder import avtranscoder as av
def testMuxAudioChannelsFromDifferentFormatInputs_20():
"""
Mux audio channels from different formats files, and generate one audio stereo stream
"""
# inputs
inputFileName1 = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE']
inputFileName2 = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE']
assert_not_equals(inputFileName1, inputFileName2)
inputs = av.InputStreamDescVector()
inputs.append(av.InputStreamDesc(inputFileName1, 1, 1))
inputs.append(av.InputStreamDesc(inputFileName2, 0, 2))
# output
outputFileName = "testMuxAudioChannelsFromDifferentFormatInputs_20.wav"
ouputFile = av.OutputFile(outputFileName)
transcoder = av.Transcoder(ouputFile)
transcoder.addStream(inputs, "wave24b48kstereo")
progress = av.ConsoleProgress()
processStat = transcoder.process( progress )
# check process stat returned
audioStat = processStat.getAudioStat(0)
inputFile1 = av.InputFile(inputFileName1)
inputFile2 = av.InputFile(inputFileName2)
src_audioStream1 = inputFile1.getProperties().getAudioProperties()[0]
src_audioStream2 = inputFile2.getProperties().getAudioProperties()[0]
min_src_duration = min(src_audioStream1.getDuration(), src_audioStream2.getDuration())
assert_equals(min_src_duration, audioStat.getDuration())
# check dst file properties
dst_inputFile = av.InputFile(outputFileName)
dst_fileProperties = dst_inputFile.getProperties()
assert_equals(min_src_duration, dst_fileProperties.getDuration())
# check dst audio streams
dst_audioProperties = dst_fileProperties.getAudioProperties()
assert_equals(1, len(dst_audioProperties))
assert_equals(2, dst_audioProperties[0].getNbChannels())
def testMuxAudioChannelsFromDifferentFormatInputs_51():
"""
Mux audio channels from different formats files, and generate one audio 5.1 stream
"""
# inputs
inputFileName1 = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE']
inputFileName2 = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE']
assert_not_equals(inputFileName1, inputFileName2)
inputs = av.InputStreamDescVector()
inputs.append(av.InputStreamDesc(inputFileName1, 1, 1))
inputs.append(av.InputStreamDesc(inputFileName1, 1, 0))
inputs.append(av.InputStreamDesc(inputFileName2, 0, 2))
inputs.append(av.InputStreamDesc(inputFileName2, 0, 5))
inputs.append(av.InputStreamDesc(inputFileName2, 0, 1))
inputs.append(av.InputStreamDesc(inputFileName2, 0, 3))
# output
outputFileName = "testMuxAudioChannelsFromDifferentFormatInputs_51.wav"
ouputFile = av.OutputFile(outputFileName)
transcoder = av.Transcoder(ouputFile)
transcoder.addStream(inputs, "wave24b48k5_1")
progress = av.ConsoleProgress()
processStat = transcoder.process( progress )
# check process stat returned
audioStat = processStat.getAudioStat(0)
inputFile1 = av.InputFile(inputFileName1)
inputFile2 = av.InputFile(inputFileName2)
src_audioStream1 = inputFile1.getProperties().getAudioProperties()[0]
src_audioStream2 = inputFile2.getProperties().getAudioProperties()[0]
min_src_duration = min(src_audioStream1.getDuration(), src_audioStream2.getDuration())
assert_equals(min_src_duration, audioStat.getDuration())
# check dst file properties
dst_inputFile = av.InputFile(outputFileName)
dst_fileProperties = dst_inputFile.getProperties()
assert_equals(min_src_duration, dst_fileProperties.getDuration())
# check dst audio streams
dst_audioProperties = dst_inputFile.getProperties().getAudioProperties()
assert_equals(1, len(dst_audioProperties))
assert_equals(6, dst_audioProperties[0].getNbChannels())
def testMuxAudioChannelsWithSilence_20():
"""
Mux audio channels with generated silence, and generate one audio stereo stream
"""
# input
inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE']
inputs = av.InputStreamDescVector()
inputs.append(av.InputStreamDesc(inputFileName, 0, 0))
inputs.append(av.InputStreamDesc("", 0, 0)) # empty filename to generate silence
# output
outputFileName = "testMuxAudioChannelsWithSilence_20.wav"
ouputFile = av.OutputFile(outputFileName)
transcoder = av.Transcoder(ouputFile)
transcoder.addStream(inputs, "wave24b48kstereo")
progress = av.ConsoleProgress()
processStat = transcoder.process( progress )
# check process stat returned
audioStat = processStat.getAudioStat(0)
inputFile = av.InputFile(inputFileName)
src_audioStream = inputFile.getProperties().getAudioProperties()[0]
assert_equals(src_audioStream.getDuration(), audioStat.getDuration())
# check dst file properties
dst_inputFile = av.InputFile(outputFileName)
dst_fileProperties = dst_inputFile.getProperties()
assert_equals(src_audioStream.getDuration(), dst_fileProperties.getDuration())
# check dst audio streams
dst_audioProperties = dst_fileProperties.getAudioProperties()
assert_equals(1, len(dst_audioProperties))
assert_equals(2, dst_audioProperties[0].getNbChannels())
def testMuxAudioChannelsWithSilenceProfileFromInput_20():
"""
Mux audio channels with generated silence, and generate one audio stereo stream
"""
# input
inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE']
inputs = av.InputStreamDescVector()
inputs.append(av.InputStreamDesc(inputFileName, 0, 0))
inputs.append(av.InputStreamDesc("", 0, 0)) # empty filename to generate silence
# output
outputFileName = "testMuxAudioChannelsWithSilenceNoProfile_20.wav"
ouputFile = av.OutputFile(outputFileName)
transcoder = av.Transcoder(ouputFile)
transcoder.addStream(inputs)
progress = av.ConsoleProgress()
processStat = transcoder.process( progress )
# check process stat returned
audioStat = processStat.getAudioStat(0)
inputFile = av.InputFile(inputFileName)
src_audioStream = inputFile.getProperties().getAudioProperties()[0]
assert_equals(src_audioStream.getDuration(), audioStat.getDuration())
# check dst file properties
dst_inputFile = av.InputFile(outputFileName)
dst_fileProperties = dst_inputFile.getProperties()
assert_equals(src_audioStream.getDuration(), dst_fileProperties.getDuration())
# check dst audio streams
dst_audioProperties = dst_fileProperties.getAudioProperties()
assert_equals(1, len(dst_audioProperties))
assert_equals(2, dst_audioProperties[0].getNbChannels())
def testMuxAudioChannelsWithSilenceProfileFromInput_51():
"""
Mux audio channels with generated silence, and generate one audio 5.1 stream
"""
# inputs
inputFileName1 = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE']
inputFileName2 = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE']
assert_not_equals(inputFileName1, inputFileName2)
inputs = av.InputStreamDescVector()
inputs.append(av.InputStreamDesc("", 0, 0)) # empty filename to generate silence
inputs.append(av.InputStreamDesc(inputFileName1, 1, 0))
inputs.append(av.InputStreamDesc(inputFileName2, 0, 2))
inputs.append(av.InputStreamDesc("", 0, 0)) # empty filename to generate silence
inputs.append(av.InputStreamDesc(inputFileName2, 0, 1))
inputs.append(av.InputStreamDesc("", 0, 0)) # empty filename to generate silence
# output
outputFileName = "testMuxAudioChannelsWithSilenceProfileFromInput_51.wav"
ouputFile = av.OutputFile(outputFileName)
transcoder = av.Transcoder(ouputFile)
transcoder.addStream(inputs)
progress = av.ConsoleProgress()
processStat = transcoder.process( progress )
# check process stat returned
audioStat = processStat.getAudioStat(0)
inputFile1 = av.InputFile(inputFileName1)
inputFile2 = av.InputFile(inputFileName2)
src_audioStream1 = inputFile1.getProperties().getAudioProperties()[0]
src_audioStream2 = inputFile2.getProperties().getAudioProperties()[0]
min_src_duration = min(src_audioStream1.getDuration(), src_audioStream2.getDuration())
assert_equals(min_src_duration, audioStat.getDuration())
# check dst file properties
dst_inputFile = av.InputFile(outputFileName)
dst_fileProperties = dst_inputFile.getProperties()
assert_equals(min_src_duration, dst_fileProperties.getDuration())
# check dst audio streams
dst_audioProperties = dst_inputFile.getProperties().getAudioProperties()
assert_equals(1, len(dst_audioProperties))
assert_equals(6, dst_audioProperties[0].getNbChannels())
@raises(RuntimeError)
def testMuxAudioChannelsWithSilenceOnly_20():
"""
Mux audio channels with generated silence, and generate one audio stereo stream
"""
# input
inputs = av.InputStreamDescVector()
inputs.append(av.InputStreamDesc("", 0, 0)) # empty filename to generate silence
inputs.append(av.InputStreamDesc("", 0, 0)) # empty filename to generate silence
# output
outputFileName = "testMuxAudioChannelsWithSilenceOnly_20.wav"
ouputFile = av.OutputFile(outputFileName)
transcoder = av.Transcoder(ouputFile)
transcoder.addStream(inputs, "wave24b48kstereo")
progress = av.ConsoleProgress()
processStat = transcoder.process( progress )