From 9093b4122dfd153a9e93fe65400a8cb8e22d94fe Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Mon, 4 Jan 2016 15:39:04 +0100 Subject: [PATCH 01/18] InputFile: updated log when no more data to read on file --- src/AvTranscoder/file/InputFile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AvTranscoder/file/InputFile.cpp b/src/AvTranscoder/file/InputFile.cpp index 156fc565..074fc57c 100644 --- a/src/AvTranscoder/file/InputFile.cpp +++ b/src/AvTranscoder/file/InputFile.cpp @@ -68,7 +68,7 @@ bool InputFile::readNextPacket(CodedData& data, const size_t streamIndex) const int ret = av_read_frame(&_formatContext.getAVFormatContext(), &data.getAVPacket()); if(ret < 0) // error or end of file { - LOG_INFO("No more data to read on file '" << _filename << "'") + LOG_INFO("No more data to read on file '" << _filename << "' for stream " << streamIndex) return false; } From 8470ef71ae9659fc07dfb52680aaa598b94d9a89 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Mon, 4 Jan 2016 16:03:05 +0100 Subject: [PATCH 02/18] StreamTranscoder: fixed private method getProcessCase The process case of a StreamTranscoder could change during the process (depending on the state of the _currentDecoder attribute). --- src/AvTranscoder/transcoder/StreamTranscoder.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AvTranscoder/transcoder/StreamTranscoder.cpp b/src/AvTranscoder/transcoder/StreamTranscoder.cpp index 44b32d1c..8c89eafa 100644 --- a/src/AvTranscoder/transcoder/StreamTranscoder.cpp +++ b/src/AvTranscoder/transcoder/StreamTranscoder.cpp @@ -547,9 +547,9 @@ void StreamTranscoder::setOffset(const float offset) StreamTranscoder::EProcessCase StreamTranscoder::getProcessCase() const { - if(_inputStream && _inputDecoder) + if(_inputStream && _inputDecoder && _currentDecoder == _inputDecoder) return eProcessCaseTranscode; - else if(_inputStream && !_inputDecoder) + else if(_inputStream && !_inputDecoder && !_currentDecoder) return eProcessCaseRewrap; else return eProcessCaseGenerator; From b8eaa7154349880f23cc60ff4b37cd98df8d2ea7 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Mon, 4 Jan 2016 16:24:22 +0100 Subject: [PATCH 03/18] Transcoder: added log when a process ended --- src/AvTranscoder/transcoder/Transcoder.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/AvTranscoder/transcoder/Transcoder.cpp b/src/AvTranscoder/transcoder/Transcoder.cpp index db698f7b..cbe9a37d 100644 --- a/src/AvTranscoder/transcoder/Transcoder.cpp +++ b/src/AvTranscoder/transcoder/Transcoder.cpp @@ -278,21 +278,27 @@ ProcessStat Transcoder::process(IProgress& progress) // check if JobStatusCancel if(progress.progress((progressDuration > outputDuration) ? outputDuration : progressDuration, outputDuration) == eJobStatusCancel) + { + LOG_INFO("End of process because the job was canceled.") break; + } // check progressDuration if(progressDuration >= outputDuration) + { + LOG_INFO("End of process because the output program duration (" + << progressDuration << "s) is equal or upper than " << outputDuration << "s.") break; + } LOG_DEBUG("Process frame " << frame) frameProcessed = processFrame(); - ++frame; } _outputFile.endWrap(); - LOG_INFO("End of process") + LOG_INFO("End of process: " << frame << " frames processed") LOG_INFO("Get process statistics") ProcessStat processStat; From ae2e1d99189112b0a58beaf0f62586e2103478a8 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Mon, 4 Jan 2016 18:07:24 +0100 Subject: [PATCH 04/18] Transcoder: updated doc of the processing policy --- src/AvTranscoder/transcoder/Transcoder.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/AvTranscoder/transcoder/Transcoder.hpp b/src/AvTranscoder/transcoder/Transcoder.hpp index f54cb3d6..fac968df 100644 --- a/src/AvTranscoder/transcoder/Transcoder.hpp +++ b/src/AvTranscoder/transcoder/Transcoder.hpp @@ -17,14 +17,14 @@ namespace avtranscoder { /** - * @brief Enum to set a policy of how we manage the transcode in case of several streams. - * eProcessMethodShortest: stop transcode at the end of the shortest stream. - * eProcessMethodLongest: stop transcode at the end of the longest stream. - * eProcessMethodBasedOnStream: stop transcode at the end of an indicated stream (@see _indexBasedStream attribute of + * @brief Enum to set a policy of how we manage the process in case of several streams. + * eProcessMethodShortest: stop the process at the end of the shortest stream. + * eProcessMethodLongest: stop the process at the end of the longest stream. + * eProcessMethodBasedOnStream: stop the process at the end of an indicated stream (@see _indexBasedStream attribute of * Transcoder). - * eProcessMethodBasedOnDuration: stop transcode at the end of an indicated duration, in seconds (@see _outputDuration + * eProcessMethodBasedOnDuration: stop the process at the end of an indicated duration, in seconds (@see _outputDuration * attribute of Transcoder). - * eProcessMethodInfinity: stop transcode by outside of avTranscoder (streaming mode) + * eProcessMethodInfinity: stop the process by outside of avTranscoder (streaming mode) */ enum EProcessMethod { @@ -229,9 +229,9 @@ class AvExport Transcoder std::vector _streamTranscoders; ///< All streams of the output media file after process. std::vector _streamTranscodersAllocated; ///< Streams allocated inside the Transcoder (has ownership) - ProfileLoader _profileLoader; ///< Objet to get existing profiles, and add new ones for the Transcoder. + ProfileLoader _profileLoader; ///< Objet to get existing profiles, and add new ones for the Transcoder. - EProcessMethod _eProcessMethod; ///< Transcoding policy + EProcessMethod _eProcessMethod; ///< Processing policy size_t _mainStreamIndex; ///< Index of stream used to stop the process of transcode in case of eProcessMethodBasedOnStream. float _outputDuration; ///< Duration of output media used to stop the process of transcode in case of From 0a9dc6841e02a5d5d09ad254a8b0e7cbb5529050 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Wed, 6 Jan 2016 09:51:45 +0100 Subject: [PATCH 05/18] StreamTranscoder: updated accessor of getProcessCase scope The method is now public. --- src/AvTranscoder/transcoder/StreamTranscoder.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/AvTranscoder/transcoder/StreamTranscoder.hpp b/src/AvTranscoder/transcoder/StreamTranscoder.hpp index bd7cbb4e..ab08c934 100644 --- a/src/AvTranscoder/transcoder/StreamTranscoder.hpp +++ b/src/AvTranscoder/transcoder/StreamTranscoder.hpp @@ -102,10 +102,6 @@ class AvExport StreamTranscoder */ void setOffset(const float offset); -private: - bool processRewrap(); - bool processTranscode(const int subStreamIndex = -1); ///< By default transcode all channels - //@{ // Get the current process case. enum EProcessCase @@ -117,6 +113,10 @@ class AvExport StreamTranscoder EProcessCase getProcessCase() const; //@} +private: + bool processRewrap(); + bool processTranscode(const int subStreamIndex = -1); ///< By default transcode all channels + private: IInputStream* _inputStream; ///< Input stream to read next packet (has link, no ownership) IOutputStream* _outputStream; ///< Output stream to wrap next packet (has link, no ownership) From 88100b918a2b83a693d2dac33453f3f451764b69 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Wed, 6 Jan 2016 09:59:26 +0100 Subject: [PATCH 06/18] Transcoder: renamed method getOutputDuration to getExpectedOutputDuration --- src/AvTranscoder/transcoder/Transcoder.cpp | 14 +++++++------- src/AvTranscoder/transcoder/Transcoder.hpp | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/AvTranscoder/transcoder/Transcoder.cpp b/src/AvTranscoder/transcoder/Transcoder.cpp index cbe9a37d..42b62c8a 100644 --- a/src/AvTranscoder/transcoder/Transcoder.cpp +++ b/src/AvTranscoder/transcoder/Transcoder.cpp @@ -266,8 +266,8 @@ ProcessStat Transcoder::process(IProgress& progress) preProcessCodecLatency(); - const float outputDuration = getOutputDuration(); - LOG_INFO("Output duration of the process will be " << outputDuration << "s.") + const float expectedOutputDuration = getExpectedOutputDuration(); + LOG_INFO("Output duration of the process will be " << expectedOutputDuration << "s.") size_t frame = 0; bool frameProcessed = true; @@ -276,18 +276,18 @@ ProcessStat Transcoder::process(IProgress& progress) const float progressDuration = _outputFile.getStream(0).getStreamDuration(); // check if JobStatusCancel - if(progress.progress((progressDuration > outputDuration) ? outputDuration : progressDuration, outputDuration) == - eJobStatusCancel) + if(progress.progress((progressDuration > expectedOutputDuration) ? expectedOutputDuration : progressDuration, + expectedOutputDuration) == eJobStatusCancel) { LOG_INFO("End of process because the job was canceled.") break; } // check progressDuration - if(progressDuration >= outputDuration) + if(progressDuration >= expectedOutputDuration) { LOG_INFO("End of process because the output program duration (" - << progressDuration << "s) is equal or upper than " << outputDuration << "s.") + << progressDuration << "s) is equal or upper than " << expectedOutputDuration << "s.") break; } @@ -507,7 +507,7 @@ float Transcoder::getMaxTotalDuration() const return maxTotalDuration; } -float Transcoder::getOutputDuration() const +float Transcoder::getExpectedOutputDuration() const { switch(_eProcessMethod) { diff --git a/src/AvTranscoder/transcoder/Transcoder.hpp b/src/AvTranscoder/transcoder/Transcoder.hpp index fac968df..9377a11f 100644 --- a/src/AvTranscoder/transcoder/Transcoder.hpp +++ b/src/AvTranscoder/transcoder/Transcoder.hpp @@ -207,10 +207,10 @@ class AvExport Transcoder float getMaxTotalDuration() const; /** - * @brief Get the duration of the output program + * @brief Get the expected duration of the output program * @note Depends on the streams, the process method, and the main stream index. */ - float getOutputDuration() const; + float getExpectedOutputDuration() const; /** * @brief Set for each StreamTranscoder if it can switch to generator at the end. From ec7a310d7c3d8dbebd42eece46c7403d2d679253 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Wed, 6 Jan 2016 10:00:12 +0100 Subject: [PATCH 07/18] StreamTranscoder: getTransform method returns a pointer instead of a reference Because the _transform attribute could be NULL. --- src/AvTranscoder/transcoder/StreamTranscoder.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AvTranscoder/transcoder/StreamTranscoder.hpp b/src/AvTranscoder/transcoder/StreamTranscoder.hpp index ab08c934..9600caf8 100644 --- a/src/AvTranscoder/transcoder/StreamTranscoder.hpp +++ b/src/AvTranscoder/transcoder/StreamTranscoder.hpp @@ -77,7 +77,7 @@ class AvExport StreamTranscoder IEncoder* getEncoder() const { return _outputEncoder; } /// Returns a reference to the object which transforms the decoded data - ITransform& getTransform() const { return *_transform; } + ITransform* getTransform() const { return _transform; } /// Returns a reference to the stream which unwraps data IInputStream* getInputStream() const { return _inputStream; } From 450b3381a99ce7b381ac82fb5486c9e708aa3be3 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Wed, 6 Jan 2016 10:43:35 +0100 Subject: [PATCH 08/18] Transcoder: fixed how to get the progressDuration during a process Added getCurrentOutputDuration private method. --- src/AvTranscoder/transcoder/Transcoder.cpp | 16 +++++++++++++++- src/AvTranscoder/transcoder/Transcoder.hpp | 7 +++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/AvTranscoder/transcoder/Transcoder.cpp b/src/AvTranscoder/transcoder/Transcoder.cpp index 42b62c8a..d646bd1e 100644 --- a/src/AvTranscoder/transcoder/Transcoder.cpp +++ b/src/AvTranscoder/transcoder/Transcoder.cpp @@ -273,7 +273,7 @@ ProcessStat Transcoder::process(IProgress& progress) bool frameProcessed = true; while(frameProcessed) { - const float progressDuration = _outputFile.getStream(0).getStreamDuration(); + const float progressDuration = getCurrentOutputDuration(); // check if JobStatusCancel if(progress.progress((progressDuration > expectedOutputDuration) ? expectedOutputDuration : progressDuration, @@ -526,6 +526,20 @@ float Transcoder::getExpectedOutputDuration() const } } +float Transcoder::getCurrentOutputDuration() const +{ + float currentOutputDuration = -1; + for(size_t streamIndex = 0; streamIndex < _streamTranscoders.size(); ++streamIndex) + { + const float currentStreamDuration = _outputFile.getStream(streamIndex).getStreamDuration(); + if(currentOutputDuration == -1) + currentOutputDuration = currentStreamDuration; + else if(currentStreamDuration < currentOutputDuration) + currentOutputDuration = currentStreamDuration; + } + return currentOutputDuration; +} + void Transcoder::manageSwitchToGenerator() { for(size_t i = 0; i < _streamTranscoders.size(); ++i) diff --git a/src/AvTranscoder/transcoder/Transcoder.hpp b/src/AvTranscoder/transcoder/Transcoder.hpp index 9377a11f..a38d7e46 100644 --- a/src/AvTranscoder/transcoder/Transcoder.hpp +++ b/src/AvTranscoder/transcoder/Transcoder.hpp @@ -212,6 +212,13 @@ class AvExport Transcoder */ float getExpectedOutputDuration() const; + /** + * @brief Get the current duration of the output program + * @note Returns the duration of the smallest stream. + * @return -1 if there is no output stream. + */ + float getCurrentOutputDuration() const; + /** * @brief Set for each StreamTranscoder if it can switch to generator at the end. */ From 0350adebcaf11a55e3c6e4770f9bdf49c9c7b660 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Wed, 6 Jan 2016 10:46:36 +0100 Subject: [PATCH 09/18] Transcoder: fixed how to process a frame for each stream * Try to process a new frame for each stream (do not exit the method if a stream failed to process). * Skip the generated streams because they always succeed. --- src/AvTranscoder/transcoder/Transcoder.cpp | 24 ++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/AvTranscoder/transcoder/Transcoder.cpp b/src/AvTranscoder/transcoder/Transcoder.cpp index d646bd1e..29cb4f22 100644 --- a/src/AvTranscoder/transcoder/Transcoder.cpp +++ b/src/AvTranscoder/transcoder/Transcoder.cpp @@ -234,16 +234,32 @@ bool Transcoder::processFrame() if(_streamTranscoders.size() == 0) return false; + // For each stream, process a frame + size_t nbStreamProcessStatusFailed = 0; for(size_t streamIndex = 0; streamIndex < _streamTranscoders.size(); ++streamIndex) { LOG_DEBUG("Process stream " << streamIndex << "/" << (_streamTranscoders.size() - 1)) - - bool streamProcessStatus = _streamTranscoders.at(streamIndex)->processFrame(); - if(!streamProcessStatus) + if(!_streamTranscoders.at(streamIndex)->processFrame()) { - return false; + LOG_WARN("Failed to process stream " << streamIndex) + ++nbStreamProcessStatusFailed; } } + + // Get the number of streams without the generators (they always succeed) + size_t nbStreamsWithoutGenerator = _streamTranscoders.size(); + for(size_t streamIndex = 0; streamIndex < _streamTranscoders.size(); ++streamIndex) + { + if(_streamTranscoders.at(streamIndex)->getProcessCase() == StreamTranscoder::eProcessCaseGenerator) + --nbStreamsWithoutGenerator; + } + + // If all streams failed to process a new frame + if(nbStreamsWithoutGenerator != 0 && nbStreamsWithoutGenerator == nbStreamProcessStatusFailed) + { + LOG_INFO("End of process because all streams (except generators) failed to process a new frame.") + return false; + } return true; } From 5190623c6e1d3c7af93f1fca10f2f9192408b33d Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Wed, 6 Jan 2016 10:52:13 +0100 Subject: [PATCH 10/18] transcoder: fix formatting --- src/AvTranscoder/transcoder/StreamTranscoder.hpp | 2 +- src/AvTranscoder/transcoder/Transcoder.cpp | 7 ++++--- src/AvTranscoder/transcoder/Transcoder.hpp | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/AvTranscoder/transcoder/StreamTranscoder.hpp b/src/AvTranscoder/transcoder/StreamTranscoder.hpp index 9600caf8..1bdc45c8 100644 --- a/src/AvTranscoder/transcoder/StreamTranscoder.hpp +++ b/src/AvTranscoder/transcoder/StreamTranscoder.hpp @@ -136,7 +136,7 @@ class AvExport StreamTranscoder float _offset; ///< Offset, in seconds, at the beginning of the StreamTranscoder. bool _needToSwitchToGenerator; ///< Set if need to switch to a generator during the process (because, of other streams - ///duration, or an offset) + /// duration, or an offset) }; } diff --git a/src/AvTranscoder/transcoder/Transcoder.cpp b/src/AvTranscoder/transcoder/Transcoder.cpp index 29cb4f22..aabacc76 100644 --- a/src/AvTranscoder/transcoder/Transcoder.cpp +++ b/src/AvTranscoder/transcoder/Transcoder.cpp @@ -599,9 +599,10 @@ void Transcoder::fillProcessStat(ProcessStat& processStat) for(size_t streamIndex = 0; streamIndex < _streamTranscoders.size(); ++streamIndex) { IOutputStream& stream = _streamTranscoders.at(streamIndex)->getOutputStream(); - const IInputStream* inputStream = _streamTranscoders.at( streamIndex )->getInputStream(); - if(inputStream == NULL) { - LOG_WARN( "Cannot process statistics of generated stream." ) + const IInputStream* inputStream = _streamTranscoders.at(streamIndex)->getInputStream(); + if(inputStream == NULL) + { + LOG_WARN("Cannot process statistics of generated stream.") continue; } const AVMediaType mediaType = inputStream->getProperties().getStreamType(); diff --git a/src/AvTranscoder/transcoder/Transcoder.hpp b/src/AvTranscoder/transcoder/Transcoder.hpp index a38d7e46..289db061 100644 --- a/src/AvTranscoder/transcoder/Transcoder.hpp +++ b/src/AvTranscoder/transcoder/Transcoder.hpp @@ -236,13 +236,13 @@ class AvExport Transcoder std::vector _streamTranscoders; ///< All streams of the output media file after process. std::vector _streamTranscodersAllocated; ///< Streams allocated inside the Transcoder (has ownership) - ProfileLoader _profileLoader; ///< Objet to get existing profiles, and add new ones for the Transcoder. + ProfileLoader _profileLoader; ///< Objet to get existing profiles, and add new ones for the Transcoder. EProcessMethod _eProcessMethod; ///< Processing policy size_t _mainStreamIndex; ///< Index of stream used to stop the process of transcode in case of eProcessMethodBasedOnStream. float _outputDuration; ///< Duration of output media used to stop the process of transcode in case of - ///eProcessMethodBasedOnDuration. + /// eProcessMethodBasedOnDuration. }; } From 6080702829e29a978db933f30c17cc6d2c7db761 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Wed, 6 Jan 2016 10:57:24 +0100 Subject: [PATCH 11/18] Transcoder: updated log to check expected output duration --- src/AvTranscoder/transcoder/Transcoder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AvTranscoder/transcoder/Transcoder.cpp b/src/AvTranscoder/transcoder/Transcoder.cpp index aabacc76..2e731d9b 100644 --- a/src/AvTranscoder/transcoder/Transcoder.cpp +++ b/src/AvTranscoder/transcoder/Transcoder.cpp @@ -283,7 +283,7 @@ ProcessStat Transcoder::process(IProgress& progress) preProcessCodecLatency(); const float expectedOutputDuration = getExpectedOutputDuration(); - LOG_INFO("Output duration of the process will be " << expectedOutputDuration << "s.") + LOG_INFO("The expected output duration of the program will be " << expectedOutputDuration << "s.") size_t frame = 0; bool frameProcessed = true; From 9059962cdbe40bee07d47c27957b9fcfc5e26bd6 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Wed, 6 Jan 2016 10:58:00 +0100 Subject: [PATCH 12/18] StreamTranscoder: removed unsued log The same log exists in switchToGeneratorDecoder method. --- src/AvTranscoder/transcoder/StreamTranscoder.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/AvTranscoder/transcoder/StreamTranscoder.cpp b/src/AvTranscoder/transcoder/StreamTranscoder.cpp index 8c89eafa..667119af 100644 --- a/src/AvTranscoder/transcoder/StreamTranscoder.cpp +++ b/src/AvTranscoder/transcoder/StreamTranscoder.cpp @@ -363,7 +363,6 @@ bool StreamTranscoder::processFrame() // process generator if(_currentDecoder != _generator) { - LOG_INFO("Switch to generator to process offset") switchToGeneratorDecoder(); } } From 689c76fbc568192f80abdd343eed9d4026374d61 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Wed, 6 Jan 2016 10:59:45 +0100 Subject: [PATCH 13/18] StreamTranscoder: do not throw if a stream needs to switch to a generator but cannot No generator will be used for this stream, but the process is not stopped. --- src/AvTranscoder/transcoder/StreamTranscoder.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/AvTranscoder/transcoder/StreamTranscoder.cpp b/src/AvTranscoder/transcoder/StreamTranscoder.cpp index 667119af..a6743180 100644 --- a/src/AvTranscoder/transcoder/StreamTranscoder.cpp +++ b/src/AvTranscoder/transcoder/StreamTranscoder.cpp @@ -530,9 +530,10 @@ void StreamTranscoder::needToSwitchToGenerator(const bool needToSwitch) if(needToSwitch && !canSwitchToGenerator()) { std::stringstream os; - os << "The stream " << _inputStream->getStreamIndex() << " has a duration of " << getDuration() - << "s. It needs to switch to a generator during the process, but it cannot."; - throw std::runtime_error(os.str()); + LOG_WARN("The stream " << _inputStream->getStreamIndex() << " has a duration of " << getDuration() + << "s. It needs to switch to a generator during the process, but it cannot. " + << "No generator will be used for this stream.") + return; } _needToSwitchToGenerator = needToSwitch; } From 24ecd8a52a96897cbb5caf911a839a4f973504a4 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Wed, 6 Jan 2016 11:00:49 +0100 Subject: [PATCH 14/18] Transcoder: default process method is the longest stream --- src/AvTranscoder/transcoder/Transcoder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AvTranscoder/transcoder/Transcoder.cpp b/src/AvTranscoder/transcoder/Transcoder.cpp index 2e731d9b..5046b990 100644 --- a/src/AvTranscoder/transcoder/Transcoder.cpp +++ b/src/AvTranscoder/transcoder/Transcoder.cpp @@ -16,7 +16,7 @@ Transcoder::Transcoder(IOutputFile& outputFile) , _streamTranscoders() , _streamTranscodersAllocated() , _profileLoader(true) - , _eProcessMethod(eProcessMethodBasedOnStream) + , _eProcessMethod(eProcessMethodLongest) , _mainStreamIndex(0) , _outputDuration(0) { From 5f10588da805529baab088d034d38fec9eb9a254 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Wed, 6 Jan 2016 11:01:24 +0100 Subject: [PATCH 15/18] pyTest: check all streams of testAddAllStreamsOfAGivenFile --- test/pyTest/testTranscoderAdd.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/pyTest/testTranscoderAdd.py b/test/pyTest/testTranscoderAdd.py index b0ab31db..50a2c9ac 100644 --- a/test/pyTest/testTranscoderAdd.py +++ b/test/pyTest/testTranscoderAdd.py @@ -86,8 +86,5 @@ def testAddAllStreamsOfAGivenFile(): import testTranscoderRewrap # for each stream for src_stream, dst_stream in zip(src_streams_properties, dst_streams_properties): - # FIXME: analyse only the first stream because all the input audio data are not read - if src_stream.getStreamId() != 1: - continue # check properties testTranscoderRewrap.checkStream(src_stream, dst_stream) From 55fb7e5785d2b68c5f327f7858890665ea63c774 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Wed, 6 Jan 2016 16:22:44 +0100 Subject: [PATCH 16/18] pyTest: updated how to check output duration when testEProcessMethods * Need to check if duration of all output streams are almost equals to the expected value. But we cannot ensure to have the exact value for all streams (it may not be possible depending on the fps/rate of input streams). * And the result vary depending on the ffmpeg version. --- test/pyTest/testEProcessMethod.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/pyTest/testEProcessMethod.py b/test/pyTest/testEProcessMethod.py index 2a431120..4fee610f 100644 --- a/test/pyTest/testEProcessMethod.py +++ b/test/pyTest/testEProcessMethod.py @@ -41,7 +41,8 @@ def testEProcessMethodShortest(): dst_inputFile = av.InputFile( outputFileName ) dst_properties = dst_inputFile.getProperties() - assert_equals( dst_properties.getDuration(), src_properties_shortest.getDuration() ) + for dst_stream_properties in dst_properties.getStreamProperties(): + assert_almost_equals( dst_stream_properties.getDuration(), src_properties_shortest.getDuration(), delta=0.05 ) def testEProcessMethodLongest(): @@ -70,7 +71,8 @@ def testEProcessMethodLongest(): dst_inputFile = av.InputFile( outputFileName ) dst_properties = dst_inputFile.getProperties() - assert_equals( dst_properties.getDuration(), src_properties_longest.getDuration() ) + for dst_stream_properties in dst_properties.getStreamProperties(): + assert_almost_equals( dst_stream_properties.getDuration(), src_properties_longest.getDuration(), delta=0.05 ) def testEProcessMethodBasedOnStream(): @@ -130,5 +132,6 @@ def testEProcessMethodBasedOnDuration(): dst_inputFile = av.InputFile( outputFileName ) dst_properties = dst_inputFile.getProperties() - assert_equals( dst_properties.getDuration(), outputDuration ) + for dst_stream_properties in dst_properties.getStreamProperties(): + assert_almost_equals( dst_stream_properties.getDuration(), outputDuration, delta=0.05 ) From 2dc2b40885968c85da6e4bd82d2d9978fc8e32c8 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Wed, 6 Jan 2016 18:16:52 +0100 Subject: [PATCH 17/18] StreamTranscoder: added log to check the current process case for each frame --- .../transcoder/StreamTranscoder.cpp | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/AvTranscoder/transcoder/StreamTranscoder.cpp b/src/AvTranscoder/transcoder/StreamTranscoder.cpp index a6743180..4471d813 100644 --- a/src/AvTranscoder/transcoder/StreamTranscoder.cpp +++ b/src/AvTranscoder/transcoder/StreamTranscoder.cpp @@ -341,7 +341,23 @@ void StreamTranscoder::preProcessCodecLatency() bool StreamTranscoder::processFrame() { - if(getProcessCase() == eProcessCaseGenerator) + const EProcessCase processCase = getProcessCase(); + std::string msg = "Current process case of the stream is a "; + switch(processCase) + { + case eProcessCaseTranscode: + msg += "transcode."; + break; + case eProcessCaseRewrap: + msg += "rewrap."; + break; + case eProcessCaseGenerator: + msg += "generator."; + break; + } + LOG_DEBUG(msg) + + if(processCase == eProcessCaseGenerator) return processTranscode(); // Manage offset @@ -380,7 +396,7 @@ bool StreamTranscoder::processFrame() } } - if(getProcessCase() == eProcessCaseRewrap) + if(processCase == eProcessCaseRewrap) return processRewrap(); return processTranscode(_subStreamIndex); From 08a2d240b5658197e81a4605180ee3f7a7e2b213 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Wed, 6 Jan 2016 18:18:28 +0100 Subject: [PATCH 18/18] StreamTranscoder: fixed preProcessCodecLatency in case of rewrap --- src/AvTranscoder/transcoder/StreamTranscoder.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/AvTranscoder/transcoder/StreamTranscoder.cpp b/src/AvTranscoder/transcoder/StreamTranscoder.cpp index 4471d813..5133e9bd 100644 --- a/src/AvTranscoder/transcoder/StreamTranscoder.cpp +++ b/src/AvTranscoder/transcoder/StreamTranscoder.cpp @@ -327,15 +327,19 @@ void StreamTranscoder::preProcessCodecLatency() return; // set a decoder to preload generated frames + bool wasARewrapCase = false; if(getProcessCase() == eProcessCaseRewrap) + { switchToGeneratorDecoder(); + wasARewrapCase = true; + } while((latency--) > 0) { processFrame(); } - if(getProcessCase() == eProcessCaseRewrap) + if(wasARewrapCase) _currentDecoder = NULL; } 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