-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathtestProcessStat.py
More file actions
46 lines (36 loc) · 1.77 KB
/
Copy pathtestProcessStat.py
File metadata and controls
46 lines (36 loc) · 1.77 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
import os
# Check if environment is setup to run the tests
if os.environ.get('AVTRANSCODER_TEST_VIDEO_AVI_FILE') is None:
from nose.plugins.skip import SkipTest
raise SkipTest("Need to define environment variables "
"AVTRANSCODER_TEST_VIDEO_AVI_FILE")
from nose.tools import *
from pyAvTranscoder import avtranscoder as av
def testProcessWithStatistics():
"""
Process one video stream with a custom profile of encoding to activate statistics.
"""
inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE']
outputFileName = "testProcessWithStatistics.mov"
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.avProfileTypeVideo
customProfile[av.avProfileCodec] = "mpeg2video"
customProfile[av.avProfileProcessStat] = "processStat"
src_inputFile = av.InputFile( inputFileName )
src_properties = src_inputFile.getProperties()
src_videoStream = src_properties.getVideoProperties()[0]
videoStreamIndex = src_videoStream.getStreamIndex()
transcoder.addStream( av.InputStreamDesc(inputFileName, videoStreamIndex), customProfile )
progress = av.ConsoleProgress()
processStat = transcoder.process( progress )
# check process stat returned
videoStat = processStat.getVideoStat(0)
# assert_equals(videoStat.getDuration(), src_videoStream.getDuration())
assert_equals(videoStat.getNbFrames(), int(src_videoStream.getDuration() * src_videoStream.getFps()))
assert_not_equals(videoStat.getQuality(), 0)
assert_not_equals(videoStat.getPSNR(), 0)