Libav
flvenc.c
Go to the documentation of this file.
1 /*
2  * FLV muxer
3  * Copyright (c) 2003 The Libav Project
4  *
5  * This file is part of Libav.
6  *
7  * Libav is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * 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  * Libav is distributed in the hope that it will be useful,
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
18  * License along with Libav; 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/dict.h"
23 #include "libavutil/intfloat.h"
24 #include "avc.h"
25 #include "avformat.h"
26 #include "flv.h"
27 #include "internal.h"
28 #include "metadata.h"
29 
30 #undef NDEBUG
31 #include <assert.h>
32 
33 static const AVCodecTag flv_video_codec_ids[] = {
40  { AV_CODEC_ID_NONE, 0 }
41 };
42 
43 static const AVCodecTag flv_audio_codec_ids[] = {
54  { AV_CODEC_ID_NONE, 0 }
55 };
56 
57 typedef struct FLVContext {
58  int reserved;
59  int64_t duration_offset;
60  int64_t filesize_offset;
61  int64_t duration;
62  int64_t delay;
63 } FLVContext;
64 
65 typedef struct FLVStreamContext {
66  int64_t last_ts;
68 
70 {
73 
74  if (enc->codec_id == AV_CODEC_ID_AAC) // specs force these parameters
77  else if (enc->codec_id == AV_CODEC_ID_SPEEX) {
78  if (enc->sample_rate != 16000) {
80  "flv only supports wideband (16kHz) Speex audio\n");
81  return -1;
82  }
83  if (enc->channels != 1) {
84  av_log(s, AV_LOG_ERROR, "flv only supports mono Speex audio\n");
85  return -1;
86  }
88  } else {
89  switch (enc->sample_rate) {
90  case 44100:
91  flags |= FLV_SAMPLERATE_44100HZ;
92  break;
93  case 22050:
94  flags |= FLV_SAMPLERATE_22050HZ;
95  break;
96  case 11025:
97  flags |= FLV_SAMPLERATE_11025HZ;
98  break;
99  case 16000: // nellymoser only
100  case 8000: // nellymoser only
101  case 5512: // not MP3
102  if (enc->codec_id != AV_CODEC_ID_MP3) {
103  flags |= FLV_SAMPLERATE_SPECIAL;
104  break;
105  }
106  default:
107  av_log(s, AV_LOG_ERROR,
108  "flv does not support that sample rate, "
109  "choose from (44100, 22050, 11025).\n");
110  return -1;
111  }
112  }
113 
114  if (enc->channels > 1)
115  flags |= FLV_STEREO;
116 
117  switch (enc->codec_id) {
118  case AV_CODEC_ID_MP3:
120  break;
121  case AV_CODEC_ID_PCM_U8:
123  break;
126  break;
129  break;
132  break;
134  if (enc->sample_rate == 8000)
136  else if (enc->sample_rate == 16000)
138  else
140  break;
143  break;
146  break;
147  case 0:
148  flags |= enc->codec_tag << 4;
149  break;
150  default:
151  av_log(s, AV_LOG_ERROR, "codec not compatible with flv\n");
152  return -1;
153  }
154 
155  return flags;
156 }
157 
158 static void put_amf_string(AVIOContext *pb, const char *str)
159 {
160  size_t len = strlen(str);
161  avio_wb16(pb, len);
162  avio_write(pb, str, len);
163 }
164 
165 static void put_avc_eos_tag(AVIOContext *pb, unsigned ts)
166 {
168  avio_wb24(pb, 5); /* Tag Data Size */
169  avio_wb24(pb, ts); /* lower 24 bits of timestamp in ms */
170  avio_w8(pb, (ts >> 24) & 0x7F); /* MSB of ts in ms */
171  avio_wb24(pb, 0); /* StreamId = 0 */
172  avio_w8(pb, 23); /* ub[4] FrameType = 1, ub[4] CodecId = 7 */
173  avio_w8(pb, 2); /* AVC end of sequence */
174  avio_wb24(pb, 0); /* Always 0 for AVC EOS. */
175  avio_wb32(pb, 16); /* Size of FLV tag */
176 }
177 
178 static void put_amf_double(AVIOContext *pb, double d)
179 {
181  avio_wb64(pb, av_double2int(d));
182 }
183 
184 static void put_amf_bool(AVIOContext *pb, int b)
185 {
187  avio_w8(pb, !!b);
188 }
189 
191 {
192  AVIOContext *pb = s->pb;
193  FLVContext *flv = s->priv_data;
194  AVCodecContext *audio_enc = NULL, *video_enc = NULL, *data_enc = NULL;
195  int i, metadata_count = 0;
196  double framerate = 0.0;
197  int64_t metadata_size_pos, data_size, metadata_count_pos;
199 
200  for (i = 0; i < s->nb_streams; i++) {
201  AVCodecContext *enc = s->streams[i]->codec;
202  FLVStreamContext *sc;
203  switch (enc->codec_type) {
204  case AVMEDIA_TYPE_VIDEO:
205  if (s->streams[i]->avg_frame_rate.den &&
206  s->streams[i]->avg_frame_rate.num) {
207  framerate = av_q2d(s->streams[i]->avg_frame_rate);
208  } else {
209  framerate = 1 / av_q2d(s->streams[i]->codec->time_base);
210  }
211  if (video_enc) {
212  av_log(s, AV_LOG_ERROR,
213  "at most one video stream is supported in flv\n");
214  return AVERROR(EINVAL);
215  }
216  video_enc = enc;
217  if (enc->codec_tag == 0) {
218  av_log(s, AV_LOG_ERROR, "video codec not compatible with flv\n");
219  return -1;
220  }
221  break;
222  case AVMEDIA_TYPE_AUDIO:
223  if (audio_enc) {
224  av_log(s, AV_LOG_ERROR,
225  "at most one audio stream is supported in flv\n");
226  return AVERROR(EINVAL);
227  }
228  audio_enc = enc;
229  if (get_audio_flags(s, enc) < 0)
230  return AVERROR_INVALIDDATA;
231  break;
232  case AVMEDIA_TYPE_DATA:
233  if (enc->codec_id != AV_CODEC_ID_TEXT) {
234  av_log(s, AV_LOG_ERROR, "codec not compatible with flv\n");
235  return AVERROR_INVALIDDATA;
236  }
237  data_enc = enc;
238  break;
239  default:
240  av_log(s, AV_LOG_ERROR, "codec not compatible with flv\n");
241  return -1;
242  }
243  avpriv_set_pts_info(s->streams[i], 32, 1, 1000); /* 32 bit pts in ms */
244 
245  sc = av_mallocz(sizeof(FLVStreamContext));
246  if (!sc)
247  return AVERROR(ENOMEM);
248  s->streams[i]->priv_data = sc;
249  sc->last_ts = -1;
250  }
251 
252  flv->delay = AV_NOPTS_VALUE;
253 
254  avio_write(pb, "FLV", 3);
255  avio_w8(pb, 1);
256  avio_w8(pb, FLV_HEADER_FLAG_HASAUDIO * !!audio_enc +
257  FLV_HEADER_FLAG_HASVIDEO * !!video_enc);
258  avio_wb32(pb, 9);
259  avio_wb32(pb, 0);
260 
261  for (i = 0; i < s->nb_streams; i++)
262  if (s->streams[i]->codec->codec_tag == 5) {
263  avio_w8(pb, 8); // message type
264  avio_wb24(pb, 0); // include flags
265  avio_wb24(pb, 0); // time stamp
266  avio_wb32(pb, 0); // reserved
267  avio_wb32(pb, 11); // size
268  flv->reserved = 5;
269  }
270 
271  /* write meta_tag */
272  avio_w8(pb, 18); // tag type META
273  metadata_size_pos = avio_tell(pb);
274  avio_wb24(pb, 0); // size of data part (sum of all parts below)
275  avio_wb24(pb, 0); // timestamp
276  avio_wb32(pb, 0); // reserved
277 
278  /* now data of data_size size */
279 
280  /* first event name as a string */
282  put_amf_string(pb, "onMetaData"); // 12 bytes
283 
284  /* mixed array (hash) with size and string/type/data tuples */
286  metadata_count_pos = avio_tell(pb);
287  metadata_count = 5 * !!video_enc +
288  5 * !!audio_enc +
289  1 * !!data_enc +
290  2; // +2 for duration and file size
291 
292  avio_wb32(pb, metadata_count);
293 
294  put_amf_string(pb, "duration");
295  flv->duration_offset= avio_tell(pb);
296 
297  // fill in the guessed duration, it'll be corrected later if incorrect
299 
300  if (video_enc) {
301  put_amf_string(pb, "width");
302  put_amf_double(pb, video_enc->width);
303 
304  put_amf_string(pb, "height");
305  put_amf_double(pb, video_enc->height);
306 
307  put_amf_string(pb, "videodatarate");
308  put_amf_double(pb, video_enc->bit_rate / 1024.0);
309 
310  put_amf_string(pb, "framerate");
311  put_amf_double(pb, framerate);
312 
313  put_amf_string(pb, "videocodecid");
314  put_amf_double(pb, video_enc->codec_tag);
315  }
316 
317  if (audio_enc) {
318  put_amf_string(pb, "audiodatarate");
319  put_amf_double(pb, audio_enc->bit_rate / 1024.0);
320 
321  put_amf_string(pb, "audiosamplerate");
322  put_amf_double(pb, audio_enc->sample_rate);
323 
324  put_amf_string(pb, "audiosamplesize");
325  put_amf_double(pb, audio_enc->codec_id == AV_CODEC_ID_PCM_U8 ? 8 : 16);
326 
327  put_amf_string(pb, "stereo");
328  put_amf_bool(pb, audio_enc->channels == 2);
329 
330  put_amf_string(pb, "audiocodecid");
331  put_amf_double(pb, audio_enc->codec_tag);
332  }
333 
334  if (data_enc) {
335  put_amf_string(pb, "datastream");
336  put_amf_double(pb, 0.0);
337  }
338 
339  while ((tag = av_dict_get(s->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
340  put_amf_string(pb, tag->key);
342  put_amf_string(pb, tag->value);
343  metadata_count++;
344  }
345 
346  put_amf_string(pb, "filesize");
347  flv->filesize_offset = avio_tell(pb);
348  put_amf_double(pb, 0); // delayed write
349 
350  put_amf_string(pb, "");
352 
353  /* write total size of tag */
354  data_size = avio_tell(pb) - metadata_size_pos - 10;
355 
356  avio_seek(pb, metadata_count_pos, SEEK_SET);
357  avio_wb32(pb, metadata_count);
358 
359  avio_seek(pb, metadata_size_pos, SEEK_SET);
360  avio_wb24(pb, data_size);
361  avio_skip(pb, data_size + 10 - 3);
362  avio_wb32(pb, data_size + 11);
363 
364  for (i = 0; i < s->nb_streams; i++) {
365  AVCodecContext *enc = s->streams[i]->codec;
366  if (enc->codec_id == AV_CODEC_ID_AAC || enc->codec_id == AV_CODEC_ID_H264) {
367  int64_t pos;
370  avio_wb24(pb, 0); // size patched later
371  avio_wb24(pb, 0); // ts
372  avio_w8(pb, 0); // ts ext
373  avio_wb24(pb, 0); // streamid
374  pos = avio_tell(pb);
375  if (enc->codec_id == AV_CODEC_ID_AAC) {
376  avio_w8(pb, get_audio_flags(s, enc));
377  avio_w8(pb, 0); // AAC sequence header
378  avio_write(pb, enc->extradata, enc->extradata_size);
379  } else {
380  avio_w8(pb, enc->codec_tag | FLV_FRAME_KEY); // flags
381  avio_w8(pb, 0); // AVC sequence header
382  avio_wb24(pb, 0); // composition time
384  }
385  data_size = avio_tell(pb) - pos;
386  avio_seek(pb, -data_size - 10, SEEK_CUR);
387  avio_wb24(pb, data_size);
388  avio_skip(pb, data_size + 10 - 3);
389  avio_wb32(pb, data_size + 11); // previous tag size
390  }
391  }
392 
393  return 0;
394 }
395 
397 {
398  int64_t file_size;
399 
400  AVIOContext *pb = s->pb;
401  FLVContext *flv = s->priv_data;
402  int i;
403 
404  /* Add EOS tag */
405  for (i = 0; i < s->nb_streams; i++) {
406  AVCodecContext *enc = s->streams[i]->codec;
407  FLVStreamContext *sc = s->streams[i]->priv_data;
408  if (enc->codec_type == AVMEDIA_TYPE_VIDEO &&
409  enc->codec_id == AV_CODEC_ID_H264)
410  put_avc_eos_tag(pb, sc->last_ts);
411  }
412 
413  file_size = avio_tell(pb);
414 
415  /* update information */
416  if (avio_seek(pb, flv->duration_offset, SEEK_SET) < 0)
417  av_log(s, AV_LOG_WARNING, "Failed to update header with correct duration.\n");
418  else
419  put_amf_double(pb, flv->duration / (double)1000);
420  if (avio_seek(pb, flv->filesize_offset, SEEK_SET) < 0)
421  av_log(s, AV_LOG_WARNING, "Failed to update header with correct filesize.\n");
422  else
423  put_amf_double(pb, file_size);
424 
425  avio_seek(pb, file_size, SEEK_SET);
426  return 0;
427 }
428 
430 {
431  AVIOContext *pb = s->pb;
432  AVCodecContext *enc = s->streams[pkt->stream_index]->codec;
433  FLVContext *flv = s->priv_data;
435  unsigned ts;
436  int size = pkt->size;
437  uint8_t *data = NULL;
438  int flags = 0, flags_size;
439 
440  if (enc->codec_id == AV_CODEC_ID_VP6F || enc->codec_id == AV_CODEC_ID_VP6A ||
441  enc->codec_id == AV_CODEC_ID_AAC)
442  flags_size = 2;
443  else if (enc->codec_id == AV_CODEC_ID_H264)
444  flags_size = 5;
445  else
446  flags_size = 1;
447 
448  switch (enc->codec_type) {
449  case AVMEDIA_TYPE_VIDEO:
451 
452  flags = enc->codec_tag;
453  if (flags == 0) {
454  av_log(s, AV_LOG_ERROR,
455  "video codec %X not compatible with flv\n",
456  enc->codec_id);
457  return -1;
458  }
459 
461  break;
462  case AVMEDIA_TYPE_AUDIO:
463  flags = get_audio_flags(s, enc);
464 
465  assert(size);
466 
468  break;
469  case AVMEDIA_TYPE_DATA:
471  break;
472  default:
473  return AVERROR(EINVAL);
474  }
475 
476  if (enc->codec_id == AV_CODEC_ID_H264)
477  /* check if extradata looks like MP4 */
478  if (enc->extradata_size > 0 && *(uint8_t*)enc->extradata != 1)
479  if (ff_avc_parse_nal_units_buf(pkt->data, &data, &size) < 0)
480  return -1;
481 
482  if (flv->delay == AV_NOPTS_VALUE)
483  flv->delay = -pkt->dts;
484 
485  if (pkt->dts < -flv->delay) {
487  "Packets are not in the proper order with respect to DTS\n");
488  return AVERROR(EINVAL);
489  }
490 
491  ts = pkt->dts + flv->delay; // add delay to force positive dts
492 
493  /* check Speex packet duration */
494  if (enc->codec_id == AV_CODEC_ID_SPEEX && ts - sc->last_ts > 160)
495  av_log(s, AV_LOG_WARNING, "Warning: Speex stream has more than "
496  "8 frames per packet. Adobe Flash "
497  "Player cannot handle this!\n");
498 
499  if (sc->last_ts < ts)
500  sc->last_ts = ts;
501 
502  avio_wb24(pb, size + flags_size);
503  avio_wb24(pb, ts);
504  avio_w8(pb, (ts >> 24) & 0x7F); // timestamps are 32 bits _signed_
505  avio_wb24(pb, flv->reserved);
506 
507  if (enc->codec_type == AVMEDIA_TYPE_DATA) {
508  int data_size;
509  int64_t metadata_size_pos = avio_tell(pb);
511  put_amf_string(pb, "onTextData");
513  avio_wb32(pb, 2);
514  put_amf_string(pb, "type");
516  put_amf_string(pb, "Text");
517  put_amf_string(pb, "text");
519  put_amf_string(pb, pkt->data);
520  put_amf_string(pb, "");
522  /* write total size of tag */
523  data_size = avio_tell(pb) - metadata_size_pos;
524  avio_seek(pb, metadata_size_pos - 10, SEEK_SET);
525  avio_wb24(pb, data_size);
526  avio_seek(pb, data_size + 10 - 3, SEEK_CUR);
527  avio_wb32(pb, data_size + 11);
528  } else {
529  avio_w8(pb,flags);
530  if (enc->codec_id == AV_CODEC_ID_VP6F || enc->codec_id == AV_CODEC_ID_VP6A) {
531  if (enc->extradata_size)
532  avio_w8(pb, enc->extradata[0]);
533  else
534  avio_w8(pb, ((FFALIGN(enc->width, 16) - enc->width) << 4) |
535  (FFALIGN(enc->height, 16) - enc->height));
536  } else if (enc->codec_id == AV_CODEC_ID_AAC)
537  avio_w8(pb, 1); // AAC raw
538  else if (enc->codec_id == AV_CODEC_ID_H264) {
539  avio_w8(pb, 1); // AVC NALU
540  avio_wb24(pb, pkt->pts - pkt->dts);
541  }
542 
543  avio_write(pb, data ? data : pkt->data, size);
544 
545  avio_wb32(pb, size + flags_size + 11); // previous tag size
546  flv->duration = FFMAX(flv->duration,
547  pkt->pts + flv->delay + pkt->duration);
548  }
549 
550  av_free(data);
551 
552  return pb->error;
553 }
554 
556  .name = "flv",
557  .long_name = NULL_IF_CONFIG_SMALL("FLV (Flash Video)"),
558  .mime_type = "video/x-flv",
559  .extensions = "flv",
560  .priv_data_size = sizeof(FLVContext),
562  .video_codec = AV_CODEC_ID_FLV1,
566  .codec_tag = (const AVCodecTag* const []) {
568  },
571 };
void avio_wb64(AVIOContext *s, uint64_t val)
Definition: aviobuf.c:330
static const AVCodecTag flv_audio_codec_ids[]
Definition: flvenc.c:43
Bytestream IO Context.
Definition: avio.h:68
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:54
int size
AVOutputFormat ff_flv_muxer
Definition: flvenc.c:555
int64_t delay
first dts delay (needed for AVC & Speex)
Definition: flvenc.c:62
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:129
void avpriv_set_pts_info(AVStream *s, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition: utils.c:3208
static int write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: assenc.c:58
int64_t duration
Definition: flvenc.c:61
int num
numerator
Definition: rational.h:44
int size
Definition: avcodec.h:974
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:186
signifies 5512Hz and 8000Hz in the case of NELLYMOSER
Definition: flv.h:71
static av_always_inline uint64_t av_double2int(double f)
Reinterpret a double as a 64-bit integer.
Definition: intfloat.h:70
void * priv_data
Definition: avformat.h:703
AVDictionaryEntry * av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
Definition: dict.c:39
static int get_audio_flags(AVFormatContext *s, AVCodecContext *enc)
Definition: flvenc.c:69
#define AVFMT_TS_NONSTRICT
Format does not require strictly increasing timestamps, but they must still be monotonic.
Definition: avformat.h:417
#define FFALIGN(x, a)
Definition: common.h:62
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
Definition: avcodec.h:1173
static const AVCodecTag flv_video_codec_ids[]
Definition: flvenc.c:33
Format I/O context.
Definition: avformat.h:871
internal metadata API header see avformat.h or the public API!
Public dictionary API.
uint8_t
Opaque data information usually continuous.
Definition: avutil.h:189
#define b
Definition: input.c:52
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:1162
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:935
const char data[16]
Definition: mxf.c:66
static double av_q2d(AVRational a)
Convert rational to double.
Definition: rational.h:69
uint8_t * data
Definition: avcodec.h:973
static int flags
Definition: log.c:44
uint32_t tag
Definition: movenc.c:822
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:219
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
Definition: avcodec.h:2481
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:165
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: avcodec.h:995
static int write_trailer(AVFormatContext *s)
Definition: assenc.c:64
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: avcodec.h:1023
static int flv_write_trailer(AVFormatContext *s)
Definition: flvenc.c:396
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:123
AVDictionary * metadata
Metadata that applies to the whole file.
Definition: avformat.h:1064
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
Definition: mem.c:186
#define AVERROR(e)
Definition: error.h:43
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:142
preferred ID for decoding MPEG audio layer 1, 2 or 3
Definition: avcodec.h:369
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:148
AVRational avg_frame_rate
Average framerate.
Definition: avformat.h:754
#define FFMAX(a, b)
Definition: common.h:55
int ff_avc_parse_nal_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size)
Definition: avc.c:92
Definition: flv.h:62
int flags
A combination of AV_PKT_FLAG values.
Definition: avcodec.h:979
AVCodecContext * codec
Codec context associated with this stream.
Definition: avformat.h:702
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition: avformat.h:923
#define CONFIG_LIBMP3LAME
Definition: config.h:287
#define FLV_AUDIO_CODECID_OFFSET
Definition: flv.h:34
int bit_rate
the average bitrate
Definition: avcodec.h:1112
#define AV_TIME_BASE
Internal time base represented as integer.
Definition: avutil.h:234
static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: flvenc.c:429
int width
picture width / height.
Definition: avcodec.h:1217
#define AVFMT_GLOBALHEADER
Format wants global header.
Definition: avformat.h:406
void avio_wb24(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:354
static av_always_inline int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: avio.h:210
const char * name
Definition: avformat.h:437
int reserved
Definition: flvenc.c:58
NULL
Definition: eval.c:55
FLV common header.
enum AVMediaType codec_type
Definition: avcodec.h:1062
enum AVCodecID codec_id
Definition: avcodec.h:1065
int sample_rate
samples per second
Definition: avcodec.h:1779
AVIOContext * pb
I/O context.
Definition: avformat.h:913
static int flv_write_header(AVFormatContext *s)
Definition: flvenc.c:190
void avio_w8(AVIOContext *s, int b)
Definition: aviobuf.c:144
main external API structure.
Definition: avcodec.h:1054
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
Definition: avcodec.h:1080
static void put_amf_string(AVIOContext *pb, const char *str)
Definition: flvenc.c:158
int extradata_size
Definition: avcodec.h:1163
static void put_amf_double(AVIOContext *pb, double d)
Definition: flvenc.c:178
int error
contains the error code or 0 if no error happened
Definition: avio.h:102
#define AMF_END_OF_OBJECT
Definition: flv.h:47
static void put_amf_bool(AVIOContext *pb, int b)
Definition: flvenc.c:184
void avio_wb16(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:342
Main libavformat public API header.
int64_t duration_offset
Definition: flvenc.c:59
raw UTF-8 text
Definition: avcodec.h:440
char * key
Definition: dict.h:75
int den
denominator
Definition: rational.h:45
static void put_avc_eos_tag(AVIOContext *pb, unsigned ts)
Definition: flvenc.c:165
#define AVFMT_VARIABLE_FPS
Format allows variable fps.
Definition: avformat.h:410
char * value
Definition: dict.h:76
int len
int channels
number of audio channels
Definition: avcodec.h:1780
void * priv_data
Format private data.
Definition: avformat.h:899
static void write_header(FFV1Context *f)
Definition: ffv1enc.c:380
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
Definition: avcodec.h:972
void avio_wb32(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:268
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
Definition: avformat.h:962
#define AV_DICT_IGNORE_SUFFIX
Definition: dict.h:62
int64_t filesize_offset
Definition: flvenc.c:60
int stream_index
Definition: avcodec.h:975
This structure stores compressed data.
Definition: avcodec.h:950
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:205
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: avcodec.h:966
int64_t last_ts
last timestamp for each stream
Definition: flvenc.c:66
int ff_isom_write_avcc(AVIOContext *pb, const uint8_t *data, int len)
Definition: avc.c:106
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:228