flvenc.c 17.6 KB
Newer Older
1
/*
2
 * FLV muxer
3
 * Copyright (c) 2003 The FFmpeg Project
4
 *
5 6 7
 * This file is part of FFmpeg.
 *
 * FFmpeg is free software; you can redistribute it and/or
8 9
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
10
 * version 2.1 of the License, or (at your option) any later version.
11
 *
12
 * FFmpeg is distributed in the hope that it will be useful,
13 14 15 16 17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with FFmpeg; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
 */
21 22

#include "libavutil/intreadwrite.h"
23
#include "libavutil/intfloat.h"
24
#include "avformat.h"
25
#include "flv.h"
26
#include "internal.h"
27
#include "avc.h"
Tomás Touceda's avatar
Tomás Touceda committed
28
#include "metadata.h"
29
#include "libavutil/dict.h"
30

Michael Niedermayer's avatar
Michael Niedermayer committed
31 32 33
#undef NDEBUG
#include <assert.h>

34
static const AVCodecTag flv_video_codec_ids[] = {
35
    {CODEC_ID_FLV1,    FLV_CODECID_H263  },
36 37
    {CODEC_ID_H263,    FLV_CODECID_REALH263},
    {CODEC_ID_MPEG4,   FLV_CODECID_MPEG4 },
38
    {CODEC_ID_FLASHSV, FLV_CODECID_SCREEN},
39
    {CODEC_ID_FLASHSV2, FLV_CODECID_SCREEN2},
40
    {CODEC_ID_VP6F,    FLV_CODECID_VP6   },
41
    {CODEC_ID_VP6,     FLV_CODECID_VP6   },
42
    {CODEC_ID_VP6A,    FLV_CODECID_VP6A  },
43
    {CODEC_ID_H264,    FLV_CODECID_H264  },
44 45 46
    {CODEC_ID_NONE,    0}
};

47
static const AVCodecTag flv_audio_codec_ids[] = {
48
    {CODEC_ID_MP3,       FLV_CODECID_MP3    >> FLV_AUDIO_CODECID_OFFSET},
49
    {CODEC_ID_PCM_U8,    FLV_CODECID_PCM    >> FLV_AUDIO_CODECID_OFFSET},
50
    {CODEC_ID_PCM_S16BE, FLV_CODECID_PCM    >> FLV_AUDIO_CODECID_OFFSET},
51 52
    {CODEC_ID_PCM_S16LE, FLV_CODECID_PCM_LE >> FLV_AUDIO_CODECID_OFFSET},
    {CODEC_ID_ADPCM_SWF, FLV_CODECID_ADPCM  >> FLV_AUDIO_CODECID_OFFSET},
53
    {CODEC_ID_AAC,       FLV_CODECID_AAC    >> FLV_AUDIO_CODECID_OFFSET},
54
    {CODEC_ID_NELLYMOSER, FLV_CODECID_NELLYMOSER >> FLV_AUDIO_CODECID_OFFSET},
55
    {CODEC_ID_SPEEX,     FLV_CODECID_SPEEX  >> FLV_AUDIO_CODECID_OFFSET},
56 57 58
    {CODEC_ID_NONE,      0}
};

59
typedef struct FLVContext {
Michael Niedermayer's avatar
Michael Niedermayer committed
60
    int reserved;
61 62
    int64_t duration_offset;
    int64_t filesize_offset;
63
    int64_t duration;
64
    int64_t delay;      ///< first dts delay (needed for AVC & Speex)
65 66
} FLVContext;

67 68 69 70
typedef struct FLVStreamContext {
    int64_t last_ts;    ///< last timestamp for each stream
} FLVStreamContext;

71
static int get_audio_flags(AVCodecContext *enc){
72
    int flags = (enc->bits_per_coded_sample == 16) ? FLV_SAMPLESSIZE_16BIT : FLV_SAMPLESSIZE_8BIT;
73

74 75
    if (enc->codec_id == CODEC_ID_AAC) // specs force these parameters
        return FLV_CODECID_AAC | FLV_SAMPLERATE_44100HZ | FLV_SAMPLESSIZE_16BIT | FLV_STEREO;
76 77 78 79 80 81 82 83 84 85 86
    else if (enc->codec_id == CODEC_ID_SPEEX) {
        if (enc->sample_rate != 16000) {
            av_log(enc, AV_LOG_ERROR, "flv only supports wideband (16kHz) Speex audio\n");
            return -1;
        }
        if (enc->channels != 1) {
            av_log(enc, AV_LOG_ERROR, "flv only supports mono Speex audio\n");
            return -1;
        }
        return FLV_CODECID_SPEEX | FLV_SAMPLERATE_11025HZ | FLV_SAMPLESSIZE_16BIT;
    } else {
87 88
    switch (enc->sample_rate) {
        case    44100:
89
            flags |= FLV_SAMPLERATE_44100HZ;
90 91
            break;
        case    22050:
92
            flags |= FLV_SAMPLERATE_22050HZ;
93 94
            break;
        case    11025:
95
            flags |= FLV_SAMPLERATE_11025HZ;
96
            break;
97
        case    16000: //nellymoser only
98 99
        case     8000: //nellymoser only
        case     5512: //not mp3
100
            if(enc->codec_id != CODEC_ID_MP3){
Michael Niedermayer's avatar
Michael Niedermayer committed
101 102
                flags |= FLV_SAMPLERATE_SPECIAL;
                break;
103
            }
104
        default:
Diego Biurrun's avatar
Diego Biurrun committed
105
            av_log(enc, AV_LOG_ERROR, "flv does not support that sample rate, choose from (44100, 22050, 11025).\n");
106 107
            return -1;
    }
108
    }
109 110

    if (enc->channels > 1) {
111
        flags |= FLV_STEREO;
112
    }
113

114 115
    switch(enc->codec_id){
    case CODEC_ID_MP3:
116
        flags |= FLV_CODECID_MP3    | FLV_SAMPLESSIZE_16BIT;
117
        break;
118
    case CODEC_ID_PCM_U8:
119
        flags |= FLV_CODECID_PCM    | FLV_SAMPLESSIZE_8BIT;
120
        break;
121
    case CODEC_ID_PCM_S16BE:
122
        flags |= FLV_CODECID_PCM    | FLV_SAMPLESSIZE_16BIT;
123
        break;
124
    case CODEC_ID_PCM_S16LE:
125
        flags |= FLV_CODECID_PCM_LE | FLV_SAMPLESSIZE_16BIT;
126
        break;
127
    case CODEC_ID_ADPCM_SWF:
128
        flags |= FLV_CODECID_ADPCM | FLV_SAMPLESSIZE_16BIT;
129
        break;
130
    case CODEC_ID_NELLYMOSER:
131 132
        if (enc->sample_rate == 8000) {
            flags |= FLV_CODECID_NELLYMOSER_8KHZ_MONO | FLV_SAMPLESSIZE_16BIT;
133 134
        } else if (enc->sample_rate == 16000) {
            flags |= FLV_CODECID_NELLYMOSER_16KHZ_MONO | FLV_SAMPLESSIZE_16BIT;
135 136 137
        } else {
            flags |= FLV_CODECID_NELLYMOSER | FLV_SAMPLESSIZE_16BIT;
        }
138
        break;
139 140 141 142
    case 0:
        flags |= enc->codec_tag<<4;
        break;
    default:
143
        av_log(enc, AV_LOG_ERROR, "codec not compatible with flv\n");
144 145
        return -1;
    }
146

147 148 149
    return flags;
}

150
static void put_amf_string(AVIOContext *pb, const char *str)
151 152
{
    size_t len = strlen(str);
153 154
    avio_wb16(pb, len);
    avio_write(pb, str, len);
155 156
}

157
static void put_avc_eos_tag(AVIOContext *pb, unsigned ts) {
158 159 160 161 162 163 164 165 166
    avio_w8(pb, FLV_TAG_TYPE_VIDEO);
    avio_wb24(pb, 5);  /* Tag Data Size */
    avio_wb24(pb, ts);  /* lower 24 bits of timestamp in ms*/
    avio_w8(pb, (ts >> 24) & 0x7F);  /* MSB of ts in ms*/
    avio_wb24(pb, 0);  /* StreamId = 0 */
    avio_w8(pb, 23);  /* ub[4] FrameType = 1, ub[4] CodecId = 7 */
    avio_w8(pb, 2);  /* AVC end of sequence */
    avio_wb24(pb, 0);  /* Always 0 for AVC EOS. */
    avio_wb32(pb, 16);  /* Size of FLV tag */
167 168
}

169
static void put_amf_double(AVIOContext *pb, double d)
170
{
171
    avio_w8(pb, AMF_DATA_TYPE_NUMBER);
172
    avio_wb64(pb, av_double2int(d));
173 174
}

175
static void put_amf_bool(AVIOContext *pb, int b) {
176 177
    avio_w8(pb, AMF_DATA_TYPE_BOOL);
    avio_w8(pb, !!b);
178 179
}

180 181
static int flv_write_header(AVFormatContext *s)
{
182
    AVIOContext *pb = s->pb;
183
    FLVContext *flv = s->priv_data;
184
    AVCodecContext *audio_enc = NULL, *video_enc = NULL;
185
    int i, metadata_count = 0;
186
    double framerate = 0.0;
187
    int64_t metadata_size_pos, data_size, metadata_count_pos;
188
    AVDictionaryEntry *tag = NULL;
189

Michael Niedermayer's avatar
Michael Niedermayer committed
190
    for(i=0; i<s->nb_streams; i++){
191
        AVCodecContext *enc = s->streams[i]->codec;
192
        FLVStreamContext *sc;
193
        if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {
194 195 196 197 198
            if (s->streams[i]->r_frame_rate.den && s->streams[i]->r_frame_rate.num) {
                framerate = av_q2d(s->streams[i]->r_frame_rate);
            } else {
                framerate = 1/av_q2d(s->streams[i]->codec->time_base);
            }
199 200
            video_enc = enc;
            if(enc->codec_tag == 0) {
201 202 203
                av_log(enc, AV_LOG_ERROR, "video codec not compatible with flv\n");
                return -1;
            }
204
        } else if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
205
            audio_enc = enc;
206 207
            if(get_audio_flags(enc)<0)
                return -1;
208
        }
209
        avpriv_set_pts_info(s->streams[i], 32, 1, 1000); /* 32 bit pts in ms */
210 211 212 213 214 215

        sc = av_mallocz(sizeof(FLVStreamContext));
        if (!sc)
            return AVERROR(ENOMEM);
        s->streams[i]->priv_data = sc;
        sc->last_ts = -1;
216
    }
217 218
    flv->delay = AV_NOPTS_VALUE;

219
    avio_write(pb, "FLV", 3);
220 221
    avio_w8(pb,1);
    avio_w8(pb,   FLV_HEADER_FLAG_HASAUDIO * !!audio_enc
222
                 + FLV_HEADER_FLAG_HASVIDEO * !!video_enc);
223 224
    avio_wb32(pb,9);
    avio_wb32(pb,0);
225 226 227

    for(i=0; i<s->nb_streams; i++){
        if(s->streams[i]->codec->codec_tag == 5){
228 229 230 231 232
            avio_w8(pb,8); // message type
            avio_wb24(pb,0); // include flags
            avio_wb24(pb,0); // time stamp
            avio_wb32(pb,0); // reserved
            avio_wb32(pb,11); // size
Michael Niedermayer's avatar
Michael Niedermayer committed
233 234 235
            flv->reserved=5;
        }
    }
236

237
    /* write meta_tag */
238
    avio_w8(pb, 18);         // tag type META
239
    metadata_size_pos= avio_tell(pb);
240 241 242
    avio_wb24(pb, 0);          // size of data part (sum of all parts below)
    avio_wb24(pb, 0);          // time stamp
    avio_wb32(pb, 0);          // reserved
243 244 245 246

    /* now data of data_size size */

    /* first event name as a string */
247
    avio_w8(pb, AMF_DATA_TYPE_STRING);
248 249 250
    put_amf_string(pb, "onMetaData"); // 12 bytes

    /* mixed array (hash) with size and string/type/data tuples */
251
    avio_w8(pb, AMF_DATA_TYPE_MIXEDARRAY);
252 253 254
    metadata_count_pos = avio_tell(pb);
    metadata_count = 5*!!video_enc + 5*!!audio_enc + 2; // +2 for duration and file size
    avio_wb32(pb, metadata_count);
255

256
    put_amf_string(pb, "duration");
