Skip to content

Commit 0dd7e49

Browse files
author
Clement Champetier
committed
pyTest: updated transcode tests by checking process stats returned
1 parent 77f311e commit 0dd7e49

File tree

3 files changed

+83
-27
lines changed

3 files changed

+83
-27
lines changed

test/pyTest/testTranscoderTranscodeAudioMov.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,16 @@ def testTranscodeMovVariableNbSamplesPerFrame():
3030
customProfile[av.avProfileCodec] = "pcm_s24le"
3131

3232
inputFile = av.InputFile( inputFileName )
33-
audioStreamIndex = inputFile.getProperties().getAudioProperties()[0].getStreamIndex()
33+
src_audioStream = inputFile.getProperties().getAudioProperties()[0]
34+
audioStreamIndex = src_audioStream.getStreamIndex()
3435
transcoder.add( inputFileName, audioStreamIndex, customProfile )
3536

3637
progress = av.ConsoleProgress()
37-
transcoder.process( progress )
38+
processStat = transcoder.process( progress )
39+
40+
# check process stat returned
41+
audioStat = processStat.getAudioStat(0)
42+
assert_equals(src_audioStream.getDuration(), audioStat.getDuration())
3843

3944
# get dst file of transcode
4045
dst_inputFile = av.InputFile( outputFileName )
@@ -44,4 +49,3 @@ def testTranscodeMovVariableNbSamplesPerFrame():
4449

4550
assert_equals( "pcm_s24le", dst_audioStream.getCodecName() )
4651
assert_equals( "PCM signed 24-bit little-endian", dst_audioStream.getCodecLongName() )
47-

test/pyTest/testTranscoderTranscodeAudioWave.py

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,20 @@ def testTranscodeWave24b48k5_1():
2020
ouputFile = av.OutputFile( outputFileName )
2121
transcoder = av.Transcoder( ouputFile )
2222

23-
transcoder.add( inputFileName, 0, "wave24b48k5_1" )
23+
inputFile = av.InputFile( inputFileName )
24+
src_audioStream = inputFile.getProperties().getAudioProperties()[0]
25+
audioStreamIndex = src_audioStream.getStreamIndex()
26+
transcoder.add( inputFileName, audioStreamIndex, "wave24b48k5_1" )
2427

2528
progress = av.ConsoleProgress()
26-
transcoder.process( progress )
29+
processStat = transcoder.process( progress )
30+
31+
# check process stat returned
32+
audioStat = processStat.getAudioStat(0)
33+
assert_equals(src_audioStream.getDuration(), audioStat.getDuration())
2734

2835
# get dst file of transcode
2936
dst_inputFile = av.InputFile( outputFileName )
30-
dst_inputFile.analyse( progress, av.eAnalyseLevelHeader )
3137
dst_properties = dst_inputFile.getProperties()
3238
dst_audioStream = dst_properties.getAudioProperties()[0]
3339

@@ -48,14 +54,20 @@ def testTranscodeWave24b48kstereo():
4854
ouputFile = av.OutputFile( outputFileName )
4955
transcoder = av.Transcoder( ouputFile )
5056

51-
transcoder.add( inputFileName, 0, "wave24b48kstereo" )
57+
inputFile = av.InputFile( inputFileName )
58+
src_audioStream = inputFile.getProperties().getAudioProperties()[0]
59+
audioStreamIndex = src_audioStream.getStreamIndex()
60+
transcoder.add( inputFileName, audioStreamIndex, "wave24b48kstereo" )
5261

5362
progress = av.ConsoleProgress()
54-
transcoder.process( progress )
63+
processStat = transcoder.process( progress )
64+
65+
# check process stat returned
66+
audioStat = processStat.getAudioStat(0)
67+
assert_equals(src_audioStream.getDuration(), audioStat.getDuration())
5568

5669
# get dst file of transcode
5770
dst_inputFile = av.InputFile( outputFileName )
58-
dst_inputFile.analyse( progress, av.eAnalyseLevelHeader )
5971
dst_properties = dst_inputFile.getProperties()
6072
dst_audioStream = dst_properties.getAudioProperties()[0]
6173

