ACTUALLY fixed urgent sequence deletion bug

This commit is contained in:
itsmattkc
2018-11-05 20:07:43 +11:00
parent e342294917
commit 72fe20d857
9 changed files with 70 additions and 27 deletions
+14 -9
View File
@@ -195,21 +195,26 @@ void PreviewGenerator::generate_waveform() {
codec_ctx[i] = NULL;
if (fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
AVCodec* codec = avcodec_find_decoder(fmt_ctx->streams[i]->codecpar->codec_id);
codec_ctx[i] = avcodec_alloc_context3(codec);
avcodec_parameters_to_context(codec_ctx[i], fmt_ctx->streams[i]->codecpar);
avcodec_open2(codec_ctx[i], codec, NULL);
if (fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && codec_ctx[i]->channel_layout == 0) {
codec_ctx[i]->channel_layout = av_get_default_channel_layout(fmt_ctx->streams[i]->codecpar->channels);
}
if (codec != NULL) {
codec_ctx[i] = avcodec_alloc_context3(codec);
avcodec_parameters_to_context(codec_ctx[i], fmt_ctx->streams[i]->codecpar);
avcodec_open2(codec_ctx[i], codec, NULL);
if (fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && codec_ctx[i]->channel_layout == 0) {
codec_ctx[i]->channel_layout = av_get_default_channel_layout(fmt_ctx->streams[i]->codecpar->channels);
}
}
}
}
}
AVPacket* packet = av_packet_alloc();
bool done = true;
bool end_of_file = false;
// get the ball rolling
av_read_frame(fmt_ctx, packet);
// get the ball rolling
do {
av_read_frame(fmt_ctx, packet);
} while (codec_ctx[packet->stream_index] == NULL);
avcodec_send_packet(codec_ctx[packet->stream_index], packet);
while (!end_of_file) {