-
Notifications
You must be signed in to change notification settings - Fork 50
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
Fix encoding of last frames #245
Conversation
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.
Override in avcodec encoded method.
{ | ||
throw std::runtime_error("Encode audio frame error: avcodec encode audio frame - " + | ||
getDescriptionFromErrorCode(ret)); | ||
} | ||
return ret == 0 && gotPacket == 1; |
There was a problem hiding this comment.
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) !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep: dea73ee
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; |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
"""
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes ! Okay !
…ation Fix output stream duration
Related to this tuttleofx issue: tuttleofx/TuttleOFX#544
Will up to v0.9.4 after this PR.