diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2004-06-15 13:49:12 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2004-06-15 13:49:12 +0000 |
commit | 50c3dd32fd6c66786d142d8d7653409f938cbc67 (patch) | |
tree | 2c575df18b13620c320b78cddc7663c880adf027 /libavformat/avienc.c | |
parent | caacc47ff9decebaa062ae3a07287af2420ebf1e (diff) | |
download | ffmpeg-50c3dd32fd6c66786d142d8d7653409f938cbc67.tar.gz |
pass timestamps correctly for -sync 0
use zero sized frames in avi to handle duplicate frames
Originally committed as revision 3225 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/avienc.c')
-rw-r--r-- | libavformat/avienc.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/libavformat/avienc.c b/libavformat/avienc.c index b5f106e8be..33500fddd9 100644 --- a/libavformat/avienc.c +++ b/libavformat/avienc.c @@ -43,6 +43,7 @@ typedef struct { offset_t frames_hdr_all, frames_hdr_strm[MAX_STREAMS]; int audio_strm_length[MAX_STREAMS]; int riff_id; + int packet_count[MAX_STREAMS]; AVIIndex indexes[MAX_STREAMS]; } AVIContext; @@ -382,6 +383,7 @@ static int avi_write_header(AVFormatContext *s) put_le32(pb, stream->frame_rate_base); /* scale */ put_le32(pb, stream->frame_rate); /* rate */ + av_set_pts_info(s->streams[i], 64, stream->frame_rate_base, stream->frame_rate); put_le32(pb, 0); /* start */ avi->frames_hdr_strm[i] = url_ftell(pb); /* remember this offset to fill later */ @@ -404,6 +406,7 @@ static int avi_write_header(AVFormatContext *s) parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale); put_le32(pb, au_scale); /* scale */ put_le32(pb, au_byterate); /* rate */ +// av_set_pts_info(&s->streams[i], 64, au_scale, au_byterate); put_le32(pb, 0); /* start */ avi->frames_hdr_strm[i] = url_ftell(pb); /* remember this offset to fill later */ put_le32(pb, 0); /* length, XXX: filled later */ @@ -615,10 +618,23 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt) ByteIOContext *pb = &s->pb; unsigned char tag[5]; unsigned int flags=0; - AVCodecContext *enc; const int stream_index= pkt->stream_index; + AVCodecContext *enc= &s->streams[stream_index]->codec;; int size= pkt->size; +// av_log(s, AV_LOG_DEBUG, "%lld %d %d\n", pkt->dts, avi->packet_count[stream_index], stream_index); + while(enc->codec_type == CODEC_TYPE_VIDEO && pkt->dts != AV_NOPTS_VALUE && pkt->dts > avi->packet_count[stream_index]){ + AVPacket empty_packet; + + av_init_packet(&empty_packet); + empty_packet.size= 0; + empty_packet.data= NULL; + empty_packet.stream_index= stream_index; + avi_write_packet(s, &empty_packet); +// av_log(s, AV_LOG_DEBUG, "dup %lld %d\n", pkt->dts, avi->packet_count[stream_index]); + } + avi->packet_count[stream_index]++; + if (url_ftell(pb) - avi->riff_start > AVI_MAX_RIFF_SIZE) { avi_write_ix(s); end_tag(pb, avi->movi_list); @@ -630,7 +646,6 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt) avi->movi_list = avi_start_new_riff(avi, pb, "AVIX", "movi"); } - enc = &s->streams[stream_index]->codec; avi_stream2fourcc(&tag[0], stream_index, enc->codec_type); if(pkt->flags&PKT_FLAG_KEY) flags = 0x10; |