comparison flvenc.c @ 1615:8e55b4de921c libavformat

VP6 and flashsv stream copy and muxing support.
author banan
date Mon, 01 Jan 2007 22:52:22 +0000
parents 8813741f7196
children ac2a299df031
comparison
equal deleted inserted replaced
1614:72b0e694b2b7 1615:8e55b4de921c
27 27
28 static const CodecTag flv_video_codec_ids[] = { 28 static const CodecTag flv_video_codec_ids[] = {
29 {CODEC_ID_FLV1, FLV_CODECID_H263 }, 29 {CODEC_ID_FLV1, FLV_CODECID_H263 },
30 {CODEC_ID_FLASHSV, FLV_CODECID_SCREEN}, 30 {CODEC_ID_FLASHSV, FLV_CODECID_SCREEN},
31 {CODEC_ID_VP6F, FLV_CODECID_VP6 }, 31 {CODEC_ID_VP6F, FLV_CODECID_VP6 },
32 {CODEC_ID_VP6, FLV_CODECID_VP6 },
32 {CODEC_ID_NONE, 0} 33 {CODEC_ID_NONE, 0}
33 }; 34 };
34 35
35 static const CodecTag flv_audio_codec_ids[] = { 36 static const CodecTag flv_audio_codec_ids[] = {
36 {CODEC_ID_MP3, FLV_CODECID_MP3 >> FLV_AUDIO_CODECID_OFFSET}, 37 {CODEC_ID_MP3, FLV_CODECID_MP3 >> FLV_AUDIO_CODECID_OFFSET},
278 279
279 // av_log(s, AV_LOG_DEBUG, "type:%d pts: %"PRId64" size:%d\n", enc->codec_type, timestamp, size); 280 // av_log(s, AV_LOG_DEBUG, "type:%d pts: %"PRId64" size:%d\n", enc->codec_type, timestamp, size);
280 281
281 if (enc->codec_type == CODEC_TYPE_VIDEO) { 282 if (enc->codec_type == CODEC_TYPE_VIDEO) {
282 put_byte(pb, FLV_TAG_TYPE_VIDEO); 283 put_byte(pb, FLV_TAG_TYPE_VIDEO);
283 flags = FLV_CODECID_H263; 284
285 flags = codec_get_tag(flv_video_codec_ids, enc->codec_id);
286 if(flags == 0) {
287 av_log(enc, AV_LOG_ERROR, "video codec %X not compatible with flv\n",enc->codec_id);
288 return -1;
289 }
290
284 flags |= pkt->flags & PKT_FLAG_KEY ? FLV_FRAME_KEY : FLV_FRAME_INTER; 291 flags |= pkt->flags & PKT_FLAG_KEY ? FLV_FRAME_KEY : FLV_FRAME_INTER;
285 } else { 292 } else {
286 assert(enc->codec_type == CODEC_TYPE_AUDIO); 293 assert(enc->codec_type == CODEC_TYPE_AUDIO);
287 flags = get_audio_flags(enc); 294 flags = get_audio_flags(enc);
288 295
289 assert(size); 296 assert(size);
290 297
291 put_byte(pb, FLV_TAG_TYPE_AUDIO); 298 put_byte(pb, FLV_TAG_TYPE_AUDIO);
292 } 299 }
293 300
294 put_be24(pb,size+1); // include flags 301 if ((enc->codec_id == CODEC_ID_VP6) || (enc->codec_id == CODEC_ID_VP6F))
302 put_be24(pb,size+2); // include the extra byte needed for VP6 in flv and flags
303 else
304 put_be24(pb,size+1); // include flags
295 put_be24(pb,pkt->pts); 305 put_be24(pb,pkt->pts);
296 put_be32(pb,flv->reserved); 306 put_be32(pb,flv->reserved);
297 put_byte(pb,flags); 307 put_byte(pb,flags);
308 if (enc->codec_id == CODEC_ID_VP6)
309 put_byte(pb,0);
310 if (enc->codec_id == CODEC_ID_VP6F)
311 put_byte(pb, enc->extradata_size ? enc->extradata[0] : 0);
298 put_buffer(pb, pkt->data, size); 312 put_buffer(pb, pkt->data, size);
299 put_be32(pb,size+1+11); // previous tag size 313 put_be32(pb,size+1+11); // previous tag size
300 flv->duration = pkt->pts + pkt->duration; 314 flv->duration = pkt->pts + pkt->duration;
301 315
302 put_flush_packet(pb); 316 put_flush_packet(pb);