-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathtestOutputFile.py
More file actions
114 lines (89 loc) · 3.96 KB
/
Copy pathtestOutputFile.py
File metadata and controls
114 lines (89 loc) · 3.96 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
from nose.tools import *
from pyAvTranscoder import avtranscoder as av
def testCreateOutputFileWithExtension():
"""
Create an OutputFile with a filename with extension.
"""
formatName = "mov"
formatLongName = "QuickTime / MOV"
outputFileName = "testCreateOutputFileWithExtension." + formatName
ouputFile = av.OutputFile( outputFileName )
assert_equals( ouputFile.getFilename(), outputFileName )
assert_equals( ouputFile.getFormatName(), formatName )
assert_in( ouputFile.getFormatLongName(), (formatLongName, '') )
@raises(IOError)
def testCreateOutputFileWithoutExtension():
"""
Create an OutputFile with a filename without extension.
"""
outputFileName = "testCreateOutputFileWithoutExtension"
av.OutputFile( outputFileName )
def testCreateOutputFileWithoutExtensionWithFormat():
"""
Create an OutputFile with a filename without extension.
Indicate the format.
"""
formatName = "mov"
formatLongName = "QuickTime / MOV"
outputFileName = "testCreateOutputFileWithoutExtensionWithFormat"
ouputFile = av.OutputFile( outputFileName, formatName )
assert_equals( ouputFile.getFilename(), outputFileName )
assert_equals( ouputFile.getFormatName(), formatName )
assert_in( ouputFile.getFormatLongName(), (formatLongName, '') )
def testCreateOutputFileWithUnknownExtensionWithFormat():
"""
Create an OutputFile with a filename with an unknown extension.
Indicate the format.
"""
formatName = "h264"
formatLongName = "raw H.264 video"
outputFileName = "testCreateOutputFileWithUnknownExtensionWithFormat.avc"
ouputFile = av.OutputFile(outputFileName, formatName)
assert_equals(ouputFile.getFilename(), outputFileName)
assert_equals(ouputFile.getFormatName(), formatName)
assert_in( ouputFile.getFormatLongName(), (formatLongName, '') )
def testCreateOutputFileWithoutExtensionWithMimeType():
"""
Create an OutputFile with a filename without extension.
Indicate the Mime Type.
"""
mimeType = "video/mp4"
outputFileName = "testCreateOutputFileWithoutExtensionWithMimeType"
ouputFile = av.OutputFile( outputFileName, "", mimeType )
assert_equals( ouputFile.getFilename(), outputFileName )
assert_equals( ouputFile.getFormatMimeType(), mimeType )
def testCreateOutputFileWithoutExtensionWithInconsistentFormatAndMimeType():
"""
Create an OutputFile with a filename without extension.
Indicate inconsistent format and Mime Type.
The OutputFile should by-pass the Mime Type.
"""
formatName = "mov"
formatLongName = "QuickTime / MOV"
mimeType = "application/mp4"
outputFileName = "testCreateOutputFileWithoutExtensionWithInconsistentFormatAndMimeType"
ouputFile = av.OutputFile( outputFileName, formatName, mimeType )
assert_equals( ouputFile.getFilename(), outputFileName )
assert_equals( ouputFile.getFormatName(), formatName )
assert_in( ouputFile.getFormatLongName(), (formatLongName, '') )
assert_not_equals( ouputFile.getFormatMimeType(), mimeType )
@raises(RuntimeError)
def testGetUnexistedOutputStream():
"""
Create an OutputFile, and try to access a stream which does not exist.
"""
outputFileName = "testGetUnexistedOutputStream.mov"
ouputFile = av.OutputFile(outputFileName)
ouputFile.getStream(0)
def testAddingCustomStream():
"""
Create an OutputFile, and add a custom stream and try to access that stream.
"""
outputFileName = "testAddingCustomStream.mov"
ouputFile = av.OutputFile(outputFileName)
codec = av.AudioCodec(av.eCodecTypeEncoder, "pcm_s24le");
addedOutputStream = ouputFile.addCustomStream(codec)
retrievedOutputStream = ouputFile.getStream(0)
assert_equals(addedOutputStream.getStreamIndex(), retrievedOutputStream.getStreamIndex())
assert_equals(addedOutputStream.getStreamDuration(), retrievedOutputStream.getStreamDuration())
assert_equals(addedOutputStream.getNbFrames(), retrievedOutputStream.getNbFrames())