257
    flv->duration_offset= avio_tell(pb);
258
    put_amf_double(pb, s->duration / AV_TIME_BASE); // fill in the guessed duration, it'll be corrected later if incorrect
259

260
    if(video_enc){
261
        put_amf_string(pb, "width");
262
        put_amf_double(pb, video_enc->width);
263 264

        put_amf_string(pb, "height");
265
        put_amf_double(pb, video_enc->height);
266 267

        put_amf_string(pb, "videodatarate");
268
        put_amf_double(pb, video_enc->bit_rate / 1024.0);
269 270 271

        put_amf_string(pb, "framerate");
        put_amf_double(pb, framerate);
272 273

        put_amf_string(pb, "videocodecid");
274
        put_amf_double(pb, video_enc->codec_tag);
275 276
    }

277
    if(audio_enc){
278 279 280
        put_amf_string(pb, "audiodatarate");
        put_amf_double(pb, audio_enc->bit_rate / 1024.0);

281
        put_amf_string(pb, "audiosamplerate");
282
        put_amf_double(pb, audio_enc->sample_rate);
283 284

        put_amf_string(pb, "audiosamplesize");
285
        put_amf_double(pb, audio_enc->codec_id == CODEC_ID_PCM_U8 ? 8 : 16);
286 287

        put_amf_string(pb, "stereo");
288
        put_amf_bool(pb, audio_enc->channels == 2);
289 290

        put_amf_string(pb, "audiocodecid");
291
        put_amf_double(pb, audio_enc->codec_tag);
292 293
    }

