Skip to content

Commit 1b4510c

Browse files
author
Clement Champetier
committed
pyTest: added a test to check a process with the statistics activated
1 parent 0dd7e49 commit 1b4510c

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

test/pyTest/testProcessStat.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import os
2+
3+
# Check if environment is setup to run the tests
4+
if os.environ.get('AVTRANSCODER_TEST_VIDEO_AVI_FILE') is None:
5+
from nose.plugins.skip import SkipTest
6+
raise SkipTest("Need to define environment variables "
7+
"AVTRANSCODER_TEST_VIDEO_AVI_FILE")
8+
9+
from nose.tools import *
10+
11+
from pyAvTranscoder import avtranscoder as av
12+
13+
14+
def testProcessWithStatistics():
15+
"""
16+
Process one video stream with a custom profile of encoding to activate statistics.
17+
"""
18+
inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE']
19+
outputFileName = "testProcessWithStatistics.mov"
20+
21+
ouputFile = av.OutputFile( outputFileName )
22+
transcoder = av.Transcoder( ouputFile )
23+
24+
# create custom profile
25+
customProfile = av.ProfileMap()
26+
customProfile[av.avProfileIdentificator] = "customProfile"
27+
customProfile[av.avProfileIdentificatorHuman] = "custom profile"
28+
customProfile[av.avProfileType] = av.avProfileTypeVideo
29+
customProfile[av.avProfileCodec] = "mpeg2video"
30+
customProfile[av.avProfileProcessStat] = "processStat"
31+
32+
src_inputFile = av.InputFile( inputFileName )
33+
src_properties = src_inputFile.getProperties()
34+
src_videoStream = src_properties.getVideoProperties()[0]
35+
videoStreamIndex = src_videoStream.getStreamIndex()
36+
transcoder.add( inputFileName, videoStreamIndex, customProfile )
37+
38+
progress = av.ConsoleProgress()
39+
processStat = transcoder.process( progress )
40+
41+
# check process stat returned
42+
videoStat = processStat.getVideoStat(0)
43+
assert_equals(videoStat.getDuration(), src_videoStream.getDuration())
44+
assert_equals(videoStat.getNbFrames(), int(src_videoStream.getDuration() * src_videoStream.getFps()))
45+
assert_not_equals(videoStat.getQuality(), 0)
46+
assert_not_equals(videoStat.getPSNR(), 0)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy