Codec timebase is not well-defined for streamcopy, so it should only be used as the last resort.
Unified · Split
| @@ -3151,8 +3151,12 @@ static int init_output_stream_streamcopy(OutputStream *ost) · 3150 unmodified lines | |||
| 3151 | return ret; | 3151 | return ret; |
| 3152 | 3152 | ||
| 3153 | // copy timebase while removing common factors | 3153 | // copy timebase while removing common factors |
| 3154 | if (ost->st->time_base.num <= 0 || ost->st->time_base.den <= 0) | 3154 | if (ost->st->time_base.num <= 0 || ost->st->time_base.den <= 0) { |
| 3155 | ost->st->time_base = av_add_q(av_stream_get_codec_timebase(ost->st), (AVRational){0, 1}); | 3155 | if (ost->frame_rate.num) |
| 3156 | ost->st->time_base = av_inv_q(ost->frame_rate); | ||
| 3157 | else | ||
| 3158 | ost->st->time_base = av_add_q(av_stream_get_codec_timebase(ost->st), (AVRational){0, 1}); | ||
| 3159 | } | ||
| 3156 | 3160 | ||
| 3157 | // copy estimated duration as a hint to the muxer | 3161 | // copy estimated duration as a hint to the muxer |
| 3158 | if (ost->st->duration <= 0 && ist->st->duration > 0) | 3162 | if (ost->st->duration <= 0 && ist->st->duration > 0) |