Re: [FFmpeg-devel] [PATCH] examples/transcoding: Fix time_base handling

2025-02-05 Thread Jack Lau
Hello. I found one better method to fix this issue. Firstly, i think the problem caused by incorrectly setting enc_ctx->time_base, so i refer to the implementation in avcodec_open2() 361 #if FF_API_AVCTX_TIMEBASE 362if (avctx->framerate.num > 0 && avctx->framerate.den > 0) 363

[FFmpeg-devel] [PATCH] examples/transcoding: Fix time_base handling

2025-02-05 Thread Jack Lau via ffmpeg-devel
From: Jack Lau The `dec_ctx->time_base` was incorrectly default set by avcodec_open2(), while `enc_ctx->time_base` was derived from `dec_ctx->framerate`. This mismatch could cause incorrect video duration in the output. This patch corrects the issue by adjusting the `enc_ctx->time_base` calcul

Re: [FFmpeg-devel] [PATCH] examples/transcoding: Fix time_base handling

2025-02-04 Thread Jack Lau
To be clear, i want to give an example, i use a 10s duration, 30fps video. The ifmt_ctx->streams[stream_index]->time_base is same as ofmt_ctx->streams[stream_index]->time_base after initializing. The stream->dec_ctx->time_base is default 0,60 but stream->enc_ctx->time_base is set to av_inv_q(dec_ct

Re: [FFmpeg-devel] [PATCH] examples/transcoding: Fix time_base handling

2025-02-04 Thread Jack Lau
> > AVCodecContext.time_base is not used for decoding. Thank you for your reply. I understand that time_base is not used during decoding, but the transcoding code calls av_packet_rescale_ts twice, once before decoding and once after encoding, as shown below: 540 if (filter_ctx[stream_

Re: [FFmpeg-devel] [PATCH] examples/transcoding: Fix time_base handling

2025-02-04 Thread Jack Lau
> > AVCodecContext.time_base is not used for decoding. Thank you for your reply. I understand that time_base is not used during decoding, but the transcoding code calls av_packet_rescale_ts twice, once before decoding and once after encoding, as shown below: 540 if (filter_ctx[stream_

[FFmpeg-devel] [PATCH] examples/transcoding: Fix time_base handling

2025-02-04 Thread Jack Lau
The `dec_ctx->time_base` was incorrectly default set to 0/60, while `enc_ctx->time_base` was derived from `dec_ctx->framerate`. This mismatch could cause incorrect video duration in the output. This patch aligns `enc_ctx->time_base` with `dec_ctx->time_base` to prevent rescaling issues and ens

Re: [FFmpeg-devel] [PATCH] examples/transcoding: Fix time_base handling

2025-02-04 Thread James Almer
From bfd5500a5448ad468d32994816e8a55c0d4a2428 Mon Sep 17 00:00:00 2001 From: Jack Lau Date: Tue, 4 Feb 2025 21:39:20 +0800 Subject: [PATCH] examples/transcoding: Fix time_base handling The `dec_ctx->time_base` was incorrectly default set to 0/60, while `enc_ctx->time_base` was derived from `dec

[FFmpeg-devel] [PATCH] examples/transcoding: Fix time_base handling

2025-02-04 Thread Jack Lau
fix-time-base-handling.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubs

[FFmpeg-devel] [PATCH] examples/transcoding: Fix time_base handling

2025-02-04 Thread Jack Lau
The `dec_ctx->time_base` was incorrectly default set to 0/60, while `enc_ctx->time_base` was derived from `dec_ctx->framerate`. This mismatch could cause incorrect video duration in the output. This patch aligns `enc_ctx->time_base` with `dec_ctx->time_base` to prevent rescaling issues and ensu

[FFmpeg-devel] [PATCH] examples/transcoding: Fix time_base handling

2025-02-04 Thread Jack Lau
The `dec_ctx->time_base` was incorrectly default set to 0/60, while `enc_ctx->time_base` was derived from `dec_ctx->framerate`. This mismatch could cause incorrect video duration in the output. This patch aligns `enc_ctx->time_base` with `dec_ctx->time_base` to prevent rescaling issues and ensure