mirror of
https://github.com/k4yt3x/video2x.git
synced 2026-02-12 08:12:24 +08:00
fix(encoder): timestamp errors processing frames with PTS equal to 0
Signed-off-by: k4yt3x <i@k4yt3x.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <cstdint>
|
||||
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
@@ -202,11 +203,17 @@ int write_frame(
|
||||
AVFrame *frame,
|
||||
AVCodecContext *enc_ctx,
|
||||
AVFormatContext *ofmt_ctx,
|
||||
int out_vstream_idx
|
||||
int out_vstream_idx,
|
||||
int64_t frame_idx
|
||||
) {
|
||||
AVFrame *converted_frame = nullptr;
|
||||
int ret;
|
||||
|
||||
// Set the frame's presentation timestamp if not set
|
||||
if (frame->pts <= 0) {
|
||||
frame->pts = frame_idx;
|
||||
}
|
||||
|
||||
// Convert the frame to the encoder's pixel format if needed
|
||||
if (frame->format != enc_ctx->pix_fmt) {
|
||||
converted_frame = convert_avframe_pix_fmt(frame, enc_ctx->pix_fmt);
|
||||
|
||||
Reference in New Issue
Block a user