diff --git a/app/avPlayer/main.cpp b/app/avPlayer/main.cpp index e250fa79..f6a2c865 100644 --- a/app/avPlayer/main.cpp +++ b/app/avPlayer/main.cpp @@ -81,7 +81,7 @@ int main(int argc, char** argv) avtranscoder::preloadCodecsAndFormats(); avtranscoder::Logger::setLogLevel(AV_LOG_QUIET); - avtranscoder::VideoReader reader(filename, streamIndex); + avtranscoder::VideoReader reader(avtranscoder::InputStreamDesc(filename, streamIndex)); if(width == 0) width = reader.getOutputWidth(); if(height == 0) diff --git a/src/AvTranscoder/reader/AudioReader.cpp b/src/AvTranscoder/reader/AudioReader.cpp index 981744b8..49c70afe 100644 --- a/src/AvTranscoder/reader/AudioReader.cpp +++ b/src/AvTranscoder/reader/AudioReader.cpp @@ -10,18 +10,8 @@ namespace avtranscoder { -AudioReader::AudioReader(const std::string& filename, const size_t streamIndex, const int channelIndex) - : IReader(filename, streamIndex, channelIndex) - , _audioStreamProperties(NULL) - , _outputSampleRate(0) - , _outputNbChannels(0) - , _outputSampleFormat(AV_SAMPLE_FMT_S16) -{ - init(); -} - -AudioReader::AudioReader(InputFile& inputFile, const size_t streamIndex, const int channelIndex) - : IReader(inputFile, streamIndex, channelIndex) +AudioReader::AudioReader(const InputStreamDesc& inputDesc) + : IReader(inputDesc) , _audioStreamProperties(NULL) , _outputSampleRate(0) , _outputNbChannels(0) @@ -35,22 +25,24 @@ void AudioReader::init() // analyse InputFile avtranscoder::NoDisplayProgress p; _inputFile->analyse(p); - _streamProperties = &_inputFile->getProperties().getStreamPropertiesWithIndex(_streamIndex); + _streamProperties = &_inputFile->getProperties().getStreamPropertiesWithIndex(_inputDesc._streamIndex); _audioStreamProperties = static_cast(_streamProperties); - _inputFile->activateStream(_streamIndex); + _inputFile->activateStream(_inputDesc._streamIndex); // setup decoder - _decoder = new AudioDecoder(_inputFile->getStream(_streamIndex)); + _decoder = new AudioDecoder(_inputFile->getStream(_inputDesc._streamIndex)); _decoder->setupDecoder(); _currentDecoder = _decoder; // create src frame - const AudioFrameDesc srcFrameDesc = _inputFile->getStream(_streamIndex).getAudioCodec().getAudioFrameDesc(); + AudioFrameDesc srcFrameDesc = _inputFile->getStream(_inputDesc._streamIndex).getAudioCodec().getAudioFrameDesc(); + if(! _inputDesc._channelIndexArray.empty()) + srcFrameDesc._nbChannels = _inputDesc._channelIndexArray.size(); _srcFrame = new AudioFrame(srcFrameDesc, false); AudioFrame* srcFrame = static_cast(_srcFrame); // create dst frame _outputSampleRate = srcFrame->getSampleRate(); - _outputNbChannels = (_channelIndex == -1) ? srcFrame->getNbChannels() : 1; + _outputNbChannels = srcFrame->getNbChannels(); _dstFrame = new AudioFrame(AudioFrameDesc(_outputSampleRate, _outputNbChannels, getSampleFormatName(_outputSampleFormat))); // generator diff --git a/src/AvTranscoder/reader/AudioReader.hpp b/src/AvTranscoder/reader/AudioReader.hpp index edaff72e..d9f20ff4 100644 --- a/src/AvTranscoder/reader/AudioReader.hpp +++ b/src/AvTranscoder/reader/AudioReader.hpp @@ -15,8 +15,7 @@ class AvExport AudioReader : public IReader //@{ // @note Transform the input stream to s16 sample format (to listen). // @see updateOutput - AudioReader(const std::string& filename, const size_t streamIndex = 0, const int channelIndex = -1); - AudioReader(InputFile& inputFile, const size_t streamIndex = 0, const int channelIndex = -1); + AudioReader(const InputStreamDesc& inputDesc); //@} ~AudioReader(); diff --git a/src/AvTranscoder/reader/IReader.cpp b/src/AvTranscoder/reader/IReader.cpp index b6f2bf78..6045ba59 100644 --- a/src/AvTranscoder/reader/IReader.cpp +++ b/src/AvTranscoder/reader/IReader.cpp @@ -5,8 +5,9 @@ namespace avtranscoder { -IReader::IReader(const std::string& filename, const size_t streamIndex, const int channelIndex) - : _inputFile(NULL) +IReader::IReader(const InputStreamDesc& inputDesc) + : _inputDesc(inputDesc) + , _inputFile(NULL) , _streamProperties(NULL) , _decoder(NULL) , _generator(NULL) @@ -14,36 +15,15 @@ IReader::IReader(const std::string& filename, const size_t streamIndex, const in , _srcFrame(NULL) , _dstFrame(NULL) , _transform(NULL) - , _streamIndex(streamIndex) - , _channelIndex(channelIndex) , _currentFrame(-1) - , _inputFileAllocated(true) - , _continueWithGenerator(false) -{ - _inputFile = new InputFile(filename); -} - -IReader::IReader(InputFile& inputFile, const size_t streamIndex, const int channelIndex) - : _inputFile(&inputFile) - , _streamProperties(NULL) - , _decoder(NULL) - , _generator(NULL) - , _currentDecoder(NULL) - , _srcFrame(NULL) - , _dstFrame(NULL) - , _transform(NULL) - , _streamIndex(streamIndex) - , _channelIndex(channelIndex) - , _currentFrame(-1) - , _inputFileAllocated(false) , _continueWithGenerator(false) { + _inputFile = new InputFile(_inputDesc._filename); } IReader::~IReader() { - if(_inputFileAllocated) - delete _inputFile; + delete _inputFile; } IFrame* IReader::readNextFrame() @@ -72,11 +52,9 @@ IFrame* IReader::readFrameAt(const size_t frame) _currentFrame = frame; // decode bool decodingStatus = false; - if(_channelIndex != -1) + if(! _inputDesc._channelIndexArray.empty()) { - std::vector channelIndexArray; - channelIndexArray.push_back(_channelIndex); - decodingStatus = _currentDecoder->decodeNextFrame(*_srcFrame, channelIndexArray); + decodingStatus = _currentDecoder->decodeNextFrame(*_srcFrame, _inputDesc._channelIndexArray); } else decodingStatus = _currentDecoder->decodeNextFrame(*_srcFrame); diff --git a/src/AvTranscoder/reader/IReader.hpp b/src/AvTranscoder/reader/IReader.hpp index b8a8a9df..f61017a5 100644 --- a/src/AvTranscoder/reader/IReader.hpp +++ b/src/AvTranscoder/reader/IReader.hpp @@ -3,6 +3,7 @@ #include +#include #include #include #include @@ -19,17 +20,10 @@ class AvExport IReader { public: /** - * @brief Create a new InputFile and prepare to read the stream at the given index - * @param streamIndex by default read the first stream - * @param channelIndex by default -1 (all channels of the stream) + * @brief Prepare to read the given input. + * @param inputDesc: the description of the input to read. */ - IReader(const std::string& filename, const size_t streamIndex = 0, const int channelIndex = -1); - - /** - * @brief Get the existing InputFile and prepare to read the stream at the given index - * @note This constructor can improve performances when you create several readers from one InputFile. - */ - IReader(InputFile& inputFile, const size_t streamIndex = 0, const int channelIndex = -1); + IReader(const InputStreamDesc& inputDesc); virtual ~IReader() = 0; @@ -64,6 +58,7 @@ class AvExport IReader void continueWithGenerator(const bool continueWithGenerator = true) { _continueWithGenerator = continueWithGenerator; } protected: + const InputStreamDesc _inputDesc; InputFile* _inputFile; const StreamProperties* _streamProperties; IDecoder* _decoder; @@ -75,12 +70,8 @@ class AvExport IReader ITransform* _transform; - size_t _streamIndex; - int _channelIndex; - private: int _currentFrame; ///< The current decoded frame. - bool _inputFileAllocated; ///< Does the InputFile is held by the class or not (depends on the constructor called) bool _continueWithGenerator; ///< If there is no more data to decode, complete with generated data }; } diff --git a/src/AvTranscoder/reader/VideoReader.cpp b/src/AvTranscoder/reader/VideoReader.cpp index b6fd245c..bfbcbe5b 100644 --- a/src/AvTranscoder/reader/VideoReader.cpp +++ b/src/AvTranscoder/reader/VideoReader.cpp @@ -10,18 +10,8 @@ namespace avtranscoder { -VideoReader::VideoReader(const std::string& filename, const size_t videoStreamIndex) - : IReader(filename, videoStreamIndex) - , _videoStreamProperties(NULL) - , _outputWidth(0) - , _outputHeight(0) - , _outputPixelProperties("rgb24") -{ - init(); -} - -VideoReader::VideoReader(InputFile& inputFile, const size_t videoStreamIndex) - : IReader(inputFile, videoStreamIndex) +VideoReader::VideoReader(const InputStreamDesc& inputDesc) + : IReader(inputDesc) , _videoStreamProperties(NULL) , _outputWidth(0) , _outputHeight(0) @@ -35,17 +25,17 @@ void VideoReader::init() // analyse InputFile avtranscoder::NoDisplayProgress p; _inputFile->analyse(p); - _streamProperties = &_inputFile->getProperties().getStreamPropertiesWithIndex(_streamIndex); + _streamProperties = &_inputFile->getProperties().getStreamPropertiesWithIndex(_inputDesc._streamIndex); _videoStreamProperties = static_cast(_streamProperties); - _inputFile->activateStream(_streamIndex); + _inputFile->activateStream(_inputDesc._streamIndex); // setup decoder - _decoder = new VideoDecoder(_inputFile->getStream(_streamIndex)); + _decoder = new VideoDecoder(_inputFile->getStream(_inputDesc._streamIndex)); _decoder->setupDecoder(); _currentDecoder = _decoder; // create src frame - const VideoFrameDesc srcFrameDesc = _inputFile->getStream(_streamIndex).getVideoCodec().getVideoFrameDesc(); + const VideoFrameDesc srcFrameDesc = _inputFile->getStream(_inputDesc._streamIndex).getVideoCodec().getVideoFrameDesc(); _srcFrame = new VideoFrame(srcFrameDesc, false); VideoFrame* srcFrame = static_cast(_srcFrame); // create dst frame diff --git a/src/AvTranscoder/reader/VideoReader.hpp b/src/AvTranscoder/reader/VideoReader.hpp index c507c91f..3884c4fc 100644 --- a/src/AvTranscoder/reader/VideoReader.hpp +++ b/src/AvTranscoder/reader/VideoReader.hpp @@ -16,8 +16,7 @@ class AvExport VideoReader : public IReader //@{ // @note Transform the input stream to rgb24 pixel format (to display). // @see updateOutput - VideoReader(const std::string& filename, const size_t videoStreamIndex = 0); - VideoReader(InputFile& inputFile, const size_t videoStreamIndex = 0); + VideoReader(const InputStreamDesc& inputDesc); //@} ~VideoReader(); diff --git a/src/AvTranscoder/transcoder/InputStreamDesc.hpp b/src/AvTranscoder/transcoder/InputStreamDesc.hpp index f9013880..a3083e5d 100644 --- a/src/AvTranscoder/transcoder/InputStreamDesc.hpp +++ b/src/AvTranscoder/transcoder/InputStreamDesc.hpp @@ -37,6 +37,9 @@ struct InputStreamDesc _channelIndexArray.push_back(channelIndex); } + /** + * @brief Read all the channels of the indicated stream. + */ InputStreamDesc(const std::string& filename, const size_t streamIndex) : _filename(filename) , _streamIndex(streamIndex) @@ -44,6 +47,16 @@ struct InputStreamDesc { } + /** + * @brief Read all the channels of the stream at index 0. + */ + InputStreamDesc(const std::string& filename) + : _filename(filename) + , _streamIndex(0) + , _channelIndexArray() + { + } + /** * @return If a demultiplexing step will be done to extract the expected data. */ diff --git a/test/pyTest/testAudioReader.py b/test/pyTest/testAudioReader.py index 7711f9d7..511480e3 100644 --- a/test/pyTest/testAudioReader.py +++ b/test/pyTest/testAudioReader.py @@ -10,13 +10,13 @@ from pyAvTranscoder import avtranscoder as av -def testAudioReaderCreateNewInputFile(): +def testAudioReader(): """ Read a audio stream with the AudioReader. The InputFile is created inside the reader. """ inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] - reader = av.AudioReader(inputFileName) + reader = av.AudioReader(av.InputStreamDesc(inputFileName)) # read all frames and check their size while True: @@ -41,24 +41,20 @@ def testAudioReaderChannelsExtraction(): channelIndex = 0 # create reader to read all channels of the audio stream - readerOfAllChannels = av.AudioReader(inputFile, streamIndex) + readerOfAllChannels = av.AudioReader(av.InputStreamDesc(inputFileName, streamIndex)) nbChannels = readerOfAllChannels.getOutputNbChannels() # read first frame frame = readerOfAllChannels.readNextFrame() sizeOfFrameWithAllChannels = frame.getDataSize() # create reader to read one channel of the audio stream - readerOfOneChannel = av.AudioReader(inputFile, streamIndex, channelIndex) + readerOfOneChannel = av.AudioReader(av.InputStreamDesc(inputFileName, streamIndex, channelIndex)) # read first frame frame = readerOfOneChannel.readNextFrame() sizeOfFrameWithOneChannels = frame.getDataSize() assert_equals( sizeOfFrameWithAllChannels / nbChannels, sizeOfFrameWithOneChannels ) - # Force to call the readers destructor before the inputFile destructor (which cannot happen in C++) - readerOfAllChannels = None - readerOfOneChannel = None - def testAudioReaderWithGenerator(): """ @@ -66,7 +62,7 @@ def testAudioReaderWithGenerator(): When there is no more data to decode, switch to a generator and process some frames. """ inputFileName = os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] - reader = av.AudioReader(inputFileName) + reader = av.AudioReader(av.InputStreamDesc(inputFileName)) # read all frames and check their size while True: diff --git a/test/pyTest/testNbFrames.py b/test/pyTest/testNbFrames.py index d97e349c..c1fdcb7b 100644 --- a/test/pyTest/testNbFrames.py +++ b/test/pyTest/testNbFrames.py @@ -20,7 +20,7 @@ def testNbFramesVideoRewrap(): ouputFile = av.OutputFile( outputFileName ) transcoder = av.Transcoder( ouputFile ) - transcoder.addStream( av.InputStreamDesc(inputFileName, 0) ) + transcoder.addStream( av.InputStreamDesc(inputFileName) ) progress = av.ConsoleProgress() transcoder.process( progress ) @@ -47,7 +47,7 @@ def testNbFramesVideoTranscode(): ouputFile = av.OutputFile( outputFileName ) transcoder = av.Transcoder( ouputFile ) - transcoder.addStream( av.InputStreamDesc(inputFileName, 0), "mpeg2" ) + transcoder.addStream( av.InputStreamDesc(inputFileName), "mpeg2" ) progress = av.ConsoleProgress() transcoder.process( progress ) diff --git a/test/pyTest/testNbSamples.py b/test/pyTest/testNbSamples.py index 3dad11b9..10e24d47 100644 --- a/test/pyTest/testNbSamples.py +++ b/test/pyTest/testNbSamples.py @@ -20,7 +20,7 @@ def testNbSamplesAudioRewrap(): ouputFile = av.OutputFile( outputFileName ) transcoder = av.Transcoder( ouputFile ) - transcoder.addStream( av.InputStreamDesc(inputFileName, 0) ) + transcoder.addStream( av.InputStreamDesc(inputFileName) ) progress = av.ConsoleProgress() transcoder.process( progress ) @@ -54,7 +54,7 @@ def testNbSamplesAudioTranscode(): customProfile[av.avProfileType] = av.avProfileTypeAudio customProfile[av.avProfileCodec] = "pcm_s16le" - transcoder.addStream( av.InputStreamDesc(inputFileName, 0), customProfile ) + transcoder.addStream( av.InputStreamDesc(inputFileName), customProfile ) progress = av.ConsoleProgress() transcoder.process( progress ) diff --git a/test/pyTest/testOffset.py b/test/pyTest/testOffset.py index 002cc39f..30ad3043 100644 --- a/test/pyTest/testOffset.py +++ b/test/pyTest/testOffset.py @@ -26,7 +26,7 @@ def testTranscodeAudioPositiveOffset(): ouputFile = av.OutputFile( outputFileName ) transcoder = av.Transcoder( ouputFile ) - transcoder.addStream( av.InputStreamDesc(inputFileName, 0), "wave24b48kmono", offset ) + transcoder.addStream( av.InputStreamDesc(inputFileName), "wave24b48kmono", offset ) progress = av.ConsoleProgress() transcoder.process( progress ) @@ -56,7 +56,7 @@ def testTranscodeAudioNegativeOffset(): ouputFile = av.OutputFile( outputFileName ) transcoder = av.Transcoder( ouputFile ) - transcoder.addStream( av.InputStreamDesc(inputFileName, 0), "wave24b48kmono", offset ) + transcoder.addStream( av.InputStreamDesc(inputFileName), "wave24b48kmono", offset ) progress = av.ConsoleProgress() transcoder.process( progress ) @@ -86,7 +86,7 @@ def testRewrapAudioPositiveOffset(): ouputFile = av.OutputFile( outputFileName ) transcoder = av.Transcoder( ouputFile ) - transcoder.addStream( av.InputStreamDesc(inputFileName, 0), "", offset ) + transcoder.addStream( av.InputStreamDesc(inputFileName), "", offset ) progress = av.ConsoleProgress() transcoder.process( progress ) @@ -117,7 +117,7 @@ def testRewrapAudioNegativeOffset(): ouputFile = av.OutputFile( outputFileName ) transcoder = av.Transcoder( ouputFile ) - transcoder.addStream( av.InputStreamDesc(inputFileName, 0), "", offset ) + transcoder.addStream( av.InputStreamDesc(inputFileName), "", offset ) progress = av.ConsoleProgress() transcoder.process( progress ) @@ -150,7 +150,7 @@ def testTranscodeVideoPositiveOffset(): ouputFile = av.OutputFile( outputFileName ) transcoder = av.Transcoder( ouputFile ) - transcoder.addStream( av.InputStreamDesc(inputFileName, 0), "mpeg2", offset ) + transcoder.addStream( av.InputStreamDesc(inputFileName), "mpeg2", offset ) progress = av.ConsoleProgress() transcoder.process( progress ) @@ -180,7 +180,7 @@ def testTranscodeVideoNegativeOffset(): ouputFile = av.OutputFile( outputFileName ) transcoder = av.Transcoder( ouputFile ) - transcoder.addStream( av.InputStreamDesc(inputFileName, 0), "mpeg2", offset ) + transcoder.addStream( av.InputStreamDesc(inputFileName), "mpeg2", offset ) progress = av.ConsoleProgress() transcoder.process( progress ) @@ -210,7 +210,7 @@ def testRewrapVideoPositiveOffset(): ouputFile = av.OutputFile( outputFileName ) transcoder = av.Transcoder( ouputFile ) - transcoder.addStream( av.InputStreamDesc(inputFileName, 0), "", offset ) + transcoder.addStream( av.InputStreamDesc(inputFileName), "", offset ) progress = av.ConsoleProgress() transcoder.process( progress ) @@ -241,7 +241,7 @@ def testRewrapVideoNegativeOffset(): ouputFile = av.OutputFile( outputFileName ) transcoder = av.Transcoder( ouputFile ) - transcoder.addStream( av.InputStreamDesc(inputFileName, 0), "", offset ) + transcoder.addStream( av.InputStreamDesc(inputFileName), "", offset ) progress = av.ConsoleProgress() transcoder.process( progress ) @@ -275,7 +275,7 @@ def testMultipleOffsetFromSameInputFile(): ouputFile = av.OutputFile( outputFileName ) transcoder = av.Transcoder( ouputFile ) - transcoder.addStream( av.InputStreamDesc(inputFileName, 0), "", offset_1 ) + transcoder.addStream( av.InputStreamDesc(inputFileName), "", offset_1 ) transcoder.addStream( av.InputStreamDesc(inputFileName, 1), "", offset_2 ) progress = av.ConsoleProgress() @@ -312,8 +312,8 @@ def testMultipleOffsetFromSameStream(): ouputFile = av.OutputFile( outputFileName ) transcoder = av.Transcoder( ouputFile ) - transcoder.addStream( av.InputStreamDesc(inputFileName, 0), "", offset_1 ) - transcoder.addStream( av.InputStreamDesc(inputFileName, 0), "", offset_2 ) + transcoder.addStream( av.InputStreamDesc(inputFileName), "", offset_1 ) + transcoder.addStream( av.InputStreamDesc(inputFileName), "", offset_2 ) progress = av.ConsoleProgress() transcoder.process( progress ) diff --git a/test/pyTest/testProperties.py b/test/pyTest/testProperties.py index 91c77584..9fba25c7 100644 --- a/test/pyTest/testProperties.py +++ b/test/pyTest/testProperties.py @@ -28,7 +28,7 @@ def testAddPossibleMetadata(): transcoder = av.Transcoder( ouputFile ) # rewrap a stream - transcoder.addStream( av.InputStreamDesc(inputFileName, 0) ) + transcoder.addStream( av.InputStreamDesc(inputFileName) ) # add a set of metadata metadata_to_check = av.PropertyVector() @@ -57,7 +57,7 @@ def testAddImpossibleMetadata(): transcoder = av.Transcoder( ouputFile ) # rewrap a stream - transcoder.addStream( av.InputStreamDesc(inputFileName, 0) ) + transcoder.addStream( av.InputStreamDesc(inputFileName) ) # add one metadata metadata_to_check = ("undefinedMetadataKey", "undefinedMetadataValue") diff --git a/test/pyTest/testTranscoderAdd.py b/test/pyTest/testTranscoderAdd.py index 5edb9e8f..c93d050e 100644 --- a/test/pyTest/testTranscoderAdd.py +++ b/test/pyTest/testTranscoderAdd.py @@ -47,7 +47,7 @@ def testAddAStreamFromAFileWhichDoesNotExist(): ouputFile = av.OutputFile( outputFileName ) transcoder = av.Transcoder( ouputFile ) - transcoder.addStream( av.InputStreamDesc(inputFileName, 0) ) + transcoder.addStream( av.InputStreamDesc(inputFileName) ) # process transcoder.process() diff --git a/test/pyTest/testTranscoderRewrap.py b/test/pyTest/testTranscoderRewrap.py index aee5c50e..d39fabc9 100644 --- a/test/pyTest/testTranscoderRewrap.py +++ b/test/pyTest/testTranscoderRewrap.py @@ -72,7 +72,7 @@ def testRewrapAudioStream(): ouputFile = av.OutputFile( outputFileName ) transcoder = av.Transcoder( ouputFile ) - transcoder.addStream( av.InputStreamDesc(inputFileName, 0) ) + transcoder.addStream( av.InputStreamDesc(inputFileName) ) processStat = transcoder.process() # check process stat returned @@ -106,7 +106,7 @@ def testRewrapAVIVideoStream(): ouputFile = av.OutputFile( outputFileName ) transcoder = av.Transcoder( ouputFile ) - transcoder.addStream( av.InputStreamDesc(inputFileName, 0) ) + transcoder.addStream( av.InputStreamDesc(inputFileName) ) processStat = transcoder.process() # check process stat returned @@ -173,7 +173,7 @@ def testRewrapRawVideoStream(): ouputFile = av.OutputFile(outputFileName) transcoder = av.Transcoder(ouputFile) - transcoder.addStream( av.InputStreamDesc(inputFileName, 0) ) + transcoder.addStream( av.InputStreamDesc(inputFileName) ) processStat = transcoder.process() # check process stat returned diff --git a/test/pyTest/testVideoReader.py b/test/pyTest/testVideoReader.py index bf853592..597738f9 100644 --- a/test/pyTest/testVideoReader.py +++ b/test/pyTest/testVideoReader.py @@ -10,13 +10,13 @@ from pyAvTranscoder import avtranscoder as av -def testVideoReaderCreateNewInputFile(): +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(inputFileName) + reader = av.VideoReader(av.InputStreamDesc(inputFileName)) # read all frames and check their size for i in xrange(0, reader.getSourceVideoProperties().getNbFrames()): @@ -28,35 +28,13 @@ def testVideoReaderCreateNewInputFile(): assert_equals( reader.readNextFrame(), None ) -def testVideoReaderReferenceInputFile(): - """ - Read a video stream with the VideoReader. - The InputFile is a reference for the reader. - """ - inputFileName = os.environ['AVTRANSCODER_TEST_VIDEO_AVI_FILE'] - inputFile = av.InputFile(inputFileName) - reader = av.VideoReader(inputFile) - - # 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 ) - - # Force to call the reader destructor before the inputFile destructor (which cannot happen in C++) - reader = None - - 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(inputFileName) + reader = av.VideoReader(av.InputStreamDesc(inputFileName)) # read all frames and check their size for i in xrange(0, reader.getSourceVideoProperties().getNbFrames()): pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy