Revision c45388b1 libavformat/flvenc.c

View differences:

libavformat/flvenc.c
110 110
    flv->hasAudio = 0;
111 111
    flv->hasVideo = 0;
112 112

  
113
    put_tag(pb,"FLV");
114
    put_byte(pb,1);
115
    put_byte(pb,0); // delayed write
116
    put_be32(pb,9);
117
    put_be32(pb,0);
118

  
119 113
    for(i=0; i<s->nb_streams; i++){
120 114
        AVCodecContext *enc = s->streams[i]->codec;
121 115
        if (enc->codec_type == CODEC_TYPE_VIDEO) {
......
130 124
        } else {
131 125
            flv->hasAudio=1;
132 126
            samplerate = enc->sample_rate;
127
            if(get_audio_flags(enc)<0)
128
                return -1;
133 129
        }
134 130
        av_set_pts_info(s->streams[i], 24, 1, 1000); /* 24 bit pts in ms */
135
        if(enc->codec_tag == 5){
131
    }
132
    put_tag(pb,"FLV");
133
    put_byte(pb,1);
134
    put_byte(pb,   FLV_HEADER_FLAG_HASAUDIO * flv->hasAudio
135
                 + FLV_HEADER_FLAG_HASVIDEO * flv->hasVideo);
136
    put_be32(pb,9);
137
    put_be32(pb,0);
138

  
139
    for(i=0; i<s->nb_streams; i++){
140
        if(s->streams[i]->codec->codec_tag == 5){
136 141
            put_byte(pb,8); // message type
137 142
            put_be24(pb,0); // include flags
138 143
            put_be24(pb,0); // time stamp
......
140 145
            put_be32(pb,11); // size
141 146
            flv->reserved=5;
142 147
        }
143
        if(enc->codec_type == CODEC_TYPE_AUDIO && get_audio_flags(enc)<0)
144
            return -1;
145 148
    }
146 149

  
147 150
    /* write meta_tag */
......
204 207
static int flv_write_trailer(AVFormatContext *s)
205 208
{
206 209
    int64_t file_size;
207
    int flags = 0;
208 210

  
209 211
    ByteIOContext *pb = &s->pb;
210 212
    FLVContext *flv = s->priv_data;
211 213

  
212 214
    file_size = url_ftell(pb);
213
    flags |= flv->hasAudio ? FLV_HEADER_FLAG_HASAUDIO : 0;
214
    flags |= flv->hasVideo ? FLV_HEADER_FLAG_HASVIDEO : 0;
215
    url_fseek(pb, 4, SEEK_SET);
216
    put_byte(pb,flags);
217 215

  
218 216
    /* update informations */
219 217
    url_fseek(pb, flv->duration_offset, SEEK_SET);

Also available in: Unified diff