-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathtestInputFile.py
More file actions
133 lines (106 loc) · 4.76 KB
/
Copy pathtestInputFile.py
File metadata and controls
133 lines (106 loc) · 4.76 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
130
131
132
133
import os
# Check if environment is setup to run the tests
if os.environ.get('AVTRANSCODER_TEST_VIDEO_MOV_FILE') is None:
from nose.plugins.skip import SkipTest
raise SkipTest("Need to define environment variables "
"AVTRANSCODER_TEST_VIDEO_MOV_FILE")
from nose.tools import *
from pyAvTranscoder import avtranscoder as av
@raises(IOError)
def testCreateInputFileFromUnexistingFilename():
"""
Create an InputFile from an unexisting filename.
"""
inputFileName = "testCreateInputFileFromUnexistingFilename"
av.InputFile( inputFileName )
@raises(RuntimeError)
def testInputFileAnalyseHeaderTryToAccessisInterlaced():
"""
Analyse only header of an InputFile, and try to access a properties computed when access the first GOP.
"""
inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_MOV_FILE']
inputFile = av.InputFile(inputFileName)
# The analyse of the first GOP is not done yet
videoProperties = inputFile.getProperties().getVideoProperties()[0]
videoProperties.isInterlaced()
@raises(RuntimeError)
def testInputFileAnalyseHeaderTryToAccessisTopFieldFirst():
"""
Analyse only header of an InputFile, and try to access a properties computed when access the first GOP.
"""
inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_MOV_FILE']
inputFile = av.InputFile(inputFileName)
# The analyse of the first GOP is not done yet
videoProperties = inputFile.getProperties().getVideoProperties()[0]
videoProperties.isTopFieldFirst()
@raises(RuntimeError)
def testInputFileAnalyseHeaderTryToAccessisGopSize():
"""
Analyse only header of an InputFile, and try to access a properties computed when access the first GOP.
"""
inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_MOV_FILE']
inputFile = av.InputFile(inputFileName)
# The analyse of the first GOP is not done yet
videoProperties = inputFile.getProperties().getVideoProperties()[0]
videoProperties.getGopSize()
@raises(RuntimeError)
def testInputFileAnalyseHeaderTryToAccessisGopStructure():
"""
Analyse only header of an InputFile, and try to access a properties computed when access the first GOP.
"""
inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_MOV_FILE']
inputFile = av.InputFile(inputFileName)
# The analyse of the first GOP is not done yet
videoProperties = inputFile.getProperties().getVideoProperties()[0]
videoProperties.getGopStructure()
def testInputFileAnalyseFirstGop():
"""
Analyse the first gop of an InputFile, and check if the correct attributes are filled.
"""
inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_MOV_FILE']
inputFile = av.InputFile( inputFileName )
# Analyse first GOP
progress = av.NoDisplayProgress()
inputFile.analyse( progress, av.eAnalyseLevelFirstGop )
# Check properties after GOP analysis
videoProperties = inputFile.getProperties().getVideoProperties()[0]
assert_greater(videoProperties.getGopSize(), 0)
assert_not_equals(videoProperties.getGopStructure(), ())
for image in videoProperties.getGopStructure():
pictureType = image[0]
encodedPictureSize = image[1]
assert_in(pictureType, ['I', 'P', 'B'])
assert_greater(encodedPictureSize, 0)
assert_not_equals(videoProperties.getDuration(), 0)
assert_not_equals(videoProperties.getBitRate(), 0)
assert_not_equals(videoProperties.getNbFrames(), 0)
def testInputFileAnalyseFull():
"""
Analyse the full video stream of an InputFile, and check if the correct attributes are filled.
"""
inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_RAW_FILE']
inputFile = av.InputFile( inputFileName )
# Analyse full stream
progress = av.ConsoleProgress()
inputFile.analyse(progress, av.eAnalyseLevelFull)
# Check properties after full analysis
videoProperties = inputFile.getProperties().getVideoProperties()[0]
assert_greater(videoProperties.getGopSize(), 0)
assert_not_equals(videoProperties.getGopStructure(), ())
for image in videoProperties.getGopStructure():
pictureType = image[0]
encodedPictureSize = image[1]
assert_in(pictureType, ['I', 'P', 'B'])
assert_greater(encodedPictureSize, 0)
assert_not_equals(videoProperties.getDuration(), 0)
assert_not_equals(videoProperties.getBitRate(), 0)
assert_not_equals(videoProperties.getNbFrames(), 0)
@raises(RuntimeError)
def testInputFileSetupInvalidUnwrappingProfile():
"""
Analyse only header of an InputFile, and try to access a properties computed when access the first GOP.
"""
inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_MOV_FILE']
emptyUnwrappingProfile = av.ProfileMap()
inputFile = av.InputFile(inputFileName)
inputFile.setupUnwrapping(emptyUnwrappingProfile);