summaryrefslogtreecommitdiff
path: root/libavformat/flvenc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2006-12-10 17:12:45 +0000
committerMichael Niedermayer <michaelni@gmx.at>2006-12-10 17:12:45 +0000
commitc45388b193e3a111b91b22245036f8715b93a4a2 (patch)
tree0cdea4fd1f5e3a0564bf7f5c5b5ea6cd0f413cf0 /libavformat/flvenc.c
parent46f9dcc3ee03c6698313e85cbdc9b40e5d23d1af (diff)
set flags correctly in write header instead of seeking back and fixing it in write_trailer()
Originally committed as revision 7267 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/flvenc.c')
-rw-r--r--libavformat/flvenc.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index 76fa2cad65..fc332e1a45 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -110,12 +110,6 @@ static int flv_write_header(AVFormatContext *s)
flv->hasAudio = 0;
flv->hasVideo = 0;
- put_tag(pb,"FLV");
- put_byte(pb,1);
- put_byte(pb,0); // delayed write
- put_be32(pb,9);
- put_be32(pb,0);
-
for(i=0; i<s->nb_streams; i++){
AVCodecContext *enc = s->streams[i]->codec;
if (enc->codec_type == CODEC_TYPE_VIDEO) {
@@ -130,9 +124,20 @@ static int flv_write_header(AVFormatContext *s)
} else {
flv->hasAudio=1;
samplerate = enc->sample_rate;
+ if(get_audio_flags(enc)<0)
+ return -1;
}
av_set_pts_info(s->streams[i], 24, 1, 1000); /* 24 bit pts in ms */
- if(enc->codec_tag == 5){
+ }
+ put_tag(pb,"FLV");
+ put_byte(pb,1);
+ put_byte(pb, FLV_HEADER_FLAG_HASAUDIO * flv->hasAudio
+ + FLV_HEADER_FLAG_HASVIDEO * flv->hasVideo);
+ put_be32(pb,9);
+ put_be32(pb,0);
+
+ for(i=0; i<s->nb_streams; i++){
+ if(s->streams[i]->codec->codec_tag == 5){
put_byte(pb,8); // message type
put_be24(pb,0); // include flags
put_be24(pb,0); // time stamp
@@ -140,8 +145,6 @@ static int flv_write_header(AVFormatContext *s)
put_be32(pb,11); // size
flv->reserved=5;
}
- if(enc->codec_type == CODEC_TYPE_AUDIO && get_audio_flags(enc)<0)
- return -1;
}
/* write meta_tag */
@@ -204,16 +207,11 @@ static int flv_write_header(AVFormatContext *s)
static int flv_write_trailer(AVFormatContext *s)
{
int64_t file_size;
- int flags = 0;
ByteIOContext *pb = &s->pb;
FLVContext *flv = s->priv_data;
file_size = url_ftell(pb);
- flags |= flv->hasAudio ? FLV_HEADER_FLAG_HASAUDIO : 0;
- flags |= flv->hasVideo ? FLV_HEADER_FLAG_HASVIDEO : 0;
- url_fseek(pb, 4, SEEK_SET);
- put_byte(pb,flags);
/* update informations */
url_fseek(pb, flv->duration_offset, SEEK_SET);