Mercurial > libavformat.hg
comparison flvenc.c @ 468:60f897e8dd2d libavformat
pass AVPacket into av_write_frame()
fixes the random dts/pts during encoding
asf preroll fix
no more initial zero frames for b frame encoding
mpeg-es dts during demuxing fixed
.ffm timestamp scale fixed, ffm is still broken though
author | michael |
---|---|
date | Sat, 29 May 2004 02:06:32 +0000 |
parents | b69898ffc92a |
children | 7942c1aa0028 |
comparison
equal
deleted
inserted
replaced
467:40069a91d1a0 | 468:60f897e8dd2d |
---|---|
237 put_byte(pb,flags); | 237 put_byte(pb,flags); |
238 url_fseek(pb, file_size, SEEK_SET); | 238 url_fseek(pb, file_size, SEEK_SET); |
239 return 0; | 239 return 0; |
240 } | 240 } |
241 | 241 |
242 static int flv_write_packet(AVFormatContext *s, int stream_index, | 242 static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) |
243 const uint8_t *buf, int size, int64_t timestamp) | |
244 { | 243 { |
245 ByteIOContext *pb = &s->pb; | 244 ByteIOContext *pb = &s->pb; |
246 AVCodecContext *enc = &s->streams[stream_index]->codec; | 245 AVCodecContext *enc = &s->streams[pkt->stream_index]->codec; |
247 FLVContext *flv = s->priv_data; | 246 FLVContext *flv = s->priv_data; |
248 FLVFrame *frame = av_malloc(sizeof(FLVFrame)); | 247 FLVFrame *frame = av_malloc(sizeof(FLVFrame)); |
248 int size= pkt->size; | |
249 uint8_t *buf= pkt->data; | |
249 | 250 |
250 frame->next = 0; | 251 frame->next = 0; |
251 frame->size = size; | 252 frame->size = size; |
252 frame->data = av_malloc(size); | 253 frame->data = av_malloc(size); |
253 frame->timestamp = timestamp; | 254 frame->timestamp = pkt->pts; |
254 frame->reserved= flv->reserved; | 255 frame->reserved= flv->reserved; |
255 memcpy(frame->data,buf,size); | 256 memcpy(frame->data,buf,size); |
256 | 257 |
257 // av_log(s, AV_LOG_DEBUG, "type:%d pts: %lld size:%d\n", enc->codec_type, timestamp, size); | 258 // av_log(s, AV_LOG_DEBUG, "type:%d pts: %lld size:%d\n", enc->codec_type, timestamp, size); |
258 | 259 |
259 if (enc->codec_type == CODEC_TYPE_VIDEO) { | 260 if (enc->codec_type == CODEC_TYPE_VIDEO) { |
260 frame->type = 9; | 261 frame->type = 9; |
261 frame->flags = 2; // choose h263 | 262 frame->flags = 2; // choose h263 |
262 frame->flags |= enc->coded_frame->key_frame ? 0x10 : 0x20; // add keyframe indicator | 263 frame->flags |= pkt->flags & PKT_FLAG_KEY ? 0x10 : 0x20; // add keyframe indicator |
263 //frame->timestamp = ( ( flv->frameCount * (int64_t)FRAME_RATE_BASE * (int64_t)1000 ) / (int64_t)enc->frame_rate ); | 264 //frame->timestamp = ( ( flv->frameCount * (int64_t)FRAME_RATE_BASE * (int64_t)1000 ) / (int64_t)enc->frame_rate ); |
264 //printf("%08x %f %f\n",frame->timestamp,(double)enc->frame_rate/(double)FRAME_RATE_BASE,1000*(double)FRAME_RATE_BASE/(double)enc->frame_rate); | 265 //printf("%08x %f %f\n",frame->timestamp,(double)enc->frame_rate/(double)FRAME_RATE_BASE,1000*(double)FRAME_RATE_BASE/(double)enc->frame_rate); |
265 flv->hasVideo = 1; | 266 flv->hasVideo = 1; |
266 | 267 |
267 InsertSorted(flv,frame); | 268 InsertSorted(flv,frame); |
304 assert(0); | 305 assert(0); |
305 } | 306 } |
306 | 307 |
307 assert(size); | 308 assert(size); |
308 if ( flv->initDelay == -1 ) { | 309 if ( flv->initDelay == -1 ) { |
309 flv->initDelay = timestamp; | 310 flv->initDelay = pkt->pts; |
310 } | 311 } |
311 | 312 |
312 frame->type = 8; | 313 frame->type = 8; |
313 frame->flags = soundFormat; | 314 frame->flags = soundFormat; |
314 | 315 |