-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathtestEProcessMethod.py
More file actions
130 lines (94 loc) · 4.49 KB
/
Copy pathtestEProcessMethod.py
File metadata and controls
130 lines (94 loc) · 4.49 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
import os
# Check if environment is setup to run the tests
if os.environ.get('AVTRANSCODER_TEST_VIDEO_FILE') is None or os.environ.get('AVTRANSCODER_TEST_AUDIO_MOV_FILE') is None or os.environ.get('AVTRANSCODER_TEST_AUDIO_WAVE_FILE') is None:
from nose.plugins.skip import SkipTest
raise SkipTest("Need to define environment variables AVTRANSCODER_TEST_VIDEO_FILE / AVTRANSCODER_TEST_AUDIO_MOV_FILE / AVTRANSCODER_TEST_AUDIO_WAVE_FILE")
from nose.tools import *
from pyAvTranscoder import avtranscoder as av
av.preloadCodecsAndFormats()
av.Logger.setLogLevel(av.AV_LOG_QUIET)
def testEProcessMethodShortest():
"""
Process with method eProcessMethodShortest, check output duration.
"""
inputFileName_longest = os.environ['AVTRANSCODER_TEST_VIDEO_FILE']
inputFileName_shortest = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE']
outputFileName = "testEProcessMethodShortest.mov"
ouputFile = av.OutputFile( outputFileName )
transcoder = av.Transcoder( ouputFile )
transcoder.setProcessMethod( av.eProcessMethodShortest )
transcoder.add( inputFileName_longest, 0, "" )
transcoder.add( inputFileName_shortest, 0, "" )
progress = av.ConsoleProgress()
transcoder.process( progress )
# get src file
src_inputFile_shortest = av.InputFile( inputFileName_shortest )
src_properties_shortest = src_inputFile_shortest.getProperties()
# get dst file
dst_inputFile = av.InputFile( outputFileName )
dst_properties = dst_inputFile.getProperties()
assert_equals( dst_properties.getDuration(), src_properties_shortest.getDuration() )
def testEProcessMethodLongest():
"""
Process with method eProcessMethodLongest, check output duration.
"""
inputFileName_longest = os.environ['AVTRANSCODER_TEST_VIDEO_FILE']
inputFileName_shortest = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE']
outputFileName = "testEProcessMethodLongest.mov"
ouputFile = av.OutputFile( outputFileName )
transcoder = av.Transcoder( ouputFile )
transcoder.setProcessMethod( av.eProcessMethodLongest )
transcoder.add( inputFileName_longest, 0, "" )
transcoder.add( inputFileName_shortest, 0, "" )
progress = av.ConsoleProgress()
transcoder.process( progress )
# get src file
src_inputFile_longest = av.InputFile( inputFileName_longest )
src_properties_longest = src_inputFile_longest.getProperties()
# get dst file
dst_inputFile = av.InputFile( outputFileName )
dst_properties = dst_inputFile.getProperties()
assert_equals( dst_properties.getDuration(), src_properties_longest.getDuration() )
def testEProcessMethodBasedOnStream():
"""
Process with method testEProcessMethodBasedOnStream, check output duration.
"""
inputFileName_first = os.environ['AVTRANSCODER_TEST_VIDEO_FILE']
inputFileName_second = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE']
inputFileName_third = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE']
outputFileName = "testEProcessMethodShortest.mov"
ouputFile = av.OutputFile( outputFileName )
transcoder = av.Transcoder( ouputFile )
transcoder.setProcessMethod( av.eProcessMethodBasedOnStream, 1 )
transcoder.add( inputFileName_first, 0, "" )
transcoder.add( inputFileName_second, 0, "" )
transcoder.add( inputFileName_third, 0, "" )
progress = av.ConsoleProgress()
transcoder.process( progress )
# get src file
src_inputFile_second = av.InputFile( inputFileName_second )
src_properties_second = src_inputFile_second.getProperties()
# get dst file
dst_inputFile = av.InputFile( outputFileName )
dst_properties = dst_inputFile.getProperties()
assert_equals( dst_properties.getDuration(), src_properties_second.getDuration() )
def testEProcessMethodBasedOnDuration():
"""
Process with method eProcessMethodBasedOnDuration, check output duration.
"""
inputFileName_first = os.environ['AVTRANSCODER_TEST_VIDEO_FILE']
inputFileName_second = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE']
inputFileName_third = os.environ['AVTRANSCODER_TEST_AUDIO_MOV_FILE']
outputFileName = "testEProcessMethodBasedOnDuration.mov"
ouputFile = av.OutputFile( outputFileName )
transcoder = av.Transcoder( ouputFile )
transcoder.setProcessMethod( av.eProcessMethodBasedOnDuration, 0, 50 )
transcoder.add( inputFileName_first, 0, "" )
transcoder.add( inputFileName_second, 0, "" )
transcoder.add( inputFileName_third, 0, "" )
progress = av.ConsoleProgress()
transcoder.process( progress )
# get dst file
dst_inputFile = av.InputFile( outputFileName )
dst_properties = dst_inputFile.getProperties()
assert_equals( dst_properties.getDuration(), 50 )