38 #define KEYFRAMES_TAG "keyframes"
39 #define KEYFRAMES_TIMESTAMP_TAG "times"
40 #define KEYFRAMES_BYTEOFFSET_TAG "filepositions"
44 uint8_t *new_extradata[2];
45 int new_extradata_size[2];
55 if (d[0] ==
'F' && d[1] ==
'L' && d[2] ==
'V' && d[3] < 5 && d[5]==0 &&
AV_RB32(d+5)>8) {
100 switch(flv_codecid) {
127 if(length >= buffsize) {
134 buffer[length] =
'\0';
140 unsigned int arraylen = 0, timeslen = 0, fileposlen = 0, i;
143 int64_t *times =
NULL;
144 int64_t *filepositions =
NULL;
150 if (creator && !strcmp(creator->
value,
"MEGA")) {
161 int64_t* current_array;
176 if (!(times =
av_mallocz(
sizeof(*times) * arraylen))) {
181 current_array = times;
183 if (!(filepositions =
av_mallocz(
sizeof(*filepositions) * arraylen))) {
187 fileposlen = arraylen;
188 current_array = filepositions;
192 for (i = 0; i < arraylen &&
avio_tell(ioc) < max_pos - 1; i++) {
196 current_array[i] = num_val;
198 if (times && filepositions) {
206 if (!ret && timeslen == fileposlen)
207 for (i = 0; i < fileposlen; i++)
217 if (ret < 0 &&
avio_seek(ioc, initial_pos, SEEK_SET) > 0)
246 if ((vstream || astream) && key && !strcmp(
KEYFRAMES_TAG, key) && depth == 1)
275 unsigned int arraylen, i;
278 for(i = 0; i < arraylen &&
avio_tell(ioc) < max_pos - 1; i++) {
291 if(depth == 1 && key) {
292 acodec = astream ? astream->
codec :
NULL;
293 vcodec = vstream ? vstream->
codec :
NULL;
296 if (!strcmp(key,
"duration"))
298 else if (!strcmp(key,
"videodatarate") && vcodec && 0 <= (
int)(num_val * 1024.0))
299 vcodec->
bit_rate = num_val * 1024.0;
300 else if (!strcmp(key,
"audiodatarate") && acodec && 0 <= (
int)(num_val * 1024.0))
301 acodec->
bit_rate = num_val * 1024.0;
304 if (!strcmp(key,
"duration") ||
305 !strcmp(key,
"filesize") ||
306 !strcmp(key,
"width") ||
307 !strcmp(key,
"height") ||
308 !strcmp(key,
"videodatarate") ||
309 !strcmp(key,
"framerate") ||
310 !strcmp(key,
"videocodecid") ||
311 !strcmp(key,
"audiodatarate") ||
312 !strcmp(key,
"audiosamplerate") ||
313 !strcmp(key,
"audiosamplesize") ||
314 !strcmp(key,
"stereo") ||
315 !strcmp(key,
"audiocodecid"))
319 av_strlcpy(str_val, num_val > 0 ?
"true" :
"false",
sizeof(str_val));
322 snprintf(str_val,
sizeof(str_val),
"%.f", num_val);
333 AVStream *stream, *astream, *vstream;
444 int sample_rate = 0, channels = 0;
453 av_dlog(s,
"type:%d, size:%d, dts:%"PRId64
"\n", type, size, dts);
472 if ((flags & 0xf0) == 0x50)
478 av_log(s,
AV_LOG_DEBUG,
"skipping flv packet: type %d, size %d, flags %d\n", type, size, flags);
491 if (st->
id == is_audio)
529 int bits_per_coded_sample;
557 int32_t cts = (
avio_rb24(s->
pb)+0xff800000)^0xff800000;
584 av_dlog(s,
"mp4a config channels %d sample rate %d\n",
635 int64_t ts,
int flags)
642 int64_t min_ts, int64_t ts, int64_t max_ts,
int flags)
649 if (stream_index < 0) {
651 if (stream_index < 0)
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int64_t avio_size(AVIOContext *s)
Get the filesize.
AV_WL32 AV_WL24 AV_WL16 AV_RB32
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.
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
Rescale a 64-bit integer with specified rounding.
#define AV_LOG_WARNING
Something somehow does not look correct.
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
int index
stream index in AVFormatContext
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
discard all bidirectional frames
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
unsigned int avio_rb16(AVIOContext *s)
uint8_t * new_extradata[2]
int ctx_flags
Format-specific flags, see AVFMTCTX_xx.
AVDictionaryEntry * av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static av_always_inline double av_int2double(uint64_t i)
Reinterpret a 64-bit integer as a double.
unsigned int avio_rb32(AVIOContext *s)
int wrong_dts
wrong dts due to negative cts
int id
format-specific stream ID
enum AVStreamParseType need_parsing
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static int read_header(FFV1Context *f)
#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 bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_log(void *avcl, int level, const char *fmt,...)
AVStream * avformat_new_stream(AVFormatContext *s, AVCodec *c)
Add a new stream to a media file.
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 avio_r8(AVIOContext *s)
AVCodecContext * codec
codec context
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
unsigned int nb_streams
A list of all streams in the file.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
int bit_rate
the average bitrate
unsigned int avio_rb24(AVIOContext *s)
#define AV_TIME_BASE
Internal time base represented as integer.
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Allocate new information of a packet.
int av_find_default_stream_index(AVFormatContext *s)
static av_always_inline int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
static int read_probe(AVProbeData *p)
#define av_dlog(pctx,...)
av_dlog macros Useful to print debug messages that shouldn't get compiled in normally.
enum AVMediaType codec_type
int sample_rate
samples per second
main external API structure.
int new_extradata_size[2]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
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.
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
This structure contains the data a format has to probe a file.
int64_t start_time
Decoding: position of the first frame of the component, in AV_TIME_BASE fractional seconds...
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Seek to the keyframe at timestamp.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
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.
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
int channels
number of audio channels
void * priv_data
Format private data.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
int64_t duration
Decoding: duration of the stream, in AV_TIME_BASE fractional seconds.
discard all frames except keyframes
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
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.
preferred ID for decoding MPEG audio layer 1, 2 or 3