@@ -76,14 +88,20 @@ def testTranscodeWave24b48kmono():
7688
ouputFile = av.OutputFile( outputFileName )
7789
transcoder = av.Transcoder( ouputFile )
7890

79-
transcoder.add( inputFileName, 0, "wave24b48kmono" )
91+
inputFile = av.InputFile( inputFileName )
92+
src_audioStream = inputFile.getProperties().getAudioProperties()[0]
93+
audioStreamIndex = src_audioStream.getStreamIndex()
94+
transcoder.add( inputFileName, audioStreamIndex, "wave24b48kmono" )
8095

8196
progress = av.ConsoleProgress()
82-
transcoder.process( progress )
97+
processStat = transcoder.process( progress )
98+
99+
# check process stat returned
100+
audioStat = processStat.getAudioStat(0)
101+
assert_equals(src_audioStream.getDuration(), audioStat.getDuration())
83102

84103
# get dst file of transcode
85104
dst_inputFile = av.InputFile( outputFileName )
86-
dst_inputFile.analyse( progress, av.eAnalyseLevelHeader )
87105
dst_properties = dst_inputFile.getProperties()
88106
dst_audioStream = dst_properties.getAudioProperties()[0]
89107

@@ -104,14 +122,20 @@ def testTranscodeWave16b48kmono():
104122
ouputFile = av.OutputFile( outputFileName )
105123
transcoder = av.Transcoder( ouputFile )
106124

107-
transcoder.add( inputFileName, 0, "wave16b48kmono" )
125+
inputFile = av.InputFile( inputFileName )
126+
src_audioStream = inputFile.getProperties().getAudioProperties()[0]
127+
audioStreamIndex = src_audioStream.getStreamIndex()
128+
transcoder.add( inputFileName, audioStreamIndex, "wave16b48kmono" )
108129

109130
progress = av.ConsoleProgress()
110-
transcoder.process( progress )
131+
processStat = transcoder.process( progress )
132+
133+
# check process stat returned
134+
audioStat = processStat.getAudioStat(0)
135+
assert_equals(src_audioStream.getDuration(), audioStat.getDuration())
111136

112137
# get dst file of transcode
113138
dst_inputFile = av.InputFile( outputFileName )
114-
dst_inputFile.analyse( progress, av.eAnalyseLevelHeader )
115139
dst_properties = dst_inputFile.getProperties()
116140
dst_audioStream = dst_properties.getAudioProperties()[0]
117141

test/pyTest/testTranscoderTranscodeVideo.py

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,21 @@ def testTranscodeDnxhd120():
2020
ouputFile = av.OutputFile( outputFileName )
2121
transcoder = av.Transcoder( ouputFile )
2222

23-
transcoder.add( inputFileName, 0, "dnxhd120" )
23+
inputFile = av.InputFile( inputFileName )
24+
src_videoStream = inputFile.getProperties().getVideoProperties()[0]
25+
videoStreamIndex = src_videoStream.getStreamIndex()
26+
transcoder.add( inputFileName, videoStreamIndex, "dnxhd120" )
2427

2528
progress = av.ConsoleProgress()
26-
transcoder.process( progress )
29+
processStat = transcoder.process( progress )
30+
31+
# check process stat returned
32+
videoStat = processStat.getVideoStat(0)
33+
# do not test duration because the profile "dnxhd120" forces the fps to 25
34+
assert_equals(int(src_videoStream.getDuration() * src_videoStream.getFps()), videoStat.getNbFrames())
2735

2836
# get dst file of transcode
2937
dst_inputFile = av.InputFile( outputFileName )
30-
dst_inputFile.analyse( progress, av.eAnalyseLevelFirstGop )
3138
dst_properties = dst_inputFile.getProperties()
3239
dst_videoStream = dst_properties.getVideoProperties()[0]
3340

