forked from avTranscoder/avTranscoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestTranscoderTranscodeImage.py
More file actions
75 lines (56 loc) · 2.63 KB
/
Copy pathtestTranscoderTranscodeImage.py
File metadata and controls
75 lines (56 loc) · 2.63 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
import os
# Check if environment is setup to run the tests
if os.environ.get('AVTRANSCODER_TEST_IMAGE_PNG_FILE') is None or \
os.environ.get('AVTRANSCODER_TEST_IMAGE_JPG_FILE') is None:
from nose.plugins.skip import SkipTest
raise SkipTest("Need to define environment variables "
"AVTRANSCODER_TEST_IMAGE_PNG_FILE and "
"AVTRANSCODER_TEST_IMAGE_JPG_FILE")
from nose.tools import *
from pyAvTranscoder import avtranscoder as av
def testTranscodePngToMjpeg():
"""
Transcode one image (to mjpeg).
"""
inputFileName = os.environ['AVTRANSCODER_TEST_IMAGE_PNG_FILE']
outputFileName = "testTranscodePngToMjpeg.jpg"
ouputFile = av.OutputFile( outputFileName )
transcoder = av.Transcoder( ouputFile )
inputFile = av.InputFile( inputFileName )
src_videoStream = inputFile.getProperties().getVideoProperties()[0]
videoStreamIndex = src_videoStream.getStreamIndex()
transcoder.addStream( av.InputStreamDesc(inputFileName, videoStreamIndex), "mjpeg" )
progress = av.ConsoleProgress()
processStat = transcoder.process( progress )
# check process stat returned
videoStat = processStat.getVideoStat(0)
assert_equals(1, videoStat.getNbFrames())
# get dst file of transcode
dst_inputFile = av.InputFile( outputFileName )
dst_properties = dst_inputFile.getProperties()
dst_videoStream = dst_properties.getVideoProperties()[0]
assert_equals( "mjpeg", dst_videoStream.getCodecName() )
assert_equals( "yuvj420p", dst_videoStream.getPixelProperties().getPixelName() )
def testTranscodeJpgToMjpeg():
"""
Transcode one image (to mjpeg).
"""
inputFileName = os.environ['AVTRANSCODER_TEST_IMAGE_JPG_FILE']
outputFileName = "testTranscodeJpgToMjpeg.jpg"
ouputFile = av.OutputFile( outputFileName )
transcoder = av.Transcoder( ouputFile )
inputFile = av.InputFile( inputFileName )
src_videoStream = inputFile.getProperties().getVideoProperties()[0]
videoStreamIndex = src_videoStream.getStreamIndex()
transcoder.addStream( av.InputStreamDesc(inputFileName, videoStreamIndex), "mjpeg" )
progress = av.ConsoleProgress()
processStat = transcoder.process( progress )
# check process stat returned
videoStat = processStat.getVideoStat(0)
assert_equals(1, videoStat.getNbFrames())
# get dst file of transcode
dst_inputFile = av.InputFile( outputFileName )
dst_properties = dst_inputFile.getProperties()
dst_videoStream = dst_properties.getVideoProperties()[0]
assert_equals( "mjpeg", dst_videoStream.getCodecName() )
assert_equals( "yuvj420p", dst_videoStream.getPixelProperties().getPixelName() )