@@ -20,14 +20,21 @@ def testTranscodeDnxhd120():
20
20
ouputFile = av .OutputFile ( outputFileName )
21
21
transcoder = av .Transcoder ( ouputFile )
22
22
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" )
24
27
25
28
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 ())
27
35
28
36
# get dst file of transcode
29
37
dst_inputFile = av .InputFile ( outputFileName )
30
- dst_inputFile .analyse ( progress , av .eAnalyseLevelFirstGop )
31
38
dst_properties = dst_inputFile .getProperties ()
32
39
dst_videoStream = dst_properties .getVideoProperties ()[0 ]
33
40
@@ -49,14 +56,21 @@ def testTranscodeDnxhd185():
49
56
ouputFile = av .OutputFile ( outputFileName )
50
57
transcoder = av .Transcoder ( ouputFile )
51
58
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" )
53
63
54
64
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 ())
56
71
57
72
# get dst file of transcode
58
73
dst_inputFile = av .InputFile ( outputFileName )
59
- dst_inputFile .analyse ( progress , av .eAnalyseLevelHeader )
60
74
dst_properties = dst_inputFile .getProperties ()
61
75
dst_videoStream = dst_properties .getVideoProperties ()[0 ]
62
76
@@ -78,14 +92,21 @@ def testTranscodeDnxhd185x():
78
92
ouputFile = av .OutputFile ( outputFileName )
79
93
transcoder = av .Transcoder ( ouputFile )
80
94
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" )
82
99
83
100
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 ())
85
107
86
108
# get dst file of transcode
87
109
dst_inputFile = av .InputFile ( outputFileName )
88
- dst_inputFile .analyse ( progress , av .eAnalyseLevelHeader )
89
110
dst_properties = dst_inputFile .getProperties ()
90
111
dst_videoStream = dst_properties .getVideoProperties ()[0 ]
91
112
@@ -115,14 +136,21 @@ def testTranscodeYUV420():
115
136
customProfile [av .avProfileCodec ] = "mpeg2video"
116
137
customProfile [av .avProfilePixelFormat ] = "yuv420p"
117
138
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 )
119
143
120
144
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 ())
122
151
123
152
# get dst file of transcode
124
153
dst_inputFile = av .InputFile ( outputFileName )
125
- dst_inputFile .analyse ( progress , av .eAnalyseLevelHeader )
126
154
dst_properties = dst_inputFile .getProperties ()
127
155
dst_videoStream = dst_properties .getVideoProperties ()[0 ]
128
156
0 commit comments