@@ -49,14 +56,21 @@ def testTranscodeDnxhd185():
4956
ouputFile = av.OutputFile( outputFileName )
5057
transcoder = av.Transcoder( ouputFile )
5158

52-
transcoder.add( inputFileName, 0, "dnxhd185" )
59+
inputFile = av.InputFile( inputFileName )
60+
src_videoStream = inputFile.getProperties().getVideoProperties()[0]
61+
videoStreamIndex = src_videoStream.getStreamIndex()
62+
transcoder.add( inputFileName, videoStreamIndex, "dnxhd185" )
5363

5464
progress = av.ConsoleProgress()
55-
transcoder.process( progress )
65+
processStat = transcoder.process( progress )
66+
67+
# check process stat returned
68+
videoStat = processStat.getVideoStat(0)
69+
# do not test duration because the profile "dnxhd185" forces the fps to 25
70+
assert_equals(int(src_videoStream.getDuration() * src_videoStream.getFps()), videoStat.getNbFrames())
5671

5772
# get dst file of transcode
5873
dst_inputFile = av.InputFile( outputFileName )
59-
dst_inputFile.analyse( progress, av.eAnalyseLevelHeader )
6074
dst_properties = dst_inputFile.getProperties()
6175
dst_videoStream = dst_properties.getVideoProperties()[0]
6276

@@ -78,14 +92,21 @@ def testTranscodeDnxhd185x():
7892
ouputFile = av.OutputFile( outputFileName )
7993
transcoder = av.Transcoder( ouputFile )
8094

81-
transcoder.add( inputFileName, 0, "dnxhd185x" )
95+
inputFile = av.InputFile( inputFileName )
96+
src_videoStream = inputFile.getProperties().getVideoProperties()[0]
97+
videoStreamIndex = src_videoStream.getStreamIndex()
98+
transcoder.add( inputFileName, videoStreamIndex, "dnxhd185x" )
8299

83100
progress = av.ConsoleProgress()
84-
transcoder.process( progress )
101+
processStat = transcoder.process( progress )
102+
103+
# check process stat returned
104+
videoStat = processStat.getVideoStat(0)
105+
# do not test duration because the profile "dnxhd185x" forces the fps to 25
106+
assert_equals(int(src_videoStream.getDuration() * src_videoStream.getFps()), videoStat.getNbFrames())
85107

86108
# get dst file of transcode
87109
dst_inputFile = av.InputFile( outputFileName )
88-
dst_inputFile.analyse( progress, av.eAnalyseLevelHeader )
89110
dst_properties = dst_inputFile.getProperties()
90111
dst_videoStream = dst_properties.getVideoProperties()[0]
91112

@@ -115,14 +136,21 @@ def testTranscodeYUV420():
115136
customProfile[av.avProfileCodec] = "mpeg2video"
116137
customProfile[av.avProfilePixelFormat] = "yuv420p"
117138

118-
transcoder.add( inputFileName, 0, customProfile )
139+
inputFile = av.InputFile( inputFileName )
140+
src_videoStream = inputFile.getProperties().getVideoProperties()[0]
141+
videoStreamIndex = src_videoStream.getStreamIndex()
142+
transcoder.add( inputFileName, videoStreamIndex, customProfile )
119143

120144
progress = av.ConsoleProgress()
121-
transcoder.process( progress )
145+
processStat = transcoder.process( progress )
146+
147+
# check process stat returned
148+
videoStat = processStat.getVideoStat(0)
149+
assert_equals(src_videoStream.getDuration(), videoStat.getDuration())
150+
assert_equals(int(src_videoStream.getDuration() * src_videoStream.getFps()), videoStat.getNbFrames())
122151

123152
# get dst file of transcode
124153
dst_inputFile = av.InputFile( outputFileName )
125-
dst_inputFile.analyse( progress, av.eAnalyseLevelHeader )
126154
dst_properties = dst_inputFile.getProperties()
127155
dst_videoStream = dst_properties.getVideoProperties()[0]
128156

0 commit comments

Comments
 (0)