40 #define KEYFRAMES_TAG "keyframes" 41 #define KEYFRAMES_TIMESTAMP_TAG "times" 42 #define KEYFRAMES_BYTEOFFSET_TAG "filepositions" 44 #define VALIDATE_INDEX_TS_THRESH 2500 71 d[3] < 5 && d[5] == 0 &&
100 switch (flv_codecid) {
103 codec_id = bits_per_coded_sample == 8
112 codec_id = bits_per_coded_sample == 8
142 switch (flv_codecid) {
206 switch (flv_codecid) {
225 int flv_codecid,
int read)
228 switch (flv_codecid) {
269 if (length >= buffsize) {
276 buffer[length] =
'\0';
285 unsigned int arraylen = 0, timeslen = 0, fileposlen = 0, i;
288 int64_t *times =
NULL;
289 int64_t *filepositions =
NULL;
298 int64_t *current_array;
311 if (!(times =
av_mallocz(
sizeof(*times) * arraylen))) {
316 current_array = times;
319 if (!(filepositions =
av_mallocz(
sizeof(*filepositions) * arraylen))) {
323 fileposlen = arraylen;
324 current_array = filepositions;
330 for (i = 0; i < arraylen &&
avio_tell(ioc) < max_pos - 1; i++) {
334 current_array[i] = num_val;
336 if (times && filepositions) {
344 if (!ret && timeslen == fileposlen) {
345 for (i = 0; i < fileposlen; i++) {
362 if (ret < 0 &&
avio_seek(ioc, initial_pos, SEEK_SET) > 0)
394 if ((vstream || astream) && key &&
426 unsigned int arraylen, i;
429 for (i = 0; i < arraylen &&
avio_tell(ioc) < max_pos - 1; i++)
450 if (!strcmp(key,
"duration"))
452 else if (!strcmp(key,
"videodatarate") && vpar &&
453 0 <= (
int)(num_val * 1024.0))
455 else if (!strcmp(key,
"audiodatarate") && apar &&
456 0 <= (
int)(num_val * 1024.0))
458 else if (!strcmp(key,
"datastream")) {
464 if (!strcmp(key,
"videocodecid") && vpar) {
466 }
else if (!strcmp(key,
"audiocodecid") && apar) {
469 }
else if (!strcmp(key,
"audiosamplerate") && apar) {
471 }
else if (!strcmp(key,
"audiosamplesize") && apar) {
473 }
else if (!strcmp(key,
"stereo") && apar) {
478 }
else if (!strcmp(key,
"width") && vpar) {
479 vpar->
width = num_val;
480 }
else if (!strcmp(key,
"height") && vpar) {
487 if (!strcmp(key,
"duration") ||
488 !strcmp(key,
"filesize") ||
489 !strcmp(key,
"width") ||
490 !strcmp(key,
"height") ||
491 !strcmp(key,
"videodatarate") ||
492 !strcmp(key,
"framerate") ||
493 !strcmp(key,
"videocodecid") ||
494 !strcmp(key,
"audiodatarate") ||
495 !strcmp(key,
"audiosamplerate") ||
496 !strcmp(key,
"audiosamplesize") ||
497 !strcmp(key,
"stereo") ||
498 !strcmp(key,
"audiocodecid") ||
499 !strcmp(key,
"datastream"))
504 av_strlcpy(str_val, num_val > 0 ?
"true" :
"false",
508 snprintf(str_val,
sizeof(str_val),
"%.f", num_val);
520 AVStream *stream, *astream, *vstream;
537 if (!strcmp(buffer,
"onTextData"))
540 if (strcmp(buffer,
"onMetaData") && strcmp(buffer,
"onCuePoint"))
614 "Found invalid index entries, clearing the index.\n");
628 int nb = -1, ret, parse_name = 1;
668 int64_t
dts, int64_t next)
738 int sample_rate = 0, channels = 0;
756 if (pos == validate_pos) {
764 }
else if (pos > validate_pos) {
783 if ((flags & 0xf0) == 0x50)
791 "Skipping flv packet: type %d, size %d, flags %d.\n",
809 }
else if (!is_audio &&
828 !((flags & FLV_VIDEO_FRAMETYPE_MASK) ==
FLV_FRAME_KEY || is_audio)) ||
849 if (size > 0 && size < fsize) {
864 int bits_per_coded_sample;
918 "Negative cts, previous timestamps might be wrong.\n");
935 if (t && !strcmp(t->
value,
"Omnia A/XE"))
996 int64_t ts,
int flags)
1003 #define OFFSET(x) offsetof(FLVContext, x) 1004 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM 1010 static const AVClass class = {
1026 .extensions =
"flv",
1027 .priv_class = &
class,
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
discard all frames except keyframes
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int64_t avio_size(AVIOContext *s)
Get the filesize.
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.
#define AV_LOG_WARNING
Something somehow does not look correct.
static const int32_t max_pos[4]
struct FLVContext::@135 validate_index[2]
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int index
stream index in AVFormatContext
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
enum AVMediaType codec_type
int event_flags
Flags for the user to detect events happening on the file.
#define AV_CH_LAYOUT_STEREO
unsigned int avio_rb16(AVIOContext *s)
uint8_t * new_extradata[2]
int ctx_flags
Flags signalling stream properties.
This struct describes the properties of an encoded stream.
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static av_always_inline double av_int2double(uint64_t i)
Reinterpret a 64-bit integer as a double.
Opaque data information usually continuous.
AVCodecParameters * avcodec_parameters_alloc(void)
Allocate a new AVCodecParameters and set its fields to default values (unknown/invalid/0).
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
unsigned int avio_rb32(AVIOContext *s)
int wrong_dts
wrong dts due to negative cts
enum AVStreamParseType need_parsing
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
AVStream ** streams
A list of all streams in the file.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
int flags
Flags modifying the (de)muxer behaviour.
#define AVERROR_EOF
End of file.
static av_cold int read_close(AVFormatContext *ctx)
uint64_t avio_rb64(AVIOContext *s)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int trust_metadata
configure streams according onMetaData
uint64_t channel_layout
Audio only.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
AVDictionary * metadata
Metadata that applies to the whole file.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
discard all bidirectional frames
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
preferred ID for decoding MPEG audio layer 1, 2 or 3
enum AVMediaType codec_type
General type of the encoded data.
void avcodec_parameters_free(AVCodecParameters **par)
Free an AVCodecParameters instance and everything associated with it and write NULL to the supplied p...
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.
int flags
A combination of AV_PKT_FLAG values.
int extradata_size
Size of the extradata content in bytes.
int avio_r8(AVIOContext *s)
int bit_rate
The average bitrate of the encoded data (in bits per second).
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
audio channel layout utility functions
unsigned int avio_rb24(AVIOContext *s)
#define AV_TIME_BASE
Internal time base represented as integer.
static av_always_inline int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
static int read_header(FFV1Context *f)
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
#define AV_LOG_INFO
Standard information.
AVIOContext * pb
I/O context.
int new_extradata_size[2]
static int read_packet(AVFormatContext *ctx, AVPacket *pkt)
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Describe the class of an AVClass context structure.
This structure contains the data a format has to probe a file.
static int64_t pts
Global timestamp for the audio frames.
int64_t start_time
Position of the first frame of the component, in AV_TIME_BASE fractional seconds. ...
int sample_rate
Audio only.
int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int bit_size, int sync_extension)
Parse MPEG-4 systems extradata to retrieve audio configuration.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
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.
int eof_reached
true if eof reached
void * priv_data
Format private data.
int bits_per_coded_sample
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
AVCodecParameters * codecpar
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Allocate new information of a packet.
#define AV_CH_LAYOUT_MONO
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
This structure stores compressed data.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AV_NOPTS_VALUE
Undefined timestamp value.