|
| 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