Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix: compensate codec latency in positive offset#320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion.gitignore
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,8 +12,10 @@
*.la
*.a

build
build*
dist
install*
test/**/test*[.wav|.avi|.mov|.h264|.mxf]

# CMake
CMakeCache.txt
Expand Down
4 changes: 4 additions & 0 deletionssrc/AvTranscoder/decoder/AudioDecoder.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -121,6 +121,10 @@ bool AudioDecoder::decodeNextFrame(IFrame& frameBuffer)
return false;
}
}

if(decodeNextFrame)
incrementNbDecodedFrames(frameBuffer.getAVFrame().nb_samples);

return decodeNextFrame;
}

Expand Down
2 changes: 2 additions & 0 deletionssrc/AvTranscoder/decoder/AudioGenerator.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -58,6 +58,8 @@ bool AudioGenerator::decodeNextFrame(IFrame& frameBuffer)
LOG_DEBUG("Convert data of the audio specified when decode next frame")
_audioTransform.convert(*_inputFrame, frameBuffer);
}

incrementNbDecodedFrames(_silent->getNbSamplesPerChannel());
return true;
}

Expand Down
16 changes: 16 additions & 0 deletionssrc/AvTranscoder/decoder/IDecoder.hpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,6 +10,12 @@ namespace avtranscoder

class AvExport IDecoder
{
protected:
IDecoder()
: _decoded_frames_counter(0)
{
}

public:
virtual ~IDecoder(){};

Expand DownExpand Up@@ -51,6 +57,16 @@ class AvExport IDecoder
* @note Not sense for generators.
*/
virtual void flushDecoder() {}

size_t getNbDecodedFrames() { return _decoded_frames_counter; }

protected:
void incrementNbDecodedFrames(const size_t& nb_frames = 1) {
_decoded_frames_counter += nb_frames;
}

private:
size_t _decoded_frames_counter;
};
}

Expand Down
4 changes: 4 additions & 0 deletionssrc/AvTranscoder/decoder/VideoDecoder.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -114,6 +114,10 @@ bool VideoDecoder::decodeNextFrame(IFrame& frameBuffer)
return false;
}
}

if(decodeNextFrame)
incrementNbDecodedFrames();

return decodeNextFrame;
}

Expand Down
2 changes: 2 additions & 0 deletionssrc/AvTranscoder/decoder/VideoGenerator.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,6 +51,8 @@ bool VideoGenerator::decodeNextFrame(IFrame& frameBuffer)
LOG_DEBUG("Convert data of the image specified when decode next frame")
_videoTransform.convert(*_inputFrame, frameBuffer);
}

incrementNbDecodedFrames();
return true;
}

Expand Down
32 changes: 29 additions & 3 deletionssrc/AvTranscoder/transcoder/StreamTranscoder.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -617,7 +617,20 @@ bool StreamTranscoder::processFrame()
// Manage offset
if(_offset > 0)
{
const bool endOfOffset = _outputStream->getStreamDuration() >= _offset;
bool endOfOffset = false;
if(_currentDecoder == _generators.at(0))
{
const double fps = 1.0 * _outputEncoder->getCodec().getAVCodecContext().time_base.den /
(_outputEncoder->getCodec().getAVCodecContext().time_base.num * _outputEncoder->getCodec().getAVCodecContext().ticks_per_frame);
const double frame_duration = 1.0 / fps;
const double generated_duration = _currentDecoder->getNbDecodedFrames() * frame_duration;
endOfOffset = generated_duration >= _offset;
}
else
{
endOfOffset = _outputStream->getStreamDuration() >= _offset;
}

if(endOfOffset)
{
LOG_INFO("End of positive offset")
Expand DownExpand Up@@ -704,6 +717,7 @@ bool StreamTranscoder::processTranscode()
assert(_outputEncoder != NULL);
assert(! _decodedData.empty());
assert(_transform != NULL);
assert(_generators.size() == _inputDecoders.size());

LOG_DEBUG("StreamTranscoder::processTranscode")

Expand DownExpand Up@@ -750,8 +764,7 @@ bool StreamTranscoder::processTranscode()
}
}

// Transform
CodedData data;
// Check decoding status
bool continueProcess = true;
for(size_t index = 0; index < decodingStatus.size(); ++index)
{
Expand All@@ -760,6 +773,17 @@ bool StreamTranscoder::processTranscode()
if(!_filterGraph->hasFilters() || !_filterGraph->hasBufferedFrames(index))
{
continueProcess = false;
if(_needToSwitchToGenerator)
{
switchToGeneratorDecoder();
LOG_INFO("Force reallocation of the decoded data buffers since the decoders could have cleared them.")
for(std::vector<IFrame*>::iterator it = _decodedData.begin(); it != _decodedData.end(); ++it)
{
if(! (*it)->isDataAllocated())
(*it)->allocateData();
}
return processTranscode();
}
break;
}
LOG_DEBUG("Some frames remain into filter graph buffer " << index);
Expand All@@ -771,8 +795,10 @@ bool StreamTranscoder::processTranscode()
}
}

CodedData data;
if(continueProcess)
{
// Transform
IFrame* dataToTransform = NULL;
if(_filterGraph->hasFilters())
{
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp