h264: fix ppc/altivec build
[libav.git] / libavformat / flvenc.c
CommitLineData
d4f5d74a 1/*
7fbde343 2 * FLV muxer
2912e87a 3 * Copyright (c) 2003 The Libav Project
d4f5d74a 4 *
2912e87a 5 * This file is part of Libav.
b78e7197 6 *
2912e87a 7 * Libav is free software; you can redistribute it and/or
d4f5d74a
GM
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
b78e7197 10 * version 2.1 of the License, or (at your option) any later version.
d4f5d74a 11 *
2912e87a 12 * Libav is distributed in the hope that it will be useful,
d4f5d74a
GM
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
2912e87a 18 * License along with Libav; if not, write to the Free Software
5509bffa 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
d4f5d74a 20 */
ee8aecd2
MR
21
22#include "libavutil/intfloat_readwrite.h"
d4f5d74a 23#include "avformat.h"
6cac3a3b 24#include "flv.h"
80b39e1c 25#include "internal.h"
f23496b5 26#include "avc.h"
16f82508 27#include "metadata.h"
d2d67e42 28#include "libavutil/dict.h"
d4f5d74a 29
068f2a22
MN
30#undef NDEBUG
31#include <assert.h>
32
7caf0cc6 33static const AVCodecTag flv_video_codec_ids[] = {
148c9bdb
AH
34 {CODEC_ID_FLV1, FLV_CODECID_H263 },
35 {CODEC_ID_FLASHSV, FLV_CODECID_SCREEN},
1b88277b 36 {CODEC_ID_FLASHSV2, FLV_CODECID_SCREEN2},
148c9bdb 37 {CODEC_ID_VP6F, FLV_CODECID_VP6 },
09d8c0ae 38 {CODEC_ID_VP6, FLV_CODECID_VP6 },
f23496b5 39 {CODEC_ID_H264, FLV_CODECID_H264 },
148c9bdb
AH
40 {CODEC_ID_NONE, 0}
41};
42
7caf0cc6 43static const AVCodecTag flv_audio_codec_ids[] = {
148c9bdb 44 {CODEC_ID_MP3, FLV_CODECID_MP3 >> FLV_AUDIO_CODECID_OFFSET},
8e9efe43 45 {CODEC_ID_PCM_U8, FLV_CODECID_PCM >> FLV_AUDIO_CODECID_OFFSET},
44de39f9 46 {CODEC_ID_PCM_S16BE, FLV_CODECID_PCM >> FLV_AUDIO_CODECID_OFFSET},
148c9bdb
AH
47 {CODEC_ID_PCM_S16LE, FLV_CODECID_PCM_LE >> FLV_AUDIO_CODECID_OFFSET},
48 {CODEC_ID_ADPCM_SWF, FLV_CODECID_ADPCM >> FLV_AUDIO_CODECID_OFFSET},
f23496b5 49 {CODEC_ID_AAC, FLV_CODECID_AAC >> FLV_AUDIO_CODECID_OFFSET},
b7d1cd02 50 {CODEC_ID_NELLYMOSER, FLV_CODECID_NELLYMOSER >> FLV_AUDIO_CODECID_OFFSET},
046c4001 51 {CODEC_ID_SPEEX, FLV_CODECID_SPEEX >> FLV_AUDIO_CODECID_OFFSET},
148c9bdb
AH
52 {CODEC_ID_NONE, 0}
53};
54
d4f5d74a 55typedef struct FLVContext {
11a8e425 56 int reserved;
bc5c918e
DB
57 int64_t duration_offset;
58 int64_t filesize_offset;
634b8cfa 59 int64_t duration;
f23496b5 60 int delay; ///< first dts delay for AVC
4ee247a2 61 int64_t last_ts;
d4f5d74a
GM
62} FLVContext;
63
37cdf93d 64static int get_audio_flags(AVCodecContext *enc){
dd1c8f3e 65 int flags = (enc->bits_per_coded_sample == 16) ? FLV_SAMPLESSIZE_16BIT : FLV_SAMPLESSIZE_8BIT;
37cdf93d 66
f23496b5
BC
67 if (enc->codec_id == CODEC_ID_AAC) // specs force these parameters
68 return FLV_CODECID_AAC | FLV_SAMPLERATE_44100HZ | FLV_SAMPLESSIZE_16BIT | FLV_STEREO;
046c4001
JR
69 else if (enc->codec_id == CODEC_ID_SPEEX) {
70 if (enc->sample_rate != 16000) {
71 av_log(enc, AV_LOG_ERROR, "flv only supports wideband (16kHz) Speex audio\n");
72 return -1;
73 }
74 if (enc->channels != 1) {
75 av_log(enc, AV_LOG_ERROR, "flv only supports mono Speex audio\n");
76 return -1;
77 }
046c4001
JR
78 return FLV_CODECID_SPEEX | FLV_SAMPLERATE_11025HZ | FLV_SAMPLESSIZE_16BIT;
79 } else {
37cdf93d
MN
80 switch (enc->sample_rate) {
81 case 44100:
6cac3a3b 82 flags |= FLV_SAMPLERATE_44100HZ;
37cdf93d
MN
83 break;
84 case 22050:
6cac3a3b 85 flags |= FLV_SAMPLERATE_22050HZ;
37cdf93d
MN
86 break;
87 case 11025:
6cac3a3b 88 flags |= FLV_SAMPLERATE_11025HZ;
37cdf93d
MN
89 break;
90 case 8000: //nellymoser only
91 case 5512: //not mp3
4838727e 92 if(enc->codec_id != CODEC_ID_MP3){
ec627278
MN
93 flags |= FLV_SAMPLERATE_SPECIAL;
94 break;
4838727e 95 }
37cdf93d 96 default:
755bfeab 97 av_log(enc, AV_LOG_ERROR, "flv does not support that sample rate, choose from (44100, 22050, 11025).\n");
37cdf93d
MN
98 return -1;
99 }
f23496b5 100 }
37cdf93d
MN
101
102 if (enc->channels > 1) {
6cac3a3b 103 flags |= FLV_STEREO;
37cdf93d 104 }
115329f1 105
37cdf93d
MN
106 switch(enc->codec_id){
107 case CODEC_ID_MP3:
6cac3a3b 108 flags |= FLV_CODECID_MP3 | FLV_SAMPLESSIZE_16BIT;
37cdf93d 109 break;
8e9efe43 110 case CODEC_ID_PCM_U8:
44de39f9 111 flags |= FLV_CODECID_PCM | FLV_SAMPLESSIZE_8BIT;
bb270c08 112 break;
923bd441 113 case CODEC_ID_PCM_S16BE:
44de39f9 114 flags |= FLV_CODECID_PCM | FLV_SAMPLESSIZE_16BIT;
bb270c08 115 break;
923bd441 116 case CODEC_ID_PCM_S16LE:
6cac3a3b 117 flags |= FLV_CODECID_PCM_LE | FLV_SAMPLESSIZE_16BIT;
bb270c08 118 break;
2fde8aae 119 case CODEC_ID_ADPCM_SWF:
e9509536 120 flags |= FLV_CODECID_ADPCM | FLV_SAMPLESSIZE_16BIT;
bb270c08 121 break;
b7d1cd02 122 case CODEC_ID_NELLYMOSER:
8ddd280d
AW
123 if (enc->sample_rate == 8000) {
124 flags |= FLV_CODECID_NELLYMOSER_8KHZ_MONO | FLV_SAMPLESSIZE_16BIT;
125 } else {
126 flags |= FLV_CODECID_NELLYMOSER | FLV_SAMPLESSIZE_16BIT;
127 }
b7d1cd02 128 break;
37cdf93d
MN
129 case 0:
130 flags |= enc->codec_tag<<4;
131 break;
132 default:
a254c574 133 av_log(enc, AV_LOG_ERROR, "codec not compatible with flv\n");
37cdf93d
MN
134 return -1;
135 }
115329f1 136
37cdf93d
MN
137 return flags;
138}
139
ae628ec1 140static void put_amf_string(AVIOContext *pb, const char *str)
fd0fb306
MN
141{
142 size_t len = strlen(str);
77eb5504
AK
143 avio_wb16(pb, len);
144 avio_write(pb, str, len);
fd0fb306
MN
145}
146
ae628ec1 147static void put_avc_eos_tag(AVIOContext *pb, unsigned ts) {
77eb5504
AK
148 avio_w8(pb, FLV_TAG_TYPE_VIDEO);
149 avio_wb24(pb, 5); /* Tag Data Size */
150 avio_wb24(pb, ts); /* lower 24 bits of timestamp in ms*/
151 avio_w8(pb, (ts >> 24) & 0x7F); /* MSB of ts in ms*/
152 avio_wb24(pb, 0); /* StreamId = 0 */
153 avio_w8(pb, 23); /* ub[4] FrameType = 1, ub[4] CodecId = 7 */
154 avio_w8(pb, 2); /* AVC end of sequence */
155 avio_wb24(pb, 0); /* Always 0 for AVC EOS. */
156 avio_wb32(pb, 16); /* Size of FLV tag */
df4f1d51
TF
157}
158
ae628ec1 159static void put_amf_double(AVIOContext *pb, double d)
fd0fb306 160{
77eb5504
AK
161 avio_w8(pb, AMF_DATA_TYPE_NUMBER);
162 avio_wb64(pb, av_dbl2int(d));
fd0fb306
MN
163}
164
ae628ec1 165static void put_amf_bool(AVIOContext *pb, int b) {
77eb5504
AK
166 avio_w8(pb, AMF_DATA_TYPE_BOOL);
167 avio_w8(pb, !!b);
148c9bdb
AH
168}
169
d4f5d74a
GM
170static int flv_write_header(AVFormatContext *s)
171{
ae628ec1 172 AVIOContext *pb = s->pb;
d4f5d74a 173 FLVContext *flv = s->priv_data;
5366f15d 174 AVCodecContext *audio_enc = NULL, *video_enc = NULL;
cad0c375 175 int i, metadata_count = 0;
fd0fb306 176 double framerate = 0.0;
cad0c375 177 int64_t metadata_size_pos, data_size, metadata_count_pos;
d2d67e42 178 AVDictionaryEntry *tag = NULL;
d4f5d74a 179
11a8e425 180 for(i=0; i<s->nb_streams; i++){
01f4895c 181 AVCodecContext *enc = s->streams[i]->codec;
72415b2a 182 if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {
fd0fb306
MN
183 if (s->streams[i]->r_frame_rate.den && s->streams[i]->r_frame_rate.num) {
184 framerate = av_q2d(s->streams[i]->r_frame_rate);
185 } else {
186 framerate = 1/av_q2d(s->streams[i]->codec->time_base);
187 }
5366f15d
BC
188 video_enc = enc;
189 if(enc->codec_tag == 0) {
148c9bdb
AH
190 av_log(enc, AV_LOG_ERROR, "video codec not compatible with flv\n");
191 return -1;
192 }
fd0fb306 193 } else {
5366f15d 194 audio_enc = enc;
c45388b1
MN
195 if(get_audio_flags(enc)<0)
196 return -1;
fd0fb306 197 }
254629b1 198 av_set_pts_info(s->streams[i], 32, 1, 1000); /* 32 bit pts in ms */
c45388b1 199 }
bbc413f9 200 avio_write(pb, "FLV", 3);
77eb5504
AK
201 avio_w8(pb,1);
202 avio_w8(pb, FLV_HEADER_FLAG_HASAUDIO * !!audio_enc
5366f15d 203 + FLV_HEADER_FLAG_HASVIDEO * !!video_enc);
77eb5504
AK
204 avio_wb32(pb,9);
205 avio_wb32(pb,0);
c45388b1
MN
206
207 for(i=0; i<s->nb_streams; i++){
208 if(s->streams[i]->codec->codec_tag == 5){
77eb5504
AK
209 avio_w8(pb,8); // message type
210 avio_wb24(pb,0); // include flags
211 avio_wb24(pb,0); // time stamp
212 avio_wb32(pb,0); // reserved
213 avio_wb32(pb,11); // size
11a8e425
MN
214 flv->reserved=5;
215 }
216 }
d4f5d74a 217
4ee247a2 218 flv->last_ts = -1;
df4f1d51 219
fd0fb306 220 /* write meta_tag */
77eb5504 221 avio_w8(pb, 18); // tag type META
a2704c97 222 metadata_size_pos= avio_tell(pb);
77eb5504
AK
223 avio_wb24(pb, 0); // size of data part (sum of all parts below)
224 avio_wb24(pb, 0); // time stamp
225 avio_wb32(pb, 0); // reserved
fd0fb306
MN
226
227 /* now data of data_size size */
228
229 /* first event name as a string */
77eb5504 230 avio_w8(pb, AMF_DATA_TYPE_STRING);
fd0fb306
MN
231 put_amf_string(pb, "onMetaData"); // 12 bytes
232
233 /* mixed array (hash) with size and string/type/data tuples */
77eb5504 234 avio_w8(pb, AMF_DATA_TYPE_MIXEDARRAY);
cad0c375
MS
235 metadata_count_pos = avio_tell(pb);
236 metadata_count = 5*!!video_enc + 5*!!audio_enc + 2; // +2 for duration and file size
237 avio_wb32(pb, metadata_count);
fd0fb306 238
634b8cfa 239 put_amf_string(pb, "duration");
a2704c97 240 flv->duration_offset= avio_tell(pb);
c5e1e982 241 put_amf_double(pb, s->duration / AV_TIME_BASE); // fill in the guessed duration, it'll be corrected later if incorrect
fd0fb306 242
5366f15d 243 if(video_enc){
fd0fb306 244 put_amf_string(pb, "width");
5366f15d 245 put_amf_double(pb, video_enc->width);
fd0fb306
MN
246
247 put_amf_string(pb, "height");
5366f15d 248 put_amf_double(pb, video_enc->height);
fd0fb306
MN
249
250 put_amf_string(pb, "videodatarate");
426a6f34 251 put_amf_double(pb, video_enc->bit_rate / 1024.0);
fd0fb306
MN
252
253 put_amf_string(pb, "framerate");
254 put_amf_double(pb, framerate);
148c9bdb
AH
255
256 put_amf_string(pb, "videocodecid");
5366f15d 257 put_amf_double(pb, video_enc->codec_tag);
fd0fb306
MN
258 }
259
5366f15d 260 if(audio_enc){
426a6f34
SK
261 put_amf_string(pb, "audiodatarate");
262 put_amf_double(pb, audio_enc->bit_rate / 1024.0);
263
fd0fb306 264 put_amf_string(pb, "audiosamplerate");
5366f15d 265 put_amf_double(pb, audio_enc->sample_rate);
148c9bdb
AH
266
267 put_amf_string(pb, "audiosamplesize");
8e9efe43 268 put_amf_double(pb, audio_enc->codec_id == CODEC_ID_PCM_U8 ? 8 : 16);
148c9bdb
AH
269
270 put_amf_string(pb, "stereo");
5366f15d 271 put_amf_bool(pb, audio_enc->channels == 2);
148c9bdb
AH
272
273 put_amf_string(pb, "audiocodecid");
5366f15d 274 put_amf_double(pb, audio_enc->codec_tag);
fd0fb306
MN
275 }
276
d2d67e42 277 while ((tag = av_dict_get(s->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
16f82508 278 put_amf_string(pb, tag->key);
77eb5504 279 avio_w8(pb, AMF_DATA_TYPE_STRING);
16f82508 280 put_amf_string(pb, tag->value);
cad0c375 281 metadata_count++;
16f82508
TT
282 }
283
634b8cfa 284 put_amf_string(pb, "filesize");
a2704c97 285 flv->filesize_offset= avio_tell(pb);
634b8cfa 286 put_amf_double(pb, 0); // delayed write
fd0fb306
MN
287
288 put_amf_string(pb, "");
77eb5504 289 avio_w8(pb, AMF_END_OF_OBJECT);
fd0fb306
MN
290
291 /* write total size of tag */
a2704c97 292 data_size= avio_tell(pb) - metadata_size_pos - 10;
cad0c375
MS
293
294 avio_seek(pb, metadata_count_pos, SEEK_SET);
295 avio_wb32(pb, metadata_count);
296
6b4aa5da 297 avio_seek(pb, metadata_size_pos, SEEK_SET);
77eb5504 298 avio_wb24(pb, data_size);
45a8a02a 299 avio_skip(pb, data_size + 10 - 3);
77eb5504 300 avio_wb32(pb, data_size + 11);
fd0fb306 301
f23496b5
BC
302 for (i = 0; i < s->nb_streams; i++) {
303 AVCodecContext *enc = s->streams[i]->codec;
304 if (enc->codec_id == CODEC_ID_AAC || enc->codec_id == CODEC_ID_H264) {
bc5c918e 305 int64_t pos;
77eb5504 306 avio_w8(pb, enc->codec_type == AVMEDIA_TYPE_VIDEO ?
f23496b5 307 FLV_TAG_TYPE_VIDEO : FLV_TAG_TYPE_AUDIO);
77eb5504
AK
308 avio_wb24(pb, 0); // size patched later
309 avio_wb24(pb, 0); // ts
310 avio_w8(pb, 0); // ts ext
311 avio_wb24(pb, 0); // streamid
a2704c97 312 pos = avio_tell(pb);
f23496b5 313 if (enc->codec_id == CODEC_ID_AAC) {
77eb5504
AK
314 avio_w8(pb, get_audio_flags(enc));
315 avio_w8(pb, 0); // AAC sequence header
316 avio_write(pb, enc->extradata, enc->extradata_size);
f23496b5 317 } else {
77eb5504
AK
318 avio_w8(pb, enc->codec_tag | FLV_FRAME_KEY); // flags
319 avio_w8(pb, 0); // AVC sequence header
320 avio_wb24(pb, 0); // composition time
f23496b5
BC
321 ff_isom_write_avcc(pb, enc->extradata, enc->extradata_size);
322 }
a2704c97 323 data_size = avio_tell(pb) - pos;
6b4aa5da 324 avio_seek(pb, -data_size - 10, SEEK_CUR);
77eb5504 325 avio_wb24(pb, data_size);
45a8a02a 326 avio_skip(pb, data_size + 10 - 3);
77eb5504 327 avio_wb32(pb, data_size + 11); // previous tag size
f23496b5
BC
328 }
329 }
330
d4f5d74a
GM
331 return 0;
332}
333
d4f5d74a
GM
334static int flv_write_trailer(AVFormatContext *s)
335{
14b32253 336 int64_t file_size;
14b32253 337
ae628ec1 338 AVIOContext *pb = s->pb;
d4f5d74a 339 FLVContext *flv = s->priv_data;
df4f1d51
TF
340 int i;
341
342 /* Add EOS tag */
343 for (i = 0; i < s->nb_streams; i++) {
344 AVCodecContext *enc = s->streams[i]->codec;
b9f9e59a 345 if (enc->codec_type == AVMEDIA_TYPE_VIDEO &&
df4f1d51 346 enc->codec_id == CODEC_ID_H264) {
4ee247a2 347 put_avc_eos_tag(pb, flv->last_ts);
df4f1d51
TF
348 }
349 }
d4f5d74a 350
a2704c97 351 file_size = avio_tell(pb);
634b8cfa
BC
352
353 /* update informations */
6b4aa5da 354 avio_seek(pb, flv->duration_offset, SEEK_SET);
634b8cfa 355 put_amf_double(pb, flv->duration / (double)1000);
6b4aa5da 356 avio_seek(pb, flv->filesize_offset, SEEK_SET);
634b8cfa
BC
357 put_amf_double(pb, file_size);
358
6b4aa5da 359 avio_seek(pb, file_size, SEEK_SET);
d4f5d74a
GM
360 return 0;
361}
362
e928649b 363static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
d4f5d74a 364{
ae628ec1 365 AVIOContext *pb = s->pb;
01f4895c 366 AVCodecContext *enc = s->streams[pkt->stream_index]->codec;
d4f5d74a 367 FLVContext *flv = s->priv_data;
f23496b5 368 unsigned ts;
e928649b 369 int size= pkt->size;
71e685b0 370 uint8_t *data= NULL;
f683dbdc 371 int flags, flags_size;
d4f5d74a 372
949b1a13 373// av_log(s, AV_LOG_DEBUG, "type:%d pts: %"PRId64" size:%d\n", enc->codec_type, timestamp, size);
115329f1 374
f23496b5
BC
375 if(enc->codec_id == CODEC_ID_VP6 || enc->codec_id == CODEC_ID_VP6F ||
376 enc->codec_id == CODEC_ID_AAC)
f683dbdc 377 flags_size= 2;
f23496b5
BC
378 else if(enc->codec_id == CODEC_ID_H264)
379 flags_size= 5;
f683dbdc
MN
380 else
381 flags_size= 1;
382
72415b2a 383 if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {
77eb5504 384 avio_w8(pb, FLV_TAG_TYPE_VIDEO);
09d8c0ae 385
bb85077f 386 flags = enc->codec_tag;
09d8c0ae
BL
387 if(flags == 0) {
388 av_log(enc, AV_LOG_ERROR, "video codec %X not compatible with flv\n",enc->codec_id);
389 return -1;
390 }
391
cc947f04 392 flags |= pkt->flags & AV_PKT_FLAG_KEY ? FLV_FRAME_KEY : FLV_FRAME_INTER;
75293f05 393 } else {
72415b2a 394 assert(enc->codec_type == AVMEDIA_TYPE_AUDIO);
37cdf93d 395 flags = get_audio_flags(enc);
115329f1 396
068f2a22 397 assert(size);
068f2a22 398
77eb5504 399 avio_w8(pb, FLV_TAG_TYPE_AUDIO);
75293f05
MN
400 }
401
7d637efa 402 if (enc->codec_id == CODEC_ID_H264) {
71e685b0
BC
403 /* check if extradata looks like mp4 formated */
404 if (enc->extradata_size > 0 && *(uint8_t*)enc->extradata != 1) {
405 if (ff_avc_parse_nal_units_buf(pkt->data, &data, &size) < 0)
406 return -1;
407 }
f23496b5 408 }
52375ba5
JR
409 if (!flv->delay && pkt->dts < 0)
410 flv->delay = -pkt->dts;
f23496b5
BC
411
412 ts = pkt->dts + flv->delay; // add delay to force positive dts
4ee247a2
JR
413
414 /* check Speex packet duration */
415 if (enc->codec_id == CODEC_ID_SPEEX && ts - flv->last_ts > 160) {
416 av_log(s, AV_LOG_WARNING, "Warning: Speex stream has more than "
417 "8 frames per packet. Adobe Flash "
418 "Player cannot handle this!\n");
df4f1d51 419 }
4ee247a2
JR
420
421 if (flv->last_ts < ts)
422 flv->last_ts = ts;
423
77eb5504
AK
424 avio_wb24(pb,size + flags_size);
425 avio_wb24(pb,ts);
426 avio_w8(pb,(ts >> 24) & 0x7F); // timestamps are 32bits _signed_
427 avio_wb24(pb,flv->reserved);
428 avio_w8(pb,flags);
09d8c0ae 429 if (enc->codec_id == CODEC_ID_VP6)
77eb5504 430 avio_w8(pb,0);
09d8c0ae 431 if (enc->codec_id == CODEC_ID_VP6F)
77eb5504 432 avio_w8(pb, enc->extradata_size ? enc->extradata[0] : 0);
f23496b5 433 else if (enc->codec_id == CODEC_ID_AAC)
77eb5504 434 avio_w8(pb,1); // AAC raw
f23496b5 435 else if (enc->codec_id == CODEC_ID_H264) {
77eb5504
AK
436 avio_w8(pb,1); // AVC NALU
437 avio_wb24(pb,pkt->pts - pkt->dts);
f23496b5 438 }
71e685b0 439
77eb5504 440 avio_write(pb, data ? data : pkt->data, size);
71e685b0 441
77eb5504 442 avio_wb32(pb,size+flags_size+11); // previous tag size
f23496b5 443 flv->duration = FFMAX(flv->duration, pkt->pts + flv->delay + pkt->duration);
115329f1 444
b7f2fdde 445 avio_flush(pb);
71e685b0
BC
446
447 av_free(data);
448
0e28e9ca 449 return pb->error;
d4f5d74a
GM
450}
451
c6610a21 452AVOutputFormat ff_flv_muxer = {
dfc2c4d9
AK
453 .name = "flv",
454 .long_name = NULL_IF_CONFIG_SMALL("FLV format"),
455 .mime_type = "video/x-flv",
456 .extensions = "flv",
457 .priv_data_size = sizeof(FLVContext),
b250f9c6 458#if CONFIG_LIBMP3LAME
dfc2c4d9 459 .audio_codec = CODEC_ID_MP3,
6ebe07fb 460#else // CONFIG_LIBMP3LAME
dfc2c4d9 461 .audio_codec = CODEC_ID_ADPCM_SWF,
6ebe07fb 462#endif // CONFIG_LIBMP3LAME
dfc2c4d9
AK
463 .video_codec = CODEC_ID_FLV1,
464 .write_header = flv_write_header,
465 .write_packet = flv_write_packet,
466 .write_trailer = flv_write_trailer,
c1854592 467 .codec_tag= (const AVCodecTag* const []){flv_video_codec_ids, flv_audio_codec_ids, 0},
e458dd0b 468 .flags= AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS,
d4f5d74a 469};