FFmpeg
Data Structures | Enumerations | Functions | Variables
flvenc.c File Reference
#include "libavutil/intreadwrite.h"
#include "libavutil/dict.h"
#include "libavutil/intfloat.h"
#include "libavutil/avassert.h"
#include "libavutil/mathematics.h"
#include "libavcodec/codec_desc.h"
#include "libavcodec/mpeg4audio.h"
#include "avio.h"
#include "avc.h"
#include "av1.h"
#include "vpcc.h"
#include "hevc.h"
#include "avformat.h"
#include "flv.h"
#include "internal.h"
#include "mux.h"
#include "libavutil/opt.h"
#include "libavcodec/put_bits.h"

Go to the source code of this file.

Data Structures

struct  FLVFileposition
 
struct  FLVContext
 

Enumerations

enum  FLVFlags {
  FLV_AAC_SEQ_HEADER_DETECT = (1 << 0), FLV_NO_SEQUENCE_END = (1 << 1), FLV_ADD_KEYFRAME_INDEX = (1 << 2), FLV_NO_METADATA = (1 << 3),
  FLV_NO_DURATION_FILESIZE = (1 << 4)
}
 

Functions

static int get_audio_flags (AVFormatContext *s, AVCodecParameters *par)
 
static void put_amf_string (AVIOContext *pb, const char *str)
 
static void put_timestamp (AVIOContext *pb, int64_t ts)
 
static void put_eos_tag (AVIOContext *pb, unsigned ts, enum AVCodecID codec_id)
 
static void put_amf_double (AVIOContext *pb, double d)
 
static void put_amf_byte (AVIOContext *pb, unsigned char abyte)
 
static void put_amf_dword_array (AVIOContext *pb, uint32_t dw)
 
static void put_amf_bool (AVIOContext *pb, int b)
 
static void write_metadata (AVFormatContext *s, unsigned int ts)
 
static int unsupported_codec (AVFormatContext *s, const char *type, int codec_id)
 
static void flv_write_codec_header (AVFormatContext *s, AVCodecParameters *par, int64_t ts)
 
static int flv_append_keyframe_info (AVFormatContext *s, FLVContext *flv, double ts, int64_t pos)
 
static int shift_data (AVFormatContext *s)
 
static int flv_init (struct AVFormatContext *s)
 
static int flv_write_header (AVFormatContext *s)
 
static int flv_write_trailer (AVFormatContext *s)
 
static int flv_write_packet (AVFormatContext *s, AVPacket *pkt)
 
static int flv_check_bitstream (AVFormatContext *s, AVStream *st, const AVPacket *pkt)
 
static void flv_deinit (AVFormatContext *s)
 

Variables

static const AVCodecTag flv_video_codec_ids []
 
static const AVCodecTag flv_audio_codec_ids []
 
static const AVOption options []
 
static const AVClass flv_muxer_class
 
const FFOutputFormat ff_flv_muxer
 

Enumeration Type Documentation

◆ FLVFlags

enum FLVFlags
Enumerator
FLV_AAC_SEQ_HEADER_DETECT 
FLV_NO_SEQUENCE_END 
FLV_ADD_KEYFRAME_INDEX 
FLV_NO_METADATA 
FLV_NO_DURATION_FILESIZE 

Definition at line 72 of file flvenc.c.

Function Documentation

◆ get_audio_flags()

static int get_audio_flags ( AVFormatContext s,
AVCodecParameters par 
)
static

Definition at line 129 of file flvenc.c.

Referenced by flv_init(), flv_write_codec_header(), and flv_write_packet().

◆ put_amf_string()

static void put_amf_string ( AVIOContext pb,
const char *  str 
)
static

Definition at line 228 of file flvenc.c.

Referenced by flv_write_packet(), flv_write_trailer(), and write_metadata().

◆ put_timestamp()

static void put_timestamp ( AVIOContext pb,
int64_t  ts 
)
static

Definition at line 236 of file flvenc.c.

Referenced by flv_write_codec_header(), flv_write_packet(), put_eos_tag(), and write_metadata().

◆ put_eos_tag()

static void put_eos_tag ( AVIOContext pb,
unsigned  ts,
enum AVCodecID  codec_id 
)
static

Definition at line 241 of file flvenc.c.

Referenced by flv_write_trailer().

◆ put_amf_double()

static void put_amf_double ( AVIOContext pb,
double  d 
)
static

Definition at line 256 of file flvenc.c.

Referenced by flv_write_trailer(), and write_metadata().

◆ put_amf_byte()

static void put_amf_byte ( AVIOContext pb,
unsigned char  abyte 
)
static

Definition at line 262 of file flvenc.c.

Referenced by write_metadata().

◆ put_amf_dword_array()

static void put_amf_dword_array ( AVIOContext pb,
uint32_t  dw 
)
static

Definition at line 267 of file flvenc.c.

Referenced by flv_write_trailer().

◆ put_amf_bool()

static void put_amf_bool ( AVIOContext pb,
int  b 
)
static

Definition at line 273 of file flvenc.c.

Referenced by write_metadata().

◆ write_metadata()

static void write_metadata ( AVFormatContext s,
unsigned int  ts 
)
static

Definition at line 279 of file flvenc.c.

Referenced by flv_write_header(), flv_write_packet(), and mxf_write_partition().

◆ unsupported_codec()

static int unsupported_codec ( AVFormatContext s,
const char *  type,
int  codec_id 
)
static

Definition at line 481 of file flvenc.c.

Referenced by flv_init().

◆ flv_write_codec_header()

static void flv_write_codec_header ( AVFormatContext s,
AVCodecParameters par,
int64_t  ts 
)
static

Definition at line 492 of file flvenc.c.

Referenced by flv_write_header(), and flv_write_packet().

◆ flv_append_keyframe_info()

static int flv_append_keyframe_info ( AVFormatContext s,
FLVContext flv,
double  ts,
int64_t  pos 
)
static

Definition at line 571 of file flvenc.c.

Referenced by flv_write_packet().

◆ shift_data()

static int shift_data ( AVFormatContext s)
static

Definition at line 598 of file flvenc.c.

Referenced by flv_write_trailer().

◆ flv_init()

static int flv_init ( struct AVFormatContext s)
static

Definition at line 627 of file flvenc.c.

◆ flv_write_header()

static int flv_write_header ( AVFormatContext s)
static

Definition at line 712 of file flvenc.c.

◆ flv_write_trailer()

static int flv_write_trailer ( AVFormatContext s)
static

Definition at line 749 of file flvenc.c.

◆ flv_write_packet()

static int flv_write_packet ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 839 of file flvenc.c.

◆ flv_check_bitstream()

static int flv_check_bitstream ( AVFormatContext s,
AVStream st,
const AVPacket pkt 
)
static

Definition at line 1066 of file flvenc.c.

◆ flv_deinit()

static void flv_deinit ( AVFormatContext s)
static

Definition at line 1080 of file flvenc.c.

Variable Documentation

◆ flv_video_codec_ids

const AVCodecTag flv_video_codec_ids[]
static

◆ flv_audio_codec_ids

const AVCodecTag flv_audio_codec_ids[]
static

◆ options

const AVOption options[]
static
Initial value:
= {
{ "flvflags", "FLV muxer flags", 0x42, AV_OPT_TYPE_FLAGS, {.i64 = 0}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "flvflags" },
{ "aac_seq_header_detect", "Put AAC sequence header based on stream data", 0, AV_OPT_TYPE_CONST, {.i64 = FLV_AAC_SEQ_HEADER_DETECT}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "flvflags" },
{ "no_sequence_end", "disable sequence end for FLV", 0, AV_OPT_TYPE_CONST, {.i64 = FLV_NO_SEQUENCE_END}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "flvflags" },
{ "no_metadata", "disable metadata for FLV", 0, AV_OPT_TYPE_CONST, {.i64 = FLV_NO_METADATA}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "flvflags" },
{ "no_duration_filesize", "disable duration and filesize zero value metadata for FLV", 0, AV_OPT_TYPE_CONST, {.i64 = FLV_NO_DURATION_FILESIZE}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "flvflags" },
{ "add_keyframe_index", "Add keyframe index metadata", 0, AV_OPT_TYPE_CONST, {.i64 = FLV_ADD_KEYFRAME_INDEX}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "flvflags" },
{ NULL },
}

Definition at line 1094 of file flvenc.c.

◆ flv_muxer_class

const AVClass flv_muxer_class
static
Initial value:
= {
.class_name = "flv muxer",
.item_name = av_default_item_name,
.option = options,
}

Definition at line 1104 of file flvenc.c.

◆ ff_flv_muxer

const FFOutputFormat ff_flv_muxer
Initial value:
= {
.p.name = "flv",
.p.long_name = NULL_IF_CONFIG_SMALL("FLV (Flash Video)"),
.p.mime_type = "video/x-flv",
.p.extensions = "flv",
.priv_data_size = sizeof(FLVContext),
.p.audio_codec = CONFIG_LIBMP3LAME ? AV_CODEC_ID_MP3 : AV_CODEC_ID_ADPCM_SWF,
.p.video_codec = AV_CODEC_ID_FLV1,
.init = flv_init,
.write_header = flv_write_header,
.write_packet = flv_write_packet,
.write_trailer = flv_write_trailer,
.deinit = flv_deinit,
.check_bitstream= flv_check_bitstream,
.p.codec_tag = (const AVCodecTag* const []) {
},
.p.priv_class = &flv_muxer_class,
}

Definition at line 1111 of file flvenc.c.

AV_CODEC_ID_PCM_S16LE
@ AV_CODEC_ID_PCM_S16LE
Definition: codec_id.h:330
AV_CODEC_ID_VP6F
@ AV_CODEC_ID_VP6F
Definition: codec_id.h:144
FLV_NO_DURATION_FILESIZE
@ FLV_NO_DURATION_FILESIZE
Definition: flvenc.c:77
FLV_NO_SEQUENCE_END
@ FLV_NO_SEQUENCE_END
Definition: flvenc.c:74
AVFMT_VARIABLE_FPS
#define AVFMT_VARIABLE_FPS
Format allows variable fps.
Definition: avformat.h:483
FLV_CODECID_VP6A
@ FLV_CODECID_VP6A
Definition: flv.h:114
AV_CODEC_ID_MPEG4
@ AV_CODEC_ID_MPEG4
Definition: codec_id.h:64
AV_CODEC_ID_VP6
@ AV_CODEC_ID_VP6
Definition: codec_id.h:143
FLV_CODECID_MP3
@ FLV_CODECID_MP3
Definition: flv.h:99
FLV_CODECID_ADPCM
@ FLV_CODECID_ADPCM
Definition: flv.h:98
AV_CODEC_ID_SPEEX
@ AV_CODEC_ID_SPEEX
Definition: codec_id.h:477
flv_write_packet
static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: flvenc.c:839
AV_CODEC_ID_PCM_S16BE
@ AV_CODEC_ID_PCM_S16BE
Definition: codec_id.h:331
AV_CODEC_ID_MP3
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
Definition: codec_id.h:443
FLV_AUDIO_CODECID_OFFSET
#define FLV_AUDIO_CODECID_OFFSET
Definition: flv.h:34
FLV_CODECID_PCM_ALAW
@ FLV_CODECID_PCM_ALAW
Definition: flv.h:104
FLV_CODECID_SPEEX
@ FLV_CODECID_SPEEX
Definition: flv.h:107
AVCodecTag
Definition: internal.h:48
FLV_CODECID_H264
@ FLV_CODECID_H264
Definition: flv.h:116
AV_OPT_FLAG_ENCODING_PARAM
#define AV_OPT_FLAG_ENCODING_PARAM
a generic parameter which can be set by the user for muxing or encoding
Definition: opt.h:281
FLV_CODECID_AAC
@ FLV_CODECID_AAC
Definition: flv.h:106
flv_write_header
static int flv_write_header(AVFormatContext *s)
Definition: flvenc.c:712
AV_CODEC_ID_VP9
@ AV_CODEC_ID_VP9
Definition: codec_id.h:220
FLV_CODECID_PCM_LE
@ FLV_CODECID_PCM_LE
Definition: flv.h:100
FLV_CODECID_H263
@ FLV_CODECID_H263
Definition: flv.h:111
FLV_CODECID_SCREEN
@ FLV_CODECID_SCREEN
Definition: flv.h:112
AV_CODEC_ID_PCM_MULAW
@ AV_CODEC_ID_PCM_MULAW
Definition: codec_id.h:336
AV_CODEC_ID_H264
@ AV_CODEC_ID_H264
Definition: codec_id.h:79
AV_CODEC_ID_PCM_ALAW
@ AV_CODEC_ID_PCM_ALAW
Definition: codec_id.h:337
AV_CODEC_ID_FLASHSV2
@ AV_CODEC_ID_FLASHSV2
Definition: codec_id.h:183
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
AV_CODEC_ID_AV1
@ AV_CODEC_ID_AV1
Definition: codec_id.h:283
FLV_ADD_KEYFRAME_INDEX
@ FLV_ADD_KEYFRAME_INDEX
Definition: flvenc.c:75
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
AV_CODEC_ID_FLASHSV
@ AV_CODEC_ID_FLASHSV
Definition: codec_id.h:138
AV_CODEC_ID_VP6A
@ AV_CODEC_ID_VP6A
Definition: codec_id.h:158
AV_CODEC_ID_AAC
@ AV_CODEC_ID_AAC
Definition: codec_id.h:444
FLV_CODECID_PCM
@ FLV_CODECID_PCM
Definition: flv.h:97
flv_muxer_class
static const AVClass flv_muxer_class
Definition: flvenc.c:1104
flv_init
static int flv_init(struct AVFormatContext *s)
Definition: flvenc.c:627
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:106
FLV_CODECID_SCREEN2
@ FLV_CODECID_SCREEN2
Definition: flv.h:115
AV_CODEC_ID_H263
@ AV_CODEC_ID_H263
Definition: codec_id.h:56
AV_CODEC_ID_ADPCM_SWF
@ AV_CODEC_ID_ADPCM_SWF
Definition: codec_id.h:382
flv_audio_codec_ids
static const AVCodecTag flv_audio_codec_ids[]
Definition: flvenc.c:58
FLVContext
Definition: flvdec.c:48
MKBETAG
#define MKBETAG(a, b, c, d)
Definition: macros.h:56
FLV_CODECID_MPEG4
@ FLV_CODECID_MPEG4
Definition: flv.h:118
flv_video_codec_ids
static const AVCodecTag flv_video_codec_ids[]
Definition: flvenc.c:42
flv_check_bitstream
static int flv_check_bitstream(AVFormatContext *s, AVStream *st, const AVPacket *pkt)
Definition: flvenc.c:1066
AVFMT_GLOBALHEADER
#define AVFMT_GLOBALHEADER
Format wants global header.
Definition: avformat.h:479
AV_CODEC_ID_NONE
@ AV_CODEC_ID_NONE
Definition: codec_id.h:50
FLV_CODECID_VP6
@ FLV_CODECID_VP6
Definition: flv.h:113
AV_CODEC_ID_HEVC
@ AV_CODEC_ID_HEVC
Definition: codec_id.h:226
FLV_NO_METADATA
@ FLV_NO_METADATA
Definition: flvenc.c:76
AVFMT_TS_NONSTRICT
#define AVFMT_TS_NONSTRICT
Format does not require strictly increasing timestamps, but they must still be monotonic.
Definition: avformat.h:492
FLV_CODECID_REALH263
@ FLV_CODECID_REALH263
Definition: flv.h:117
FLV_AAC_SEQ_HEADER_DETECT
@ FLV_AAC_SEQ_HEADER_DETECT
Definition: flvenc.c:73
flv_deinit
static void flv_deinit(AVFormatContext *s)
Definition: flvenc.c:1080
FLV_CODECID_NELLYMOSER
@ FLV_CODECID_NELLYMOSER
Definition: flv.h:103
AV_CODEC_ID_PCM_U8
@ AV_CODEC_ID_PCM_U8
Definition: codec_id.h:335
FLV_CODECID_PCM_MULAW
@ FLV_CODECID_PCM_MULAW
Definition: flv.h:105
flv_write_trailer
static int flv_write_trailer(AVFormatContext *s)
Definition: flvenc.c:749
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Definition: opt.h:224
options
static const AVOption options[]
Definition: flvenc.c:1094
AV_CODEC_ID_FLV1
@ AV_CODEC_ID_FLV1
Definition: codec_id.h:73
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
AV_CODEC_ID_NELLYMOSER
@ AV_CODEC_ID_NELLYMOSER
Definition: codec_id.h:475