Skip to content

Fix encoding of last frames #245

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 9 commits into from
Apr 22, 2016

Conversation

cchampet
Copy link
Member

@cchampet cchampet commented Apr 21, 2016

Related to this tuttleofx issue: tuttleofx/TuttleOFX#544
Will up to v0.9.4 after this PR.

Clement Champetier added 7 commits April 21, 2016 14:24
The AVPacket data attribut should be set to NULL: the encoder will
allocate it.
* Only the returned value of the avcodec function is needed.
* Indeed, the encoded process could be a success, without any data
encoded (end of process).
Add private method encode.
* Add a comment.
* Add const keyword.
Add private method encode.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 74.704% when pulling eb29b44 on cchampet:fix_encodingLastFrames into 14164d6 on avTranscoder:develop.

{
throw std::runtime_error("Encode audio frame error: avcodec encode audio frame - " +
getDescriptionFromErrorCode(ret));
}
return ret == 0 && gotPacket == 1;
Copy link
Member

Choose a reason for hiding this comment

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

The condition ret == 0 is not necessary here, because if it's false, you throw a runtime error (just before) !

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep: dea73ee

Clement Champetier added 2 commits April 22, 2016 14:51
Unecessary to check returned value of avcodec encode method twice.
#else
const int ret = avcodec_encode_audio(&avCodecContext, encodedData.data, encodedData.size, decodedData);
if(ret < 0)
{
throw std::runtime_error("Encode audio frame error: avcodec encode audio frame - " +
getDescriptionFromErrorCode(ret));
}
return ret == 0;
return true;
Copy link
Member

Choose a reason for hiding this comment

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

hm.. Shouldn't ret be more than 0 ? And wouldn't it be a bad value ?

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: https://ffmpeg.org/doxygen/2.7/group__lavc__encoding.html#gaf12a9da0d33f50ff406e03572fab4763
"""
Returns:
On error a negative value is returned, on success zero or the number of bytes used to encode the data read from the input buffer.
"""

Copy link
Member

Choose a reason for hiding this comment

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

Ah yes ! Okay !

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 74.704% when pulling cdf2697 on cchampet:fix_encodingLastFrames into 14164d6 on avTranscoder:develop.

@valnoel valnoel merged commit 0fe7c8a into avTranscoder:develop Apr 22, 2016
valnoel added a commit to valnoel/avTranscoder that referenced this pull request Jul 22, 2016
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