Go to the documentation of this file.
41 #define VALIDATE_INDEX_TS_THRESH 2500
43 #define RESYNC_BUFFER_SIZE (1<<20)
97 d[3] < 5 && d[5] == 0 &&
100 int is_live = !memcmp(d +
offset + 40,
"NGINX RTMP", 10);
170 if (
s->nb_streams>=3 ||(
s->nb_streams==2
205 switch (flv_codecid) {
208 codec_id = bits_per_coded_sample == 8
217 codec_id = bits_per_coded_sample == 8
247 switch (flv_codecid) {
311 switch (flv_codecid) {
330 int flv_codecid,
int read)
335 switch (flv_codecid) {
409 unsigned int timeslen = 0, fileposlen = 0,
i;
411 int64_t *times =
NULL;
412 int64_t *filepositions =
NULL;
428 int64_t **current_array;
429 unsigned int arraylen;
440 current_array = ×
444 current_array = &filepositions;
445 fileposlen = arraylen;
451 if (!(*current_array =
av_mallocz(
sizeof(**current_array) * arraylen))) {
461 if (
isnan(d) || d < INT64_MIN || d > INT64_MAX)
463 if (current_array == × && (d <= INT64_MIN / 1000 || d >= INT64_MAX / 1000))
465 current_array[0][
i] = d;
467 if (times && filepositions) {
475 if (timeslen == fileposlen && fileposlen>1 &&
max_pos <= filepositions[0]) {
476 for (
i = 0;
i <
FFMIN(2,fileposlen);
i++) {
485 filepositions =
NULL;
568 av_log(
s,
AV_LOG_ERROR,
"Missing AMF_END_OF_OBJECT in AMF_DATA_TYPE_MIXEDARRAY, found %d\n", v);
575 unsigned int arraylen,
i;
602 if (!strcmp(
key,
"duration"))
604 else if (!strcmp(
key,
"videodatarate") &&
605 0 <= (
int)(num_val * 1024.0))
607 else if (!strcmp(
key,
"audiodatarate") &&
608 0 <= (
int)(num_val * 1024.0))
610 else if (!strcmp(
key,
"datastream")) {
615 }
else if (!strcmp(
key,
"framerate")) {
620 if (!strcmp(
key,
"videocodecid") && vpar) {
624 }
else if (!strcmp(
key,
"audiocodecid") && apar) {
627 }
else if (!strcmp(
key,
"audiosamplerate") && apar) {
629 }
else if (!strcmp(
key,
"audiosamplesize") && apar) {
631 }
else if (!strcmp(
key,
"stereo") && apar) {
636 }
else if (!strcmp(
key,
"width") && vpar) {
637 vpar->
width = num_val;
638 }
else if (!strcmp(
key,
"height") && vpar) {
644 if (!strcmp(
key,
"encoder")) {
646 if (1 == sscanf(str_val,
"Open Broadcaster Software v0.%d", &
version)) {
650 }
else if (!strcmp(
key,
"metadatacreator")) {
651 if ( !strcmp (str_val,
"MEGA")
652 || !strncmp(str_val,
"FlixEngine", 10))
659 ((!apar && !strcmp(
key,
"audiocodecid")) ||
660 (!vpar && !strcmp(
key,
"videocodecid"))))
663 if ((!strcmp(
key,
"duration") ||
664 !strcmp(
key,
"filesize") ||
665 !strcmp(
key,
"width") ||
666 !strcmp(
key,
"height") ||
667 !strcmp(
key,
"videodatarate") ||
668 !strcmp(
key,
"framerate") ||
669 !strcmp(
key,
"videocodecid") ||
670 !strcmp(
key,
"audiodatarate") ||
671 !strcmp(
key,
"audiosamplerate") ||
672 !strcmp(
key,
"audiosamplesize") ||
673 !strcmp(
key,
"stereo") ||
674 !strcmp(
key,
"audiocodecid") ||
680 av_strlcpy(str_val, num_val > 0 ?
"true" :
"false",
684 snprintf(str_val,
sizeof(str_val),
"%.f", num_val);
694 strftime(datestr,
sizeof(datestr),
"%a, %d %b %Y %H:%M:%S %z", &t);
703 #define TYPE_ONTEXTDATA 1
704 #define TYPE_ONCAPTION 2
705 #define TYPE_ONCAPTIONINFO 3
706 #define TYPE_UNKNOWN 9
712 AVStream *stream, *astream, *vstream;
729 if (!strcmp(
buffer,
"onTextData"))
732 if (!strcmp(
buffer,
"onCaption"))
735 if (!strcmp(
buffer,
"onCaptionInfo"))
738 if (strcmp(
buffer,
"onMetaData") && strcmp(
buffer,
"onCuePoint")) {
745 for (
i = 0;
i <
s->nb_streams;
i++) {
746 stream =
s->streams[
i];
771 int pre_tag_size = 0;
774 if(!strcmp(
s->iformat->name,
"kux"))
794 av_log(
s,
AV_LOG_WARNING,
"Read FLV header error, input file is not a standard flv format, first PreviousTagSize0 always is 0\n");
847 "Found invalid index entries, clearing the index.\n");
848 for (
i = 0;
i <
s->nb_streams;
i++) {
861 int nb = -1,
ret, parse_name = 1;
909 int64_t dts, int64_t next)
949 for (
i = 0;
i <
s->nb_streams;
i++) {
955 if (
i ==
s->nb_streams) {
992 d[3] < 5 && d[5] == 0) {
1006 if (size1 == lsize1 - 11 && size2 == lsize2 - 11) {
1007 avio_seek(
s->pb, pos +
i - lsize1 - lsize2 - 8, SEEK_SET);
1023 int64_t next, pos, meta_pos;
1039 dts |= (unsigned)
avio_r8(
s->pb) << 24;
1040 av_log(
s,
AV_LOG_TRACE,
"type:%d, size:%d, last:%d, dts:%"PRId64
" pos:%"PRId64
"\n",
type,
size, last, dts,
avio_tell(
s->pb));
1048 if (pos == validate_pos) {
1056 }
else if (pos > validate_pos) {
1081 if (
size > 13 + 1 + 4) {
1085 if (
type == 0 && dts == 0 ||
type < 0) {
1086 if (type < 0 && flv->validate_count &&
1106 "Skipping flv packet: type %d, size %d, flags %d.\n",
1109 if (
avio_seek(
s->pb, next, SEEK_SET) != next) {
1127 for (
i = 0;
i <
s->nb_streams;
i++) {
1145 if (
i ==
s->nb_streams) {
1191 ts |= (unsigned)
avio_r8(
s->pb) << 24;
1196 goto retry_duration;
1206 int bits_per_coded_sample;
1268 "Negative cts, previous timestamps might be wrong.\n");
1270 }
else if (
FFABS(dts -
pts) > 1000*60*15) {
1272 "invalid timestamps %"PRId64
" %"PRId64
"\n", dts,
pts);
1355 if (last != orig_size + 11 && last != orig_size + 10 &&
1376 int64_t ts,
int flags)
1383 #define OFFSET(x) offsetof(FLVContext, x)
1384 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
1386 {
"flv_metadata",
"Allocate streams according to the onMetaData array",
OFFSET(trust_metadata),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1,
VD },
1387 {
"flv_full_metadata",
"Dump full metadata of the onMetadata",
OFFSET(dump_full_metadata),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1,
VD },
1388 {
"flv_ignore_prevtag",
"Ignore the Size of previous tag",
OFFSET(trust_datasize),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1,
VD },
1409 .extensions =
"flv",
1429 .extensions =
"flv",
1450 .extensions =
"kux",
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
#define AV_LOG_WARNING
Something somehow does not look correct.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
#define AV_OPT_FLAG_READONLY
The option may not be set through the AVOptions API, only read.
enum AVMediaType codec_type
General type of the encoded data.
This struct describes the properties of an encoded stream.
#define AVERROR_EOF
End of file.
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
static av_always_inline double av_int2double(uint64_t i)
Reinterpret a 64-bit integer as a double.
#define AV_CH_LAYOUT_MONO
int trust_metadata
configure streams according onMetaData
static const int32_t max_pos[4]
Size of the MP-MLQ fixed excitation codebooks.
AVStreamInternal * internal
An opaque field for libavformat internal usage.
AVRational avg_frame_rate
Average framerate.
uint8_t resync_buffer[2 *RESYNC_BUFFER_SIZE]
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
int buf_size
Size of buf except extra allocated bytes.
int trust_datasize
trust data size of FLVTag
enum AVMediaType codec_type
int64_t avio_size(AVIOContext *s)
Get the filesize.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
int64_t * keyframe_filepositions
int64_t avio_seek_time(AVIOContext *h, int stream_index, int64_t timestamp, int flags)
Seek to a given timestamp relative to some component stream.
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Add an index entry into a sorted list.
static av_cold int read_close(AVFormatContext *ctx)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
#define AV_CH_LAYOUT_STEREO
unsigned int avio_rb32(AVIOContext *s)
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
int new_extradata_size[FLV_STREAM_TYPE_NB]
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
enum AVStreamParseType need_parsing
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
static int64_t fsize(FILE *f)
@ AVDISCARD_BIDIR
discard all bidirectional frames
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Allocate new information of a packet.
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
@ AVDISCARD_ALL
discard all
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define LIBAVUTIL_VERSION_INT
static int read_header(FFV1Context *f)
Describe the class of an AVClass context structure.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
void avcodec_parameters_free(AVCodecParameters **par)
Free an AVCodecParameters instance and everything associated with it and write NULL to the supplied p...
Rational number (pair of numerator and denominator).
struct FLVContext::@258 validate_index[2]
const char * av_default_item_name(void *ptr)
Return the context name.
uint64_t avio_rb64(AVIOContext *s)
This structure contains the data a format has to probe a file.
int sample_rate
Audio only.
AVCodecID
Identify the syntax and semantics of the bitstream.
int extradata_size
Size of the extradata content in bytes.
@ AVDISCARD_NONKEY
discard all frames except keyframes
unsigned int avio_rb24(AVIOContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
#define AV_NOPTS_VALUE
Undefined timestamp value.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
int avio_r8(AVIOContext *s)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
int flags
A combination of AV_PKT_FLAG values.
AVCodecParameters * avcodec_parameters_alloc(void)
Allocate a new AVCodecParameters and set its fields to default values (unknown/invalid/0).
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int last_keyframe_stream_index
#define AV_TIME_BASE
Internal time base represented as integer.
AVRational av_d2q(double d, int max)
Convert a double precision floating point number to a rational.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int wrong_dts
wrong dts due to negative cts
uint8_t * new_extradata[FLV_STREAM_TYPE_NB]
static int array[MAX_W *MAX_W]
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
unsigned int avio_rb16(AVIOContext *s)
@ AV_CODEC_ID_TEXT
raw UTF-8 text
#define AV_INPUT_BUFFER_PADDING_SIZE
int index
stream index in AVFormatContext
#define AV_OPT_FLAG_EXPORT
The option is intended for exporting values to the caller.
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
@ AV_PKT_DATA_NEW_EXTRADATA
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
int eof_reached
true if was unable to read due to error or eof
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
int bits_per_coded_sample
The number of bits per sample in the codedwords.
int need_context_update
Whether the internal avctx needs to be updated from codecpar (after a late change to codecpar)
#define avpriv_request_sample(...)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
int64_t pos
byte position in stream, -1 if unknown
uint64_t channel_layout
Audio only.
#define flags(name, subs,...)
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int bit_size, int sync_extension)
Parse MPEG-4 systems extradata from a raw buffer to retrieve audio configuration.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_RB24
int dump_full_metadata
Dump full metadata of the onMetadata.
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.