mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-03-17 20:17:55 +02:00
Merge commit '452860d7e056f9a894cac2fe52cdedeae4c38251'
* commit '452860d7e056f9a894cac2fe52cdedeae4c38251': Use av_packet_rescale_ts() to simplify code. Conflicts: doc/examples/muxing.c ffmpeg.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
afa7ab557a
@ -63,9 +63,7 @@ static void log_packet(const AVFormatContext *fmt_ctx, const AVPacket *pkt)
|
||||
static int write_frame(AVFormatContext *fmt_ctx, const AVRational *time_base, AVStream *st, AVPacket *pkt)
|
||||
{
|
||||
/* rescale output packet timestamp values from codec to stream timebase */
|
||||
pkt->pts = av_rescale_q_rnd(pkt->pts, *time_base, st->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
|
||||
pkt->dts = av_rescale_q_rnd(pkt->dts, *time_base, st->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
|
||||
pkt->duration = av_rescale_q(pkt->duration, *time_base, st->time_base);
|
||||
av_packet_rescale_ts(pkt, *time_base, st->time_base);
|
||||
pkt->stream_index = st->index;
|
||||
|
||||
/* Write the compressed frame to the media file. */
|
||||
|
19
ffmpeg.c
19
ffmpeg.c
@ -755,12 +755,7 @@ static void do_audio_out(AVFormatContext *s, OutputStream *ost,
|
||||
update_benchmark("encode_audio %d.%d", ost->file_index, ost->index);
|
||||
|
||||
if (got_packet) {
|
||||
if (pkt.pts != AV_NOPTS_VALUE)
|
||||
pkt.pts = av_rescale_q(pkt.pts, enc->time_base, ost->st->time_base);
|
||||
if (pkt.dts != AV_NOPTS_VALUE)
|
||||
pkt.dts = av_rescale_q(pkt.dts, enc->time_base, ost->st->time_base);
|
||||
if (pkt.duration > 0)
|
||||
pkt.duration = av_rescale_q(pkt.duration, enc->time_base, ost->st->time_base);
|
||||
av_packet_rescale_ts(&pkt, enc->time_base, ost->st->time_base);
|
||||
|
||||
if (debug_ts) {
|
||||
av_log(NULL, AV_LOG_INFO, "encoder -> type:audio "
|
||||
@ -1052,10 +1047,7 @@ static void do_video_out(AVFormatContext *s,
|
||||
if (pkt.pts == AV_NOPTS_VALUE && !(enc->codec->capabilities & CODEC_CAP_DELAY))
|
||||
pkt.pts = ost->sync_opts;
|
||||
|
||||
if (pkt.pts != AV_NOPTS_VALUE)
|
||||
pkt.pts = av_rescale_q(pkt.pts, enc->time_base, ost->st->time_base);
|
||||
if (pkt.dts != AV_NOPTS_VALUE)
|
||||
pkt.dts = av_rescale_q(pkt.dts, enc->time_base, ost->st->time_base);
|
||||
av_packet_rescale_ts(&pkt, enc->time_base, ost->st->time_base);
|
||||
|
||||
if (debug_ts) {
|
||||
av_log(NULL, AV_LOG_INFO, "encoder -> type:video "
|
||||
@ -1564,12 +1556,7 @@ static void flush_encoders(void)
|
||||
av_free_packet(&pkt);
|
||||
continue;
|
||||
}
|
||||
if (pkt.pts != AV_NOPTS_VALUE)
|
||||
pkt.pts = av_rescale_q(pkt.pts, enc->time_base, ost->st->time_base);
|
||||
if (pkt.dts != AV_NOPTS_VALUE)
|
||||
pkt.dts = av_rescale_q(pkt.dts, enc->time_base, ost->st->time_base);
|
||||
if (pkt.duration > 0)
|
||||
pkt.duration = av_rescale_q(pkt.duration, enc->time_base, ost->st->time_base);
|
||||
av_packet_rescale_ts(&pkt, enc->time_base, ost->st->time_base);
|
||||
pkt_size = pkt.size;
|
||||
write_frame(os, &pkt, ost);
|
||||
if (ost->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO && vstats_filename) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user