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` calculation to account for `ticks_per_frame`, ensuring that the time base is consistent between the decoder and encoder contexts.