-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathtestNbSamples.py
More file actions
72 lines (53 loc) · 2.46 KB
/
Copy pathtestNbSamples.py
File metadata and controls
72 lines (53 loc) · 2.46 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
import os
# Check if environment is setup to run the tests
if os.environ.get('AVTRANSCODER_TEST_AUDIO_WAVE_FILE') is None:
from nose.plugins.skip import SkipTest
raise SkipTest("Need to define environment variable AVTRANSCODER_TEST_AUDIO_WAVE_FILE")
from nose.tools import *
from pyAvTranscoder import avtranscoder as av
def testNbSamplesAudioRewrap():
"""
Rewrap one audio stream, check nb samples.
"""
inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE']
outputFileName = "testNbSamplesAudioRewrap.wav"
ouputFile = av.OutputFile( outputFileName )
transcoder = av.Transcoder( ouputFile )
transcoder.addStream( av.InputStreamDesc(inputFileName) )
progress = av.ConsoleProgress()
transcoder.process( progress )
# get src file of rewrap
src_inputFile = av.InputFile( inputFileName )
src_properties = src_inputFile.getProperties()
src_audioStream = src_properties.getAudioProperties()[0]
# get dst file of rewrap
dst_inputFile = av.InputFile( outputFileName )
dst_properties = dst_inputFile.getProperties()
dst_audioStream = dst_properties.getAudioProperties()[0]
assert_equals( src_audioStream.getNbSamples(), dst_audioStream.getNbSamples() )
def testNbSamplesAudioTranscode():
"""
Transcode one audio stream (to wave24b48kmono), check nb samples.
"""
inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE']
outputFileName = "testNbSamplesAudioTranscode.wav"
ouputFile = av.OutputFile( outputFileName )
transcoder = av.Transcoder( ouputFile )
# create custom profile
customProfile = av.ProfileMap()
customProfile[av.avProfileIdentificator] = "customProfile"
customProfile[av.avProfileIdentificatorHuman] = "custom profile"
customProfile[av.avProfileType] = av.avProfileTypeAudio
customProfile[av.avProfileCodec] = "pcm_s16le"
transcoder.addStream( av.InputStreamDesc(inputFileName), customProfile )
progress = av.ConsoleProgress()
transcoder.process( progress )
# get src file of transcode
src_inputFile = av.InputFile( inputFileName )
src_properties = src_inputFile.getProperties()
src_audioStream = src_properties.getAudioProperties()[0]
# get dst file of transcode
dst_inputFile = av.InputFile( outputFileName )
dst_properties = dst_inputFile.getProperties()
dst_audioStream = dst_properties.getAudioProperties()[0]
assert_equals( src_audioStream.getNbSamples(), dst_audioStream.getNbSamples() )