AVCodecEncoder: Skip frames
* Fix garbage put into videos while encoding. * Testing welcome. * Various fixes are still waiting to be merged into Haiku. * Fixes sponsored by the V\OS project.
This commit is contained in:
@@ -723,28 +723,28 @@ AVCodecEncoder::_EncodeVideo(const void* buffer, int64 frameCount,
|
|||||||
fCodecContext->time_base.num, fCodecContext->time_base.den);
|
fCodecContext->time_base.num, fCodecContext->time_base.den);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup media_encode_info, most important is the time stamp.
|
if (gotPacket == 1) {
|
||||||
info->start_time = (bigtime_t)(fFramesWritten * 1000000LL
|
// Setup media_encode_info, most important is the time stamp.
|
||||||
/ fInputFormat.u.raw_video.field_rate);
|
info->start_time = (bigtime_t)(fFramesWritten * 1000000LL
|
||||||
|
/ fInputFormat.u.raw_video.field_rate);
|
||||||
|
|
||||||
info->flags = 0;
|
info->flags = 0;
|
||||||
if (fCodecContext->coded_frame->key_frame)
|
if (fCodecContext->coded_frame->key_frame)
|
||||||
info->flags |= B_MEDIA_KEY_FRAME;
|
info->flags |= B_MEDIA_KEY_FRAME;
|
||||||
|
|
||||||
// Write the chunk
|
// Write the chunk
|
||||||
ret = WriteChunk(pkt.data, pkt.size, info);
|
ret = WriteChunk(pkt.data, pkt.size, info);
|
||||||
if (ret != B_OK) {
|
if (ret != B_OK) {
|
||||||
TRACE(" error writing chunk: %s\n", strerror(ret));
|
TRACE(" error writing chunk: %s\n", strerror(ret));
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip to the next frame (but usually, there is only one to encode
|
// Skip to the next frame (but usually, there is only one to encode
|
||||||
// for video).
|
// for video).
|
||||||
frameCount--;
|
frameCount--;
|
||||||
fFramesWritten++;
|
fFramesWritten++;
|
||||||
buffer = (const void*)((const uint8*)buffer + bufferSize);
|
buffer = (const void*)((const uint8*)buffer + bufferSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user