AVCodecEncoder: Use new API
Change-Id: I5b985cebf241e67f901e93a5a4bb61a67a659cdf
This commit is contained in:
parent
247f2fb691
commit
c85dd27c9e
@ -700,20 +700,20 @@ AVCodecEncoder::_EncodeVideo(const void* buffer, int64 frameCount,
|
||||
fDstFrame.linesize);
|
||||
|
||||
// Encode one video chunk/frame.
|
||||
int gotPacket;
|
||||
int result = avcodec_send_frame(fCodecContext, fFrame);
|
||||
if (result != 0) {
|
||||
TRACE(" avcodec_send_frame() failed: %d\n", result);
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
// avcodec.h says we need to set it.
|
||||
fFrame->pts++;
|
||||
|
||||
AVPacket pkt;
|
||||
pkt.data = NULL;
|
||||
pkt.size = 0;
|
||||
av_init_packet(&pkt);
|
||||
int usedBytes = avcodec_encode_video2(fCodecContext, &pkt, fFrame, &gotPacket);
|
||||
// avcodec.h says we need to set it.
|
||||
fFrame->pts++;
|
||||
|
||||
if (usedBytes < 0) {
|
||||
TRACE(" avcodec_encode_video() failed: %d\n", usedBytes);
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
if (avcodec_receive_packet(fCodecContext, &pkt) == 0) {
|
||||
// Maybe we need to use this PTS to calculate start_time:
|
||||
if (pkt.pts != AV_NOPTS_VALUE) {
|
||||
TRACE(" codec frame PTS: %lld (codec time_base: %d/%d)\n",
|
||||
@ -724,7 +724,6 @@ AVCodecEncoder::_EncodeVideo(const void* buffer, int64 frameCount,
|
||||
fCodecContext->time_base.num, fCodecContext->time_base.den);
|
||||
}
|
||||
|
||||
if (gotPacket == 1) {
|
||||
// Setup media_encode_info, most important is the time stamp.
|
||||
info->start_time = (bigtime_t)(fFramesWritten * 1000000LL
|
||||
/ fInputFormat.u.raw_video.field_rate);
|
||||
|
Loading…
Reference in New Issue
Block a user