294
    while ((tag = av_dict_get(s->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310
        if(   !strcmp(tag->key, "width")
            ||!strcmp(tag->key, "height")
            ||!strcmp(tag->key, "videodatarate")
            ||!strcmp(tag->key, "framerate")
            ||!strcmp(tag->key, "videocodecid")
            ||!strcmp(tag->key, "audiodatarate")
            ||!strcmp(tag->key, "audiosamplerate")
            ||!strcmp(tag->key, "audiosamplesize")
            ||!strcmp(tag->key, "stereo")
            ||!strcmp(tag->key, "audiocodecid")
            ||!strcmp(tag->key, "duration")
            ||!strcmp(tag->key, "onMetaData")
        ){
            av_log(s, AV_LOG_DEBUG, "ignoring metadata for %s\n", tag->key);
            continue;
        }
Tomás Touceda's avatar
Tomás Touceda committed
311
        put_amf_string(pb, tag->key);
312
        avio_w8(pb, AMF_DATA_TYPE_STRING);
Tomás Touceda's avatar
Tomás Touceda committed
313
        put_amf_string(pb, tag->value);
314
        metadata_count++;
Tomás Touceda's avatar
Tomás Touceda committed
315 316
    }

317
    put_amf_string(pb, "filesize");
318
    flv->filesize_offset= avio_tell(pb);
319
    put_amf_double(pb, 0); // delayed write
320 321

    put_amf_string(pb, "");
322
    avio_w8(pb, AMF_END_OF_OBJECT);
323 324

    /* write total size of tag */
325
    data_size= avio_tell(pb) - metadata_size_pos - 10;
326 327 328 329

    avio_seek(pb, metadata_count_pos, SEEK_SET);
    avio_wb32(pb, metadata_count);

330
    avio_seek(pb, metadata_size_pos, SEEK_SET);
331
    avio_wb24(pb, data_size);
332
    avio_skip(pb, data_size + 10 - 3);
333
    avio_wb32(pb, data_size + 11);
334

335 336
    for (i = 0; i < s->nb_streams; i++) {
        AVCodecContext *enc = s->streams[i]->codec;
337
        if (enc->codec_id == CODEC_ID_AAC || enc->codec_id == CODEC_ID_H264 || enc->codec_id == CODEC_ID_MPEG4) {
338
            int64_t pos;
339
            avio_w8(pb, enc->codec_type == AVMEDIA_TYPE_VIDEO ?
340
                     FLV_TAG_TYPE_VIDEO : FLV_TAG_TYPE_AUDIO);
341 342 343 344
            avio_wb24(pb, 0); // size patched later
            avio_wb24(pb, 0); // ts
            avio_w8(pb, 0); // ts ext
            avio_wb24(pb, 0); // streamid
345
            pos = avio_tell(pb);
346
            if (enc->codec_id == CODEC_ID_AAC) {
347 348 349
                avio_w8(pb, get_audio_flags(enc));
                avio_w8(pb, 0); // AAC sequence header
                avio_write(pb, enc->extradata, enc->extradata_size);
350
            } else {
351 352 353
                avio_w8(pb, enc->codec_tag | FLV_FRAME_KEY); // flags
                avio_w8(pb, 0); // AVC sequence header
                avio_wb24(pb, 0); // composition time
354 355
                ff_isom_write_avcc(pb, enc->extradata, enc->extradata_size);
            }
356
            data_size = avio_tell(pb) - pos;
357
            avio_seek(pb, -data_size - 10, SEEK_CUR);
358
            avio_wb24(pb, data_size);
359
            avio_skip(pb, data_size + 10 - 3);
360
            avio_wb32(pb, data_size + 11); // previous tag size
361 362 363
        }
    }

364 365 366 367 368
    return 0;
}

static int flv_write_trailer(AVFormatContext *s)
{
369 370
    int64_t file_size;

371
    AVIOContext *pb = s->pb;
372
    FLVContext *flv = s->priv_data;
373 374 375 376 377
    int i;

    /* Add EOS tag */
    for (i = 0; i < s->nb_streams; i++) {
        AVCodecContext *enc = s->streams[i]->codec;
378
        FLVStreamContext *sc = s->streams[i]->priv_data;
379
        if (enc->codec_type == AVMEDIA_TYPE_VIDEO &&
380
                (enc->codec_id == CODEC_ID_H264 || enc->codec_id == CODEC_ID_MPEG4)) {
381
            put_avc_eos_tag(pb, sc->last_ts);
382 383
        }
    }
384

385
    file_size = avio_tell(pb);
386

387
    /* update information */
388
    avio_seek(pb, flv->duration_offset, SEEK_SET);
389
    put_amf_double(pb, flv->duration / (double)1000);
390
    avio_seek(pb, flv->filesize_offset, SEEK_SET);
391 392
    put_amf_double(pb, file_size);

393
    avio_seek(pb, file_size, SEEK_SET);
394 395 396
    return 0;
}

397
static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
398
{
399
    AVIOContext *pb = s->pb;
400
    AVCodecContext *enc = s->streams[pkt->stream_index]->codec;
401
    FLVContext *flv = s->priv_data;
402
    FLVStreamContext *sc = s->streams[pkt->stream_index]->priv_data;
403
    unsigned ts;
404
    int size= pkt->size;
405
    uint8_t *data= NULL;
406
    int flags, flags_size;
407

408
//    av_log(s, AV_LOG_DEBUG, "type:%d pts: %"PRId64" size:%d\n", enc->codec_type, timestamp, size);
409

410
    if(enc->codec_id == CODEC_ID_VP6 || enc->codec_id == CODEC_ID_VP6F ||
411
       enc->codec_id == CODEC_ID_VP6A || enc->codec_id == CODEC_ID_AAC)
412
        flags_size= 2;
413
    else if(enc->codec_id == CODEC_ID_H264 || enc->codec_id == CODEC_ID_MPEG4)
414
        flags_size= 5;
415 416 417
    else
        flags_size= 1;

418
    if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {
419
        avio_w8(pb, FLV_TAG_TYPE_VIDEO);
420

421
        flags = enc->codec_tag;
422
        if(flags == 0) {
423
            av_log(enc, AV_LOG_ERROR, "video codec %s not compatible with flv\n", avcodec_get_name(enc->codec_id));
424 425 426
            return -1;
        }

427
        flags |= pkt->flags & AV_PKT_FLAG_KEY ? FLV_FRAME_KEY : FLV_FRAME_INTER;
428
    } else if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
429
        flags = get_audio_flags(enc);
430

Michael Niedermayer's avatar
Michael Niedermayer committed
431 432
        assert(size);

433
        avio_w8(pb, FLV_TAG_TYPE_AUDIO);
434 435 436 437 438
    } else {
        // In-band flv metadata ("scriptdata")
        assert(enc->codec_type == AVMEDIA_TYPE_DATA);
        avio_w8(pb, FLV_TAG_TYPE_META);
        flags_size = 0;
Joseph Wecker's avatar
Joseph Wecker committed
439
        flags = 0;
Michael Niedermayer's avatar
Michael Niedermayer committed
440 441
    }

442
    if (enc->codec_id == CODEC_ID_H264 || enc->codec_id == CODEC_ID_MPEG4) {
443 444 445 446 447
        /* check if extradata looks like mp4 formated */
        if (enc->extradata_size > 0 && *(uint8_t*)enc->extradata != 1) {
            if (ff_avc_parse_nal_units_buf(pkt->data, &data, &size) < 0)
                return -1;
        }
448 449 450 451
    } else if (enc->codec_id == CODEC_ID_AAC && pkt->size > 2 &&
               (AV_RB16(pkt->data) & 0xfff0) == 0xfff0) {
        av_log(s, AV_LOG_ERROR, "malformated aac bitstream, use -absf aac_adtstoasc\n");
        return -1;
452
    }
453 454 455 456 457 458 459
    if (flv->delay == AV_NOPTS_VALUE)
        flv->delay = -pkt->dts;
    if (pkt->dts < -flv->delay) {
        av_log(s, AV_LOG_WARNING, "Packets are not in the proper order with "
                                  "respect to DTS\n");
        return AVERROR(EINVAL);
    }
460

461
    ts = pkt->dts + flv->delay; // add delay to force positive dts
462 463

    /* check Speex packet duration */
464
    if (enc->codec_id == CODEC_ID_SPEEX && ts - sc->last_ts > 160) {
465 466 467
        av_log(s, AV_LOG_WARNING, "Warning: Speex stream has more than "
                                  "8 frames per packet. Adobe Flash "
                                  "Player cannot handle this!\n");
468
    }
469

470 471
    if (sc->last_ts < ts)
        sc->last_ts = ts;
472

473 474 475 476
    avio_wb24(pb,size + flags_size);
    avio_wb24(pb,ts);
    avio_w8(pb,(ts >> 24) & 0x7F); // timestamps are 32bits _signed_
    avio_wb24(pb,flv->reserved);
477 478 479 480

    if(flags_size)
        avio_w8(pb,flags);

481
    if (enc->codec_id == CODEC_ID_VP6)
482
        avio_w8(pb,0);
483
    if (enc->codec_id == CODEC_ID_VP6F || enc->codec_id == CODEC_ID_VP6A)
484
        avio_w8(pb, enc->extradata_size ? enc->extradata[0] : 0);
485
    else if (enc->codec_id == CODEC_ID_AAC)
486
        avio_w8(pb,1); // AAC raw
487
    else if (enc->codec_id == CODEC_ID_H264 || enc->codec_id == CODEC_ID_MPEG4) {
488 489
        avio_w8(pb,1); // AVC NALU
        avio_wb24(pb,pkt->pts - pkt->dts);
490
    }
491

492
    avio_write(pb, data ? data : pkt->data, size);
493

494
    avio_wb32(pb,size+flags_size+11); // previous tag size
495
    flv->duration = FFMAX(flv->duration, pkt->pts + flv->delay + pkt->duration);
496

497
    avio_flush(pb);
498 499 500

    av_free(data);

501
    return pb->error;
502 503
}

504
AVOutputFormat ff_flv_muxer = {
505 506 507 508 509
    .name           = "flv",
    .long_name      = NULL_IF_CONFIG_SMALL("FLV format"),
    .mime_type      = "video/x-flv",
    .extensions     = "flv",
    .priv_data_size = sizeof(FLVContext),
510
#if CONFIG_LIBMP3LAME
511
    .audio_codec    = CODEC_ID_MP3,
512
#else // CONFIG_LIBMP3LAME
513
    .audio_codec    = CODEC_ID_ADPCM_SWF,
514
#endif // CONFIG_LIBMP3LAME
515 516 517 518
    .video_codec    = CODEC_ID_FLV1,
    .write_header   = flv_write_header,
    .write_packet   = flv_write_packet,
    .write_trailer  = flv_write_trailer,
519
    .codec_tag= (const AVCodecTag* const []){flv_video_codec_ids, flv_audio_codec_ids, 0},
520
    .flags= AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS,
521
};