Skip to content

Commit 343ef4e

Browse files
author
Valentin Noel
committed
Test: add a new python test for audio channels muxing
Audio channels are extracted from different file format sources, to stereo and 5.1 output audio streams.
1 parent 2dcdc1c commit 343ef4e

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed

test/pyTest/testMuxAudioChannels.py

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import os
2+
3+
# Check if environment is setup to run the tests
4+
if os.environ.get('AVTRANSCODER_TEST_AUDIO_WAVE_FILE') is None or \
5+
os.environ.get('AVTRANSCODER_TEST_AUDIO_MOV_FILE') is None:
6+
from nose.plugins.skip import SkipTest
7+
raise SkipTest("Need to define environment variables "
8+
"AVTRANSCODER_TEST_AUDIO_WAVE_FILE and "
9+
"AVTRANSCODER_TEST_AUDIO_MOV_FILE")
10+
11+
from nose.tools import *
12+
13+
from pyAvTranscoder import avtranscoder as av
14+
15+
def testMuxAudioChannelsFromDifferentFormatInputs_20():
16+
"""
17+
Mux audio channels from different formats files, and generate one audio stereo stream
18+
"""
19+
# inputs
20+
inputFileName1 = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE']
21+
inputFileName2 = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE']
22+
assert_not_equals(inputFileName1, inputFileName2)
23+
24+
inputs = av.InputStreamDescVector()
25+
inputs.append(av.InputStreamDesc(inputFileName1, 1, 1))
26+
inputs.append(av.InputStreamDesc(inputFileName2, 0, 2))
27+
28+
# output
29+
outputFileName = "testMuxAudioChannelsFromDifferentFormatInputs_20.wav"
30+
ouputFile = av.OutputFile(outputFileName)
31+
32+
transcoder = av.Transcoder(ouputFile)
33+
transcoder.addStream(inputs, "wave24b48kstereo")
34+
35+
progress = av.ConsoleProgress()
36+
processStat = transcoder.process( progress )
37+
38+
# check process stat returned
39+
audioStat = processStat.getAudioStat(0)
40+
41+
inputFile1 = av.InputFile(inputFileName1)
42+
inputFile2 = av.InputFile(inputFileName2)
43+
44+
src_audioStream1 = inputFile1.getProperties().getAudioProperties()[0]
45+
src_audioStream2 = inputFile2.getProperties().getAudioProperties()[0]
46+
47+
min_src_duration = min(src_audioStream1.getDuration(), src_audioStream2.getDuration())
48+
49+
assert_equals(min_src_duration, audioStat.getDuration())
50+
51+
# check dst audio streams
52+
dst_inputFile = av.InputFile(outputFileName)
53+
dst_audioProperties = dst_inputFile.getProperties().getAudioProperties()
54+
assert_equals(1, len(dst_audioProperties))
55+
assert_equals(2, dst_audioProperties[0].getNbChannels())
56+
57+
def testMuxAudioChannelsFromDifferentFormatInputs_51():
58+
"""
59+
Mux audio channels from different formats files, and generate one audio stereo stream
60+
"""
61+
# inputs
62+
inputFileName1 = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE']
63+
inputFileName2 = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE']
64+
assert_not_equals(inputFileName1, inputFileName2)
65+
66+
inputs = av.InputStreamDescVector()
67+
inputs.append(av.InputStreamDesc(inputFileName1, 1, 1))
68+
inputs.append(av.InputStreamDesc(inputFileName1, 1, 0))
69+
inputs.append(av.InputStreamDesc(inputFileName2, 0, 2))
70+
inputs.append(av.InputStreamDesc(inputFileName2, 0, 5))
71+
inputs.append(av.InputStreamDesc(inputFileName2, 0, 1))
72+
inputs.append(av.InputStreamDesc(inputFileName2, 0, 3))
73+
74+
# output
75+
outputFileName = "testMuxAudioChannelsFromDifferentFormatInputs_51.wav"
76+
ouputFile = av.OutputFile(outputFileName)
77+
78+
transcoder = av.Transcoder(ouputFile)
79+
transcoder.addStream(inputs, "wave24b48k5_1")
80+
81+
progress = av.ConsoleProgress()
82+
processStat = transcoder.process( progress )
83+
84+
# check process stat returned
85+
audioStat = processStat.getAudioStat(0)
86+
87+
inputFile1 = av.InputFile(inputFileName1)
88+
inputFile2 = av.InputFile(inputFileName2)
89+
90+
src_audioStream1 = inputFile1.getProperties().getAudioProperties()[0]
91+
src_audioStream2 = inputFile2.getProperties().getAudioProperties()[0]
92+
93+
min_src_duration = min(src_audioStream1.getDuration(), src_audioStream2.getDuration())
94+
95+
assert_equals(min_src_duration, audioStat.getDuration())
96+
97+
# check dst audio streams
98+
dst_inputFile = av.InputFile(outputFileName)
99+
dst_audioProperties = dst_inputFile.getProperties().getAudioProperties()
100+
assert_equals(1, len(dst_audioProperties))
101+
assert_equals(6, dst_audioProperties[0].getNbChannels())

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy