|
|
|
@ -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; |
|
|
|
|