def testVideoReaderWithGenerator(): """ Read a video stream with the VideoReader. When there is no more data to decode, switch to a generator and process some frames. """ inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] reader = av.VideoReader(av.InputStreamDesc(inputFileName)) # read all frames and check their size for i in xrange(0, reader.getSourceVideoProperties().getNbFrames()): frame = reader.readNextFrame() bytesPerPixel = reader.getOutputBitDepth() / 8 assert_equals( frame.getDataSize(), reader.getOutputWidth() * reader.getOutputHeight() * bytesPerPixel) # check if there is no next frame assert_equals(reader.readNextFrame(), None) # generate 10 frames of black reader.continueWithGenerator() for i in xrange(0, 9): frame = reader.readNextFrame() bytesPerPixel = reader.getOutputBitDepth() / 8 assert_equals( frame.getDataSize(), reader.getOutputWidth() * reader.getOutputHeight() * bytesPerPixel)
def testVideoReader(): """ Read a video stream with the VideoReader. The InputFile is created inside the reader. """ inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] reader = av.VideoReader(av.InputStreamDesc(inputFileName)) # read all frames and check their size for i in xrange(0, reader.getSourceVideoProperties().getNbFrames()): frame = reader.readNextFrame() bytesPerPixel = reader.getOutputBitDepth() / 8 assert_equals( frame.getDataSize(), reader.getOutputWidth() * reader.getOutputHeight() * bytesPerPixel) # check if there is no next frame assert_equals(reader.readNextFrame(), None)
def testVideoReaderCreateNewInputFile(): """ Read a video stream with the VideoReader. The InputFile is created inside the reader. """ inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] reader = av.VideoReader(inputFileName) # read all frames and check their size for i in xrange(0, reader.getSourceVideoProperties().getNbFrames()): frame = av.VideoFrame(reader.readNextFrame()) assert_equals( frame.getSize(), reader.getOutputWidth() * reader.getOutputHeight() * reader.getOutputNbComponents()) # check if the next frame is empty frame = av.VideoFrame(reader.readNextFrame()) assert_equals(frame.getSize(), 0)