Skip to content

Fix: different frame size as inputs of the filter graph #303

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Sep 21, 2017

Conversation

valnoel
Copy link
Member

@valnoel valnoel commented Aug 31, 2017

In order to mux audio channels, AvTranscoder uses the amerge filter.
If, as inputs of the filter graph containing this amerge filter, we put frames with different sizes, the resulting frame size seems to be the minimum of the input frame size. This means that one or more output channels can have cut frames, changing the reading speed and generating clicks into the final audio stream.

Using the internal filter buffer, the output frame is ensured not to lose audio samples, solving the problem of speed and clicks.
However, the filter internal buffer is quiet limited and quickly overflowed, making the process crashing before the end of the program. So, using custom frame buffers before the filter graph inputs fixes this other problem.

Let the filter managing the output frame size, using its internal
frame buffer queue.
@valnoel valnoel changed the title Fix: different frame size as inputs of the filter graph [WIP] Fix: different frame size as inputs of the filter graph Sep 5, 2017
Valentin NOEL added 4 commits September 5, 2017 16:43
Used as frame buffers on the filter graph inputs.
For the moment, this first version only handles audio frames.
Returning frames with the same size as inputs of the graph,
avoiding to overflow the internal filter buffers.
If the input frames have the same size and the buffers are empty, bypass
to avoid useless data copies.
private:
void popFrame();

const AudioFrameDesc _audioFrameDesc;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that you have a compilation error because this attribute is const...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks! Now, it's fixed in 380f238

Valentin NOEL added 6 commits September 6, 2017 12:03
Add a new getAvailableFrameSize() private method
Add utility methods, documentation and logs into FilterGraph
and FrameBuffer classes
Avoid filling the filter graph buffers with wrong data frames.
Improve documentation into FilterGraph::FrameBuffer class.
Since video frames cannot be split, this filter graph buffers
will be specialized to audio frames.
Replace it by a simple AudioFrameBuffer vector empty() test, since
buffers are initialized only for audio frames (into the addInBuffer()
method)
And rename _inputAudioFramesBuffer attribute to _inputAudioFrameBuffers
@coveralls
Copy link

Coverage Status

Coverage decreased (-1.2%) to 76.929% when pulling 969c6c3 on valnoel:filter_inputMethod into 93961f4 on avTranscoder:develop.

Valentin NOEL added 4 commits September 8, 2017 10:43
Comparing the frame sizes in samples (instead of bytes)
Audio channels are extracted from different file format sources, to
stereo and 5.1 output audio streams.
@avTranscoder avTranscoder deleted a comment from coveralls Sep 8, 2017
@avTranscoder avTranscoder deleted a comment from coveralls Sep 8, 2017
@avTranscoder avTranscoder deleted a comment from coveralls Sep 8, 2017
@avTranscoder avTranscoder deleted a comment from coveralls Sep 8, 2017
@avTranscoder avTranscoder deleted a comment from coveralls Sep 8, 2017
@avTranscoder avTranscoder deleted a comment from coveralls Sep 8, 2017
@avTranscoder avTranscoder deleted a comment from coveralls Sep 8, 2017
@coveralls
Copy link

coveralls commented Sep 9, 2017

Coverage Status

Coverage decreased (-1.5%) to 76.616% when pulling 2dcdc1c on valnoel:filter_inputMethod into 93961f4 on avTranscoder:develop.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-1.5%) to 76.616% when pulling 2dcdc1c on valnoel:filter_inputMethod into 93961f4 on avTranscoder:develop.

@coveralls
Copy link

coveralls commented Sep 9, 2017

Coverage Status

Coverage increased (+0.5%) to 78.68% when pulling 343ef4e on valnoel:filter_inputMethod into 93961f4 on avTranscoder:develop.

1 similar comment
@coveralls
Copy link

coveralls commented Sep 9, 2017

Coverage Status

Coverage increased (+0.5%) to 78.68% when pulling 343ef4e on valnoel:filter_inputMethod into 93961f4 on avTranscoder:develop.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.5%) to 78.68% when pulling 343ef4e on valnoel:filter_inputMethod into 93961f4 on avTranscoder:develop.

@valnoel valnoel changed the title [WIP] Fix: different frame size as inputs of the filter graph Fix: different frame size as inputs of the filter graph Sep 11, 2017
@valnoel valnoel changed the title Fix: different frame size as inputs of the filter graph [WIP] Fix: different frame size as inputs of the filter graph Sep 11, 2017
Export AudioFrameBuffer class symbol for DLL
@valnoel valnoel changed the title [WIP] Fix: different frame size as inputs of the filter graph Fix: different frame size as inputs of the filter graph Sep 11, 2017
@coveralls
Copy link

coveralls commented Sep 11, 2017

Coverage Status

Coverage increased (+0.5%) to 78.68% when pulling a26bae9 on valnoel:filter_inputMethod into 93961f4 on avTranscoder:develop.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.5%) to 78.68% when pulling a26bae9 on valnoel:filter_inputMethod into 93961f4 on avTranscoder:develop.

dst_inputFile = av.InputFile(outputFileName)
dst_audioProperties = dst_inputFile.getProperties().getAudioProperties()
assert_equals(1, len(dst_audioProperties))
assert_equals(2, dst_audioProperties[0].getNbChannels())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you check the duration of the output stream?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it was already done using the process statistics, but it is indeed better using the output file properties: 9abcb90

dst_inputFile = av.InputFile(outputFileName)
dst_audioProperties = dst_inputFile.getProperties().getAudioProperties()
assert_equals(1, len(dst_audioProperties))
assert_equals(6, dst_audioProperties[0].getNbChannels())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you check the duration of the output stream?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duration check using the output file properties: 9abcb90

if(!_filterGraph->hasFilters() || !_filterGraph->hasBufferedFrames(index))
{
continueProcess = false;
continue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you consider to user break instead of continue? Because in this case, do we need to continue to get the remaining buffers in the filter graph?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, it is better! See 0e49751

@coveralls
Copy link

coveralls commented Sep 20, 2017

Coverage Status

Coverage increased (+0.5%) to 78.68% when pulling 0e49751 on valnoel:filter_inputMethod into 93961f4 on avTranscoder:develop.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.5%) to 78.68% when pulling 0e49751 on valnoel:filter_inputMethod into 93961f4 on avTranscoder:develop.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.5%) to 78.68% when pulling 0e49751 on valnoel:filter_inputMethod into 93961f4 on avTranscoder:develop.

@valnoel
Copy link
Member Author

valnoel commented Sep 21, 2017

@cchampet RTM?


// Concatenate frames data
size_t extractedDataSize = 0;
unsigned char* outputData = new unsigned char[size];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this type mean that the supported data type is only 1byte per sample?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it is actually the raw data in bytes, without considering the sample format or whatever.

@cchampet
Copy link
Member

@valnoel I had only one question.
Except that, you can merge whenever you want ;)

@valnoel
Copy link
Member Author

valnoel commented Sep 21, 2017

@cchampet OK then! :)

@valnoel valnoel merged commit d33ffd2 into avTranscoder:develop Sep 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants