- if (pkt_copy.stream_index == 0) {
- pkt_copy.pts = av_rescale_q(pts, timebase, avstream_video->time_base);
- pkt_copy.dts = av_rescale_q(dts, timebase, avstream_video->time_base);
- pkt_copy.duration = av_rescale_q(pkt.duration, timebase, avstream_video->time_base);
- } else if (pkt_copy.stream_index == 1) {
- pkt_copy.pts = av_rescale_q(pts, timebase, avstream_audio->time_base);
- pkt_copy.dts = av_rescale_q(dts, timebase, avstream_audio->time_base);
- pkt_copy.duration = av_rescale_q(pkt.duration, timebase, avstream_audio->time_base);
- } else {
- assert(false);
- }
+ assert(size_t(pkt_copy.stream_index) < streams.size());
+ AVRational time_base = streams[pkt_copy.stream_index]->time_base;
+ pkt_copy.pts = av_rescale_q(pts, timebase, time_base);
+ pkt_copy.dts = av_rescale_q(dts, timebase, time_base);
+ pkt_copy.duration = av_rescale_q(pkt.duration, timebase, time_base);