FFmpeg
Loading...
Searching...
No Matches
flvdec.c
Go to the documentation of this file.
1/*
2 * FLV demuxer
3 * Copyright (c) 2003 The FFmpeg Project
4 *
5 * This demuxer will generate a 1 byte extradata for VP6F content.
6 * It is composed of:
7 * - upper 4 bits: difference between encoded width and visible width
8 * - lower 4 bits: difference between encoded height and visible height
9 *
10 * This file is part of FFmpeg.
11 *
12 * FFmpeg is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
16 *
17 * FFmpeg is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with FFmpeg; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 */
26
28#include "libavutil/avassert.h"
29#include "libavutil/avstring.h"
31#include "libavutil/dict.h"
32#include "libavutil/mem.h"
33#include "libavutil/opt.h"
34#include "libavutil/internal.h"
35#include "libavutil/intfloat.h"
38#include "avformat.h"
39#include "demux.h"
40#include "internal.h"
41#include "flv.h"
42
43#define VALIDATE_INDEX_TS_THRESH 2500
44
45#define RESYNC_BUFFER_SIZE (1<<20)
46
47#define MAX_DEPTH 16 ///< arbitrary limit to prevent unbounded recursion
48
49typedef struct FLVMasteringMeta {
50 float r_x;
51 float r_y;
52 float g_x;
53 float g_y;
54 float b_x;
55 float b_y;
56 float white_x;
57 float white_y;
61
70
76
118
119/* AMF date type */
120typedef struct amf_date {
122 int16_t timezone;
123} amf_date;
124
125static int probe(const AVProbeData *p, int live)
126{
127 const uint8_t *d = p->buf;
128 unsigned offset = AV_RB32(d + 5);
129
130 if (d[0] == 'F' &&
131 d[1] == 'L' &&
132 d[2] == 'V' &&
133 d[3] < 5 && d[5] == 0 &&
134 offset + 100 < p->buf_size &&
135 offset > 8) {
136 int is_live = !memcmp(d + offset + 40, "NGINX RTMP", 10);
137
138 if (live == is_live)
139 return AVPROBE_SCORE_MAX;
140 }
141 return 0;
142}
143
144static int flv_probe(const AVProbeData *p)
145{
146 return probe(p, 0);
147}
148
149static int live_flv_probe(const AVProbeData *p)
150{
151 return probe(p, 1);
152}
153
154static int kux_probe(const AVProbeData *p)
155{
156 const uint8_t *d = p->buf;
157
158 if (d[0] == 'K' &&
159 d[1] == 'D' &&
160 d[2] == 'K' &&
161 d[3] == 0 &&
162 d[4] == 0) {
163 return AVPROBE_SCORE_EXTENSION + 1;
164 }
165 return 0;
166}
167
169{
170 FLVContext *flv = s->priv_data;
171 AVStream *stream = NULL;
172 unsigned int i = 0;
173
174 if (flv->last_keyframe_stream_index < 0) {
175 av_log(s, AV_LOG_DEBUG, "keyframe stream hasn't been created\n");
176 return;
177 }
178
179 av_assert0(flv->last_keyframe_stream_index <= s->nb_streams);
180 stream = s->streams[flv->last_keyframe_stream_index];
181
182 if (ffstream(stream)->nb_index_entries == 0) {
183 for (i = 0; i < flv->keyframe_count; i++) {
184 av_log(s, AV_LOG_TRACE, "keyframe filepositions = %"PRId64" times = %"PRId64"\n",
187 flv->keyframe_times[i], 0, 0, AVINDEX_KEYFRAME);
188 }
189 } else
190 av_log(s, AV_LOG_WARNING, "Skipping duplicate index\n");
191
192 if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
195 flv->keyframe_count = 0;
196 }
197}
198
199static AVStream *create_stream(AVFormatContext *s, int codec_type, int track_idx)
200{
201 FFFormatContext *const si = ffformatcontext(s);
202 FLVContext *flv = s->priv_data;
204 if (!st)
205 return NULL;
207 st->id = track_idx;
208 avpriv_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */
209 if (track_idx)
210 return st;
211
212 if (s->nb_streams>=3 ||( s->nb_streams==2
213 && s->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE
214 && s->streams[1]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE
215 && s->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_DATA
216 && s->streams[1]->codecpar->codec_type != AVMEDIA_TYPE_DATA))
217 s->ctx_flags &= ~AVFMTCTX_NOHEADER;
219 st->codecpar->bit_rate = flv->audio_bit_rate;
221 }
223 st->codecpar->bit_rate = flv->video_bit_rate;
225 st->avg_frame_rate = flv->framerate;
226 }
227
228 flv->last_keyframe_stream_index = s->nb_streams - 1;
230 return st;
231}
232
233static int flv_same_audio_codec(AVCodecParameters *apar, int flags, uint32_t codec_fourcc)
234{
235 int bits_per_coded_sample = (flags & FLV_AUDIO_SAMPLESIZE_MASK) ? 16 : 8;
236 int flv_codecid = flags & FLV_AUDIO_CODECID_MASK;
237 int codec_id;
238
239 switch (codec_fourcc) {
240 case MKBETAG('m', 'p', '4', 'a'):
241 return apar->codec_id == AV_CODEC_ID_AAC;
242 case MKBETAG('O', 'p', 'u', 's'):
243 return apar->codec_id == AV_CODEC_ID_OPUS;
244 case MKBETAG('.', 'm', 'p', '3'):
245 return apar->codec_id == AV_CODEC_ID_MP3;
246 case MKBETAG('f', 'L', 'a', 'C'):
247 return apar->codec_id == AV_CODEC_ID_FLAC;
248 case MKBETAG('a', 'c', '-', '3'):
249 return apar->codec_id == AV_CODEC_ID_AC3;
250 case MKBETAG('e', 'c', '-', '3'):
251 return apar->codec_id == AV_CODEC_ID_EAC3;
252 case 0:
253 // Not enhanced flv, continue as normal.
254 break;
255 default:
256 // Unknown FOURCC
257 return 0;
258 }
259
260 if (!apar->codec_id && !apar->codec_tag)
261 return 1;
262
263 if (apar->bits_per_coded_sample != bits_per_coded_sample)
264 return 0;
265
266 switch (flv_codecid) {
267 // no distinction between S16 and S8 PCM codec flags
268 case FLV_CODECID_PCM:
269 codec_id = bits_per_coded_sample == 8
271#if HAVE_BIGENDIAN
273#else
275#endif
276 return codec_id == apar->codec_id;
278 codec_id = bits_per_coded_sample == 8
281 return codec_id == apar->codec_id;
282 case FLV_CODECID_AAC:
283 return apar->codec_id == AV_CODEC_ID_AAC;
285 return apar->codec_id == AV_CODEC_ID_ADPCM_SWF;
287 return apar->codec_id == AV_CODEC_ID_SPEEX;
288 case FLV_CODECID_MP3:
289 return apar->codec_id == AV_CODEC_ID_MP3;
293 return apar->codec_id == AV_CODEC_ID_NELLYMOSER;
295 return apar->sample_rate == 8000 &&
298 return apar->sample_rate == 8000 &&
300 default:
301 return apar->codec_tag == (flv_codecid >> FLV_AUDIO_CODECID_OFFSET);
302 }
303}
304
306 AVCodecParameters *apar, int flv_codecid)
307{
308 FFStream *const astreami = ffstream(astream);
309 AVCodecParameters *par = astream->codecpar;
310 enum AVCodecID old_codec_id = astream->codecpar->codec_id;
311
312 switch (flv_codecid) {
313 // no distinction between S16 and S8 PCM codec flags
314 case FLV_CODECID_PCM:
315 apar->codec_id = apar->bits_per_coded_sample == 8
317#if HAVE_BIGENDIAN
319#else
321#endif
322 break;
324 apar->codec_id = apar->bits_per_coded_sample == 8
327 break;
328 case FLV_CODECID_AAC:
330 break;
333 break;
336 apar->sample_rate = 16000;
337 break;
338 case FLV_CODECID_MP3:
341 break;
343 // in case metadata does not otherwise declare samplerate
344 apar->sample_rate = 8000;
346 break;
348 apar->sample_rate = 16000;
350 break;
353 break;
355 apar->sample_rate = 8000;
357 break;
359 apar->sample_rate = 8000;
361 break;
362 case MKBETAG('m', 'p', '4', 'a'):
364 break;
365 case MKBETAG('O', 'p', 'u', 's'):
367 apar->sample_rate = 48000;
368 break;
369 case MKBETAG('.', 'm', 'p', '3'):
371 break;
372 case MKBETAG('f', 'L', 'a', 'C'):
374 break;
375 case MKBETAG('a', 'c', '-', '3'):
377 break;
378 case MKBETAG('e', 'c', '-', '3'):
380 break;
381 default:
382 avpriv_request_sample(s, "Audio codec (%x)",
383 flv_codecid >> FLV_AUDIO_CODECID_OFFSET);
384 apar->codec_tag = flv_codecid >> FLV_AUDIO_CODECID_OFFSET;
385 }
386
387 if (!astreami->need_context_update && par->codec_id != old_codec_id) {
388 avpriv_request_sample(s, "Changing the codec id midstream");
390 }
391 return 0;
392}
393
394static int flv_same_video_codec(AVCodecParameters *vpar, uint32_t flv_codecid)
395{
396 if (!vpar->codec_id && !vpar->codec_tag)
397 return 1;
398
399 switch (flv_codecid) {
400 case MKBETAG('v', 'v', 'c', '1'):
401 return vpar->codec_id == AV_CODEC_ID_VVC;
403 case MKBETAG('h', 'v', 'c', '1'):
404 return vpar->codec_id == AV_CODEC_ID_HEVC;
405 case MKBETAG('a', 'v', '0', '1'):
406 return vpar->codec_id == AV_CODEC_ID_AV1;
407 case MKBETAG('v', 'p', '0', '9'):
408 return vpar->codec_id == AV_CODEC_ID_VP9;
409 case FLV_CODECID_H263:
410 return vpar->codec_id == AV_CODEC_ID_FLV1;
412 return vpar->codec_id == AV_CODEC_ID_FLASHSV;
414 return vpar->codec_id == AV_CODEC_ID_FLASHSV2;
415 case FLV_CODECID_VP6:
416 return vpar->codec_id == AV_CODEC_ID_VP6F;
417 case FLV_CODECID_VP6A:
418 return vpar->codec_id == AV_CODEC_ID_VP6A;
419 case FLV_CODECID_H264:
420 case MKBETAG('a', 'v', 'c', '1'):
421 return vpar->codec_id == AV_CODEC_ID_H264;
422 default:
423 return vpar->codec_tag == flv_codecid;
424 }
425}
426
428 uint32_t flv_codecid, int read)
429{
430 FFStream *const vstreami = ffstream(vstream);
431 int ret = 0;
432 AVCodecParameters *par = vstream->codecpar;
433 enum AVCodecID old_codec_id = vstream->codecpar->codec_id;
434
435 switch (flv_codecid) {
436 case MKBETAG('v', 'v', 'c', '1'):
439 break;
441 case MKBETAG('h', 'v', 'c', '1'):
444 break;
445 case MKBETAG('a', 'v', '0', '1'):
448 break;
449 case MKBETAG('v', 'p', '0', '9'):
452 break;
453 case FLV_CODECID_H263:
455 break;
458 break; // Really mean it this time
461 break;
464 break;
465 case FLV_CODECID_VP6:
468 case FLV_CODECID_VP6A:
469 if (flv_codecid == FLV_CODECID_VP6A)
471 if (read) {
472 if (par->extradata_size != 1) {
473 ff_alloc_extradata(par, 1);
474 }
475 if (par->extradata)
476 par->extradata[0] = avio_r8(s->pb);
477 else
478 avio_skip(s->pb, 1);
479 }
480 ret = 1; // 1 byte body size adjustment for flv_read_packet()
481 break;
482 case FLV_CODECID_H264:
483 case MKBETAG('a', 'v', 'c', '1'):
486 break;
489 break;
490 default:
491 avpriv_request_sample(s, "Video codec (%x)", flv_codecid);
492 par->codec_tag = flv_codecid;
493 }
494
495 if (!vstreami->need_context_update && par->codec_id != old_codec_id) {
496 avpriv_request_sample(s, "Changing the codec id midstream");
498 }
499
500 return ret;
501}
502
503static int amf_get_string(AVIOContext *ioc, char *buffer, int buffsize)
504{
505 int ret;
506 int length = avio_rb16(ioc);
507 if (length >= buffsize) {
508 avio_skip(ioc, length);
509 return AVERROR_INVALIDDATA;
510 }
511
512 ret = avio_read(ioc, buffer, length);
513 if (ret < 0)
514 return ret;
515 if (ret < length)
516 return AVERROR_INVALIDDATA;
517
518 buffer[length] = '\0';
519
520 return length;
521}
522
524{
525 FLVContext *flv = s->priv_data;
526 unsigned int timeslen = 0, fileposlen = 0, i;
527 char str_val[256];
528 int64_t *times = NULL;
529 int64_t *filepositions = NULL;
530 int ret = AVERROR(ENOSYS);
531 int64_t initial_pos = avio_tell(ioc);
532
533 if (flv->keyframe_count > 0) {
534 av_log(s, AV_LOG_DEBUG, "keyframes have been parsed\n");
535 return 0;
536 }
539
540 if (s->flags & AVFMT_FLAG_IGNIDX)
541 return 0;
542
543 while (avio_tell(ioc) < max_pos - 2 &&
544 amf_get_string(ioc, str_val, sizeof(str_val)) > 0) {
545 int64_t **current_array;
546 unsigned int arraylen;
547 int factor;
548
549 // Expect array object in context
550 if (avio_r8(ioc) != AMF_DATA_TYPE_ARRAY)
551 break;
552
553 arraylen = avio_rb32(ioc);
554 if (arraylen>>28)
555 break;
556
557 if (!strcmp(KEYFRAMES_TIMESTAMP_TAG , str_val) && !times) {
558 current_array = &times;
559 timeslen = arraylen;
560 factor = 1000;
561 } else if (!strcmp(KEYFRAMES_BYTEOFFSET_TAG, str_val) &&
562 !filepositions) {
563 current_array = &filepositions;
564 fileposlen = arraylen;
565 factor = 1;
566 } else
567 // unexpected metatag inside keyframes, will not use such
568 // metadata for indexing
569 break;
570
571 if (!(*current_array = av_mallocz(sizeof(**current_array) * arraylen))) {
572 ret = AVERROR(ENOMEM);
573 goto finish;
574 }
575
576 for (i = 0; i < arraylen && avio_tell(ioc) < max_pos - 1; i++) {
577 double d;
578 if (avio_r8(ioc) != AMF_DATA_TYPE_NUMBER)
579 goto invalid;
580 d = av_int2double(avio_rb64(ioc)) * factor;
581 if (isnan(d) || d < INT64_MIN || d > INT64_MAX)
582 goto invalid;
583 if (avio_feof(ioc))
584 goto invalid;
585 current_array[0][i] = d;
586 }
587 if (times && filepositions) {
588 // All done, exiting at a position allowing amf_parse_object
589 // to finish parsing the object
590 ret = 0;
591 break;
592 }
593 }
594
595 if (timeslen == fileposlen && fileposlen>1 && max_pos <= filepositions[0]) {
596 for (i = 0; i < FFMIN(2,fileposlen); i++) {
597 flv->validate_index[i].pos = filepositions[i];
598 flv->validate_index[i].dts = times[i];
599 flv->validate_count = i + 1;
600 }
601 flv->keyframe_times = times;
602 flv->keyframe_filepositions = filepositions;
603 flv->keyframe_count = timeslen;
604 times = NULL;
605 filepositions = NULL;
606 } else {
607invalid:
608 av_log(s, AV_LOG_WARNING, "Invalid keyframes object, skipping.\n");
609 }
610
611finish:
612 av_freep(&times);
613 av_freep(&filepositions);
614 avio_seek(ioc, initial_pos, SEEK_SET);
615 return ret;
616}
617
619 AVStream *vstream, const char *key,
620 int64_t max_pos, int depth)
621{
622 AVCodecParameters *apar, *vpar;
623 FLVContext *flv = s->priv_data;
624 AVIOContext *ioc;
625 AMFDataType amf_type;
626 char str_val[1024];
627 double num_val;
628 amf_date date;
629
630 if (depth > MAX_DEPTH)
632
633 num_val = 0;
634 ioc = s->pb;
635 if (avio_feof(ioc))
636 return AVERROR_EOF;
637 amf_type = avio_r8(ioc);
638
639 switch (amf_type) {
641 num_val = av_int2double(avio_rb64(ioc));
642 break;
644 num_val = avio_r8(ioc);
645 break;
647 if (amf_get_string(ioc, str_val, sizeof(str_val)) < 0) {
648 av_log(s, AV_LOG_ERROR, "AMF_DATA_TYPE_STRING parsing failed\n");
649 return -1;
650 }
651 break;
653 if (key &&
655 !strcmp(KEYFRAMES_TAG, key) && depth == 1)
656 if (parse_keyframes_index(s, ioc, max_pos) < 0)
657 av_log(s, AV_LOG_ERROR, "Keyframe index parsing failed\n");
658 else
660 while (avio_tell(ioc) < max_pos - 2 &&
661 amf_get_string(ioc, str_val, sizeof(str_val)) > 0)
662 if (amf_parse_object(s, astream, vstream, str_val, max_pos,
663 depth + 1) < 0)
664 return -1; // if we couldn't skip, bomb out.
665 if (avio_r8(ioc) != AMF_END_OF_OBJECT) {
666 av_log(s, AV_LOG_ERROR, "Missing AMF_END_OF_OBJECT in AMF_DATA_TYPE_OBJECT\n");
667 return -1;
668 }
669 break;
673 break; // these take up no additional space
675 {
676 unsigned v;
677 avio_skip(ioc, 4); // skip 32-bit max array index
678 while (avio_tell(ioc) < max_pos - 2 &&
679 amf_get_string(ioc, str_val, sizeof(str_val)) > 0)
680 // this is the only case in which we would want a nested
681 // parse to not skip over the object
682 if (amf_parse_object(s, astream, vstream, str_val, max_pos,
683 depth + 1) < 0)
684 return -1;
685 v = avio_r8(ioc);
686 if (v != AMF_END_OF_OBJECT) {
687 av_log(s, AV_LOG_ERROR, "Missing AMF_END_OF_OBJECT in AMF_DATA_TYPE_MIXEDARRAY, found %d\n", v);
688 return -1;
689 }
690 break;
691 }
693 {
694 unsigned int arraylen, i;
695
696 arraylen = avio_rb32(ioc);
697 for (i = 0; i < arraylen && avio_tell(ioc) < max_pos - 1; i++)
699 depth + 1) < 0)
700 return -1; // if we couldn't skip, bomb out.
701 }
702 break;
704 // timestamp (double) and UTC offset (int16)
706 date.timezone = avio_rb16(ioc);
707 break;
708 default: // unsupported type, we couldn't skip
709 av_log(s, AV_LOG_ERROR, "unsupported amf type %d\n", amf_type);
710 return -1;
711 }
712
713 if (key) {
714 apar = astream ? astream->codecpar : NULL;
715 vpar = vstream ? vstream->codecpar : NULL;
716
717 // stream info doesn't live any deeper than the first object
718 if (depth == 1) {
719 if (amf_type == AMF_DATA_TYPE_NUMBER ||
720 amf_type == AMF_DATA_TYPE_BOOL) {
721 if (!strcmp(key, "duration"))
722 s->duration = num_val * AV_TIME_BASE;
723 else if (!strcmp(key, "videodatarate") &&
724 0 <= (int)(num_val * 1024.0))
725 flv->video_bit_rate = num_val * 1024.0;
726 else if (!strcmp(key, "audiodatarate") &&
727 0 <= (int)(num_val * 1024.0))
728 flv->audio_bit_rate = num_val * 1024.0;
729 else if (!strcmp(key, "framerate")) {
730 flv->framerate = av_d2q(num_val, 1000);
731 if (vstream)
732 vstream->avg_frame_rate = flv->framerate;
733 } else if (flv->trust_metadata) {
734 if (!strcmp(key, "videocodecid") && vpar) {
735 int ret = flv_set_video_codec(s, vstream, num_val, 0);
736 if (ret < 0)
737 return ret;
738 } else if (!strcmp(key, "audiocodecid") && apar) {
739 int id = ((int)num_val) << FLV_AUDIO_CODECID_OFFSET;
740 int ret = flv_set_audio_codec(s, astream, apar, id);
741 if (ret < 0)
742 return ret;
743 } else if (!strcmp(key, "audiosamplerate") && apar) {
744 apar->sample_rate = num_val;
745 } else if (!strcmp(key, "audiosamplesize") && apar) {
746 apar->bits_per_coded_sample = num_val;
747 } else if (!strcmp(key, "stereo") && apar) {
748 av_channel_layout_default(&apar->ch_layout, num_val + 1);
749 } else if (!strcmp(key, "width") && vpar) {
750 vpar->width = num_val;
751 } else if (!strcmp(key, "height") && vpar) {
752 vpar->height = num_val;
753 } else if (!strcmp(key, "datastream")) {
755 if (!st)
756 return AVERROR(ENOMEM);
758 }
759 }
760 }
761 if (amf_type == AMF_DATA_TYPE_STRING) {
762 if (!strcmp(key, "encoder")) {
763 int version = -1;
764 if (1 == sscanf(str_val, "Open Broadcaster Software v0.%d", &version)) {
765 if (version > 0 && version <= 655)
766 flv->broken_sizes = 1;
767 }
768 } else if (!strcmp(key, "metadatacreator")) {
769 if ( !strcmp (str_val, "MEGA")
770 || !strncmp(str_val, "FlixEngine", 10))
771 flv->broken_sizes = 1;
772 }
773 }
774 }
775
777 FLVMetaVideoColor *meta_video_color = &flv->meta_color_info;
778 if (!strcmp(key, "colorPrimaries")) {
779 meta_video_color->primaries = num_val;
780 } else if (!strcmp(key, "transferCharacteristics")) {
781 meta_video_color->trc = num_val;
782 } else if (!strcmp(key, "matrixCoefficients")) {
783 meta_video_color->matrix_coefficients = num_val;
784 } else if (!strcmp(key, "maxFall")) {
785 meta_video_color->max_fall = num_val;
786 } else if (!strcmp(key, "maxCLL")) {
787 meta_video_color->max_cll = num_val;
788 } else if (!strcmp(key, "redX")) {
789 meta_video_color->mastering_meta.r_x = num_val;
790 } else if (!strcmp(key, "redY")) {
791 meta_video_color->mastering_meta.r_y = num_val;
792 } else if (!strcmp(key, "greenX")) {
793 meta_video_color->mastering_meta.g_x = num_val;
794 } else if (!strcmp(key, "greenY")) {
795 meta_video_color->mastering_meta.g_y = num_val;
796 } else if (!strcmp(key, "blueX")) {
797 meta_video_color->mastering_meta.b_x = num_val;
798 } else if (!strcmp(key, "blueY")) {
799 meta_video_color->mastering_meta.b_y = num_val;
800 } else if (!strcmp(key, "whitePointX")) {
801 meta_video_color->mastering_meta.white_x = num_val;
802 } else if (!strcmp(key, "whitePointY")) {
803 meta_video_color->mastering_meta.white_y = num_val;
804 } else if (!strcmp(key, "maxLuminance")) {
805 meta_video_color->mastering_meta.max_luminance = num_val;
806 } else if (!strcmp(key, "minLuminance")) {
807 meta_video_color->mastering_meta.min_luminance = num_val;
808 }
809 }
810
811 if (amf_type == AMF_DATA_TYPE_OBJECT && s->nb_streams == 1 &&
812 ((!apar && !strcmp(key, "audiocodecid")) ||
813 (!vpar && !strcmp(key, "videocodecid"))))
814 s->ctx_flags &= ~AVFMTCTX_NOHEADER; //If there is either audio/video missing, codecid will be an empty object
815
816 if ((!strcmp(key, "duration") ||
817 !strcmp(key, "filesize") ||
818 !strcmp(key, "width") ||
819 !strcmp(key, "height") ||
820 !strcmp(key, "videodatarate") ||
821 !strcmp(key, "framerate") ||
822 !strcmp(key, "videocodecid") ||
823 !strcmp(key, "audiodatarate") ||
824 !strcmp(key, "audiosamplerate") ||
825 !strcmp(key, "audiosamplesize") ||
826 !strcmp(key, "stereo") ||
827 !strcmp(key, "audiocodecid") ||
828 !strcmp(key, "datastream")) && !flv->dump_full_metadata)
829 return 0;
830
831 s->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;
832 if (amf_type == AMF_DATA_TYPE_BOOL) {
833 av_strlcpy(str_val, num_val > 0 ? "true" : "false",
834 sizeof(str_val));
835 av_dict_set(&s->metadata, key, str_val, 0);
836 } else if (amf_type == AMF_DATA_TYPE_NUMBER) {
837 snprintf(str_val, sizeof(str_val), "%.f", num_val);
838 av_dict_set(&s->metadata, key, str_val, 0);
839 } else if (amf_type == AMF_DATA_TYPE_STRING) {
840 av_dict_set(&s->metadata, key, str_val, 0);
841 } else if ( amf_type == AMF_DATA_TYPE_DATE
842 && isfinite(date.milliseconds)
843 && date.milliseconds > INT64_MIN/1000
844 && date.milliseconds < INT64_MAX/1000
845 ) {
846 // timezone is ignored, since there is no easy way to offset the UTC
847 // timestamp into the specified timezone
848 ff_dict_set_timestamp(&s->metadata, key, 1000 * (int64_t)date.milliseconds);
849 }
850 }
851
852 return 0;
853}
854
855#define TYPE_ONTEXTDATA 1
856#define TYPE_ONCAPTION 2
857#define TYPE_ONCAPTIONINFO 3
858#define TYPE_UNKNOWN 9
859
861{
862 FLVContext *flv = s->priv_data;
864 AVStream *stream, *astream, *vstream;
865 av_unused AVStream *dstream;
866 AVIOContext *ioc;
867 int i;
868 char buffer[32];
869
870 astream = NULL;
871 vstream = NULL;
872 dstream = NULL;
873 ioc = s->pb;
874
875 // first object needs to be "onMetaData" string
876 type = avio_r8(ioc);
877 if (type != AMF_DATA_TYPE_STRING ||
878 amf_get_string(ioc, buffer, sizeof(buffer)) < 0)
879 return TYPE_UNKNOWN;
880
881 if (!strcmp(buffer, "onTextData"))
882 return TYPE_ONTEXTDATA;
883
884 if (!strcmp(buffer, "onCaption"))
885 return TYPE_ONCAPTION;
886
887 if (!strcmp(buffer, "onCaptionInfo"))
888 return TYPE_ONCAPTIONINFO;
889
890 if (strcmp(buffer, "onMetaData") && strcmp(buffer, "onCuePoint") && strcmp(buffer, "|RtmpSampleAccess")) {
891 av_log(s, AV_LOG_DEBUG, "Unknown type %s\n", buffer);
892 return TYPE_UNKNOWN;
893 }
894
895 // find the streams now so that amf_parse_object doesn't need to do
896 // the lookup every time it is called.
897 for (i = 0; i < s->nb_streams; i++) {
898 stream = s->streams[i];
899 if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
900 vstream = stream;
902 } else if (stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
903 astream = stream;
904 if (flv->last_keyframe_stream_index == -1)
906 } else if (stream->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE)
907 dstream = stream;
908 }
909
910 // parse the second object (we want a mixed array)
911 if (amf_parse_object(s, astream, vstream, buffer, next_pos, 0) < 0)
912 return -1;
913
914 return 0;
915}
916
918{
919 FFFormatContext *const si = ffformatcontext(s);
920 int flags;
921 FLVContext *flv = s->priv_data;
922 int offset;
923 int pre_tag_size = 0;
924
925 /* Actual FLV data at 0xe40000 in KUX file */
926 if(!strcmp(s->iformat->name, "kux"))
927 avio_skip(s->pb, 0xe40000);
928
929 avio_skip(s->pb, 4);
930 flags = avio_r8(s->pb);
931
933
934 s->ctx_flags |= AVFMTCTX_NOHEADER;
935
936 offset = avio_rb32(s->pb);
937 avio_seek(s->pb, offset, SEEK_SET);
938
939 /* Annex E. The FLV File Format
940 * E.3 TheFLVFileBody
941 * Field Type Comment
942 * PreviousTagSize0 UI32 Always 0
943 * */
944 pre_tag_size = avio_rb32(s->pb);
945 if (pre_tag_size) {
946 av_log(s, AV_LOG_WARNING, "Read FLV header error, input file is not a standard flv format, first PreviousTagSize0 always is 0\n");
947 }
948
949 s->start_time = 0;
950 flv->sum_flv_tag_size = 0;
952
953 return 0;
954}
955
957{
958 int i;
959 FLVContext *flv = s->priv_data;
960 for (i = 0; i < FLV_STREAM_TYPE_NB; i++)
961 av_freep(&flv->new_extradata[i]);
962 for (i = 0; i < flv->mt_extradata_cnt; i++)
963 av_freep(&flv->mt_extradata[i]);
964 av_freep(&flv->mt_extradata);
968 return 0;
969}
970
972{
973 int ret;
974 if (!size)
975 return 0;
976
977 if ((ret = ff_get_extradata(s, st->codecpar, s->pb, size)) < 0)
978 return ret;
980 return 0;
981}
982
983static int flv_queue_extradata(FLVContext *flv, AVIOContext *pb, int stream,
984 int size, int multitrack)
985{
986 if (!size)
987 return 0;
988
989 if (!multitrack) {
990 av_free(flv->new_extradata[stream]);
991 flv->new_extradata[stream] = av_mallocz(size +
993 if (!flv->new_extradata[stream])
994 return AVERROR(ENOMEM);
995 flv->new_extradata_size[stream] = size;
996 avio_read(pb, flv->new_extradata[stream], size);
997 } else {
998 int new_count = stream + 1;
999
1000 if (flv->mt_extradata_cnt < new_count) {
1001 void *tmp = av_realloc_array(flv->mt_extradata, new_count,
1002 sizeof(*flv->mt_extradata));
1003 if (!tmp)
1004 return AVERROR(ENOMEM);
1005 flv->mt_extradata = tmp;
1006
1007 tmp = av_realloc_array(flv->mt_extradata_sz, new_count,
1008 sizeof(*flv->mt_extradata_sz));
1009 if (!tmp)
1010 return AVERROR(ENOMEM);
1011 flv->mt_extradata_sz = tmp;
1012
1013 // Set newly allocated pointers/sizes to 0
1014 for (int i = flv->mt_extradata_cnt; i < new_count; i++) {
1015 flv->mt_extradata[i] = NULL;
1016 flv->mt_extradata_sz[i] = 0;
1017 }
1018 flv->mt_extradata_cnt = new_count;
1019 }
1020
1021 av_free(flv->mt_extradata[stream]);
1023 if (!flv->mt_extradata[stream])
1024 return AVERROR(ENOMEM);
1025 flv->mt_extradata_sz[stream] = size;
1026 avio_read(pb, flv->mt_extradata[stream], size);
1027 }
1028
1029 return 0;
1030}
1031
1033{
1035 "Found invalid index entries, clearing the index.\n");
1036 for (unsigned i = 0; i < s->nb_streams; i++) {
1037 FFStream *const sti = ffstream(s->streams[i]);
1038 int out = 0;
1039 /* Remove all index entries that point to >= pos */
1040 for (int j = 0; j < sti->nb_index_entries; j++)
1041 if (sti->index_entries[j].pos < pos)
1042 sti->index_entries[out++] = sti->index_entries[j];
1043 sti->nb_index_entries = out;
1044 }
1045}
1046
1047static int amf_skip_tag(AVIOContext *pb, AMFDataType type, int depth)
1048{
1049 int nb = -1, ret, parse_name = 1;
1050
1051 if (depth > MAX_DEPTH)
1052 return AVERROR_PATCHWELCOME;
1053
1054 if (avio_feof(pb))
1055 return AVERROR_EOF;
1056
1057 switch (type) {
1059 avio_skip(pb, 8);
1060 break;
1061 case AMF_DATA_TYPE_BOOL:
1062 avio_skip(pb, 1);
1063 break;
1065 avio_skip(pb, avio_rb16(pb));
1066 break;
1068 parse_name = 0;
1071 nb = avio_rb32(pb);
1072 if (nb < 0)
1073 return AVERROR_INVALIDDATA;
1076 while(!pb->eof_reached && (nb-- > 0 || type != AMF_DATA_TYPE_ARRAY)) {
1077 if (parse_name) {
1078 int size = avio_rb16(pb);
1079 if (!size) {
1080 avio_skip(pb, 1);
1081 break;
1082 }
1083 avio_skip(pb, size);
1084 }
1085 if ((ret = amf_skip_tag(pb, avio_r8(pb), depth + 1)) < 0)
1086 return ret;
1087 }
1088 break;
1089 case AMF_DATA_TYPE_NULL:
1091 break;
1092 default:
1093 return AVERROR_INVALIDDATA;
1094 }
1095 return 0;
1096}
1097
1099 int64_t dts, int64_t next)
1100{
1101 AVIOContext *pb = s->pb;
1102 AVStream *st = NULL;
1103 char buf[20];
1104 int ret = AVERROR_INVALIDDATA;
1105 int i, length = -1;
1106 int array = 0;
1107
1108 switch (avio_r8(pb)) {
1110 array = 1;
1113 avio_seek(pb, 4, SEEK_CUR);
1116 break;
1117 default:
1118 goto skip;
1119 }
1120
1121 while (array || (ret = amf_get_string(pb, buf, sizeof(buf))) > 0) {
1122 AMFDataType type = avio_r8(pb);
1123 if (type == AMF_DATA_TYPE_STRING && (array || !strcmp(buf, "text"))) {
1124 length = avio_rb16(pb);
1125 ret = av_get_packet(pb, pkt, length);
1126 if (ret < 0)
1127 goto skip;
1128 else
1129 break;
1130 } else {
1131 if ((ret = amf_skip_tag(pb, type, 0)) < 0)
1132 goto skip;
1133 }
1134 }
1135
1136 if (length < 0) {
1137 ret = AVERROR_INVALIDDATA;
1138 goto skip;
1139 }
1140
1141 for (i = 0; i < s->nb_streams; i++) {
1142 st = s->streams[i];
1144 break;
1145 }
1146
1147 if (i == s->nb_streams) {
1149 if (!st)
1150 return AVERROR(ENOMEM);
1152 }
1153
1154 pkt->dts = dts;
1155 pkt->pts = dts;
1156 pkt->size = ret;
1157
1158 pkt->stream_index = st->index;
1159 pkt->flags |= AV_PKT_FLAG_KEY;
1160
1161skip:
1162 avio_seek(s->pb, next + 4, SEEK_SET);
1163
1164 return ret;
1165}
1166
1168{
1169 FLVContext *flv = s->priv_data;
1170 int64_t i;
1171 int64_t pos = avio_tell(s->pb);
1172
1173 for (i=0; !avio_feof(s->pb); i++) {
1174 int j = i & (RESYNC_BUFFER_SIZE-1);
1175 int j1 = j + RESYNC_BUFFER_SIZE;
1176 flv->resync_buffer[j ] =
1177 flv->resync_buffer[j1] = avio_r8(s->pb);
1178
1179 if (i >= 8 && pos) {
1180 uint8_t *d = flv->resync_buffer + j1 - 8;
1181 if (d[0] == 'F' &&
1182 d[1] == 'L' &&
1183 d[2] == 'V' &&
1184 d[3] < 5 && d[5] == 0) {
1185 av_log(s, AV_LOG_WARNING, "Concatenated FLV detected, might fail to demux, decode and seek %"PRId64"\n", flv->last_ts);
1186 flv->time_offset = flv->last_ts + 1;
1187 flv->time_pos = avio_tell(s->pb);
1188 }
1189 }
1190
1191 if (i > 22) {
1192 unsigned lsize2 = AV_RB32(flv->resync_buffer + j1 - 4);
1193 if (lsize2 >= 11 && lsize2 + 8LL < FFMIN(i, RESYNC_BUFFER_SIZE)) {
1194 unsigned size2 = AV_RB24(flv->resync_buffer + j1 - lsize2 + 1 - 4);
1195 unsigned lsize1 = AV_RB32(flv->resync_buffer + j1 - lsize2 - 8);
1196 if (lsize1 >= 11 && lsize1 + 8LL + lsize2 < FFMIN(i, RESYNC_BUFFER_SIZE)) {
1197 unsigned size1 = AV_RB24(flv->resync_buffer + j1 - lsize1 + 1 - lsize2 - 8);
1198 if (size1 == lsize1 - 11 && size2 == lsize2 - 11) {
1199 avio_seek(s->pb, pos + i - lsize1 - lsize2 - 8, SEEK_SET);
1200 return 1;
1201 }
1202 }
1203 }
1204 }
1205 }
1206 return AVERROR_EOF;
1207}
1208
1210{
1211 int ret;
1212 FLVContext *flv = s->priv_data;
1214 AVIOContext *ioc;
1215 char buffer[32];
1216 ioc = s->pb;
1217
1218 // first object needs to be "colorInfo" string
1219 type = avio_r8(ioc);
1220 if (type != AMF_DATA_TYPE_STRING) {
1221 av_log(s, AV_LOG_WARNING, "Ignore invalid colorInfo\n");
1222 return 0;
1223 }
1224
1225 ret = amf_get_string(ioc, buffer, sizeof(buffer));
1226 if (ret < 0)
1227 return ret;
1228
1229 if (strcmp(buffer, "colorInfo") != 0) {
1230 av_log(s, AV_LOG_WARNING, "Ignore invalid colorInfo type %s\n", buffer);
1231 return 0;
1232 }
1233
1235 ret = amf_parse_object(s, NULL, NULL, buffer, next_pos, 0); // parse metadata
1236 if (ret < 0) {
1238 return ret;
1239 }
1240
1242
1243 return 0;
1244}
1245
1247{
1248 FLVContext *flv = s->priv_data;
1249 const FLVMetaVideoColor* meta_video_color = &flv->meta_color_info;
1250 const FLVMasteringMeta *mastering_meta = &meta_video_color->mastering_meta;
1251
1252 int has_mastering_primaries, has_mastering_luminance;
1253 // Mastering primaries are CIE 1931 coords, and must be > 0.
1254 has_mastering_primaries =
1255 mastering_meta->r_x > 0 && mastering_meta->r_y > 0 &&
1256 mastering_meta->g_x > 0 && mastering_meta->g_y > 0 &&
1257 mastering_meta->b_x > 0 && mastering_meta->b_y > 0 &&
1258 mastering_meta->white_x > 0 && mastering_meta->white_y > 0;
1259 has_mastering_luminance = mastering_meta->max_luminance > 0 && mastering_meta->min_luminance > 0;
1260
1261 if (meta_video_color->matrix_coefficients != AVCOL_SPC_RESERVED)
1262 st->codecpar->color_space = meta_video_color->matrix_coefficients;
1263 if (meta_video_color->primaries != AVCOL_PRI_RESERVED &&
1264 meta_video_color->primaries != AVCOL_PRI_RESERVED0)
1265 st->codecpar->color_primaries = meta_video_color->primaries;
1266 if (meta_video_color->trc != AVCOL_TRC_RESERVED &&
1267 meta_video_color->trc != AVCOL_TRC_RESERVED0)
1268 st->codecpar->color_trc = meta_video_color->trc;
1269
1270 if (meta_video_color->max_cll && meta_video_color->max_fall) {
1271 size_t size = 0;
1273 if (!metadata)
1274 return AVERROR(ENOMEM);
1278 return AVERROR(ENOMEM);
1279 }
1280 metadata->MaxCLL = meta_video_color->max_cll;
1281 metadata->MaxFALL = meta_video_color->max_fall;
1282 }
1283
1284 if (has_mastering_primaries || has_mastering_luminance) {
1285 size_t size = 0;
1287 AVPacketSideData *sd;
1288
1289 if (!metadata)
1290 return AVERROR(ENOMEM);
1291
1295 metadata, size, 0);
1296 if (!sd) {
1298 return AVERROR(ENOMEM);
1299 }
1300
1301 // hdrCll
1302 if (has_mastering_luminance) {
1303 metadata->max_luminance = av_d2q(mastering_meta->max_luminance, INT_MAX);
1304 metadata->min_luminance = av_d2q(mastering_meta->min_luminance, INT_MAX);
1305 metadata->has_luminance = 1;
1306 }
1307 // hdrMdcv
1308 if (has_mastering_primaries) {
1309 metadata->display_primaries[0][0] = av_d2q(mastering_meta->r_x, INT_MAX);
1310 metadata->display_primaries[0][1] = av_d2q(mastering_meta->r_y, INT_MAX);
1311 metadata->display_primaries[1][0] = av_d2q(mastering_meta->g_x, INT_MAX);
1312 metadata->display_primaries[1][1] = av_d2q(mastering_meta->g_y, INT_MAX);
1313 metadata->display_primaries[2][0] = av_d2q(mastering_meta->b_x, INT_MAX);
1314 metadata->display_primaries[2][1] = av_d2q(mastering_meta->b_y, INT_MAX);
1315 metadata->white_point[0] = av_d2q(mastering_meta->white_x, INT_MAX);
1316 metadata->white_point[1] = av_d2q(mastering_meta->white_y, INT_MAX);
1317 metadata->has_primaries = 1;
1318 }
1319 }
1320 return 0;
1321}
1322
1323static int flv_parse_mod_ex_data(AVFormatContext *s, int *pkt_type, int *size, int64_t *dts)
1324{
1325 int ex_type, ret;
1326 uint8_t *ex_data;
1327
1328 int ex_size = (uint8_t)avio_r8(s->pb) + 1;
1329 *size -= 1;
1330
1331 if (ex_size == 256) {
1332 ex_size = (uint16_t)avio_rb16(s->pb) + 1;
1333 *size -= 2;
1334 }
1335
1336 if (ex_size >= *size) {
1337 av_log(s, AV_LOG_WARNING, "ModEx size larger than remaining data!\n");
1338 return AVERROR(EINVAL);
1339 }
1340
1341 ex_data = av_malloc(ex_size);
1342 if (!ex_data)
1343 return AVERROR(ENOMEM);
1344
1345 ret = avio_read(s->pb, ex_data, ex_size);
1346 if (ret < 0) {
1347 av_free(ex_data);
1348 return ret;
1349 }
1350 *size -= ex_size;
1351
1352 ex_type = (uint8_t)avio_r8(s->pb);
1353 *size -= 1;
1354
1355 *pkt_type = ex_type & 0x0f;
1356 ex_type &= 0xf0;
1357
1358 if (ex_type == PacketModExTypeTimestampOffsetNano) {
1359 uint32_t nano_offset;
1360
1361 if (ex_size != 3) {
1362 av_log(s, AV_LOG_WARNING, "Invalid ModEx size for Type TimestampOffsetNano!\n");
1363 nano_offset = 0;
1364 } else {
1365 nano_offset = (ex_data[0] << 16) | (ex_data[1] << 8) | ex_data[2];
1366 }
1367
1368 // this is not likely to ever add anything, but right now timestamps are with ms precision
1369 *dts += nano_offset / 1000000;
1370 } else {
1371 av_log(s, AV_LOG_INFO, "Unknown ModEx type: %d", ex_type);
1372 }
1373
1374 av_free(ex_data);
1375
1376 return 0;
1377}
1378
1380{
1381 FLVContext *flv = s->priv_data;
1382 int ret = AVERROR_BUG, i, size, flags;
1383 int res = 0;
1384 enum FlvTagType type;
1385 int stream_type = -1;
1386 int64_t next, pos, meta_pos;
1387 int64_t dts, pts = AV_NOPTS_VALUE;
1388 int av_uninit(channels);
1389 int av_uninit(sample_rate);
1390 AVStream *st = NULL;
1391 int last = -1;
1392 int orig_size;
1393 int enhanced_flv = 0;
1394 int multitrack = 0;
1395 int pkt_type = 0;
1396 uint8_t track_idx = 0;
1397 uint32_t codec_id = 0;
1398 int multitrack_type = MultitrackTypeOneTrack;
1399
1400retry:
1401 /* pkt size is repeated at end. skip it */
1402 pos = avio_tell(s->pb);
1403 type = (avio_r8(s->pb) & 0x1F);
1404 orig_size =
1405 size = avio_rb24(s->pb);
1406 flv->sum_flv_tag_size += size + 11LL;
1407 dts = avio_rb24(s->pb);
1408 dts |= (unsigned)avio_r8(s->pb) << 24;
1409 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));
1410 if (avio_feof(s->pb))
1411 return AVERROR_EOF;
1412 avio_skip(s->pb, 3); /* stream id, always 0 */
1413 flags = 0;
1414
1415 if (flv->validate_next < flv->validate_count) {
1416 int64_t validate_pos = flv->validate_index[flv->validate_next].pos;
1417 if (pos == validate_pos) {
1418 if (FFABS(dts - flv->validate_index[flv->validate_next].dts) <=
1420 flv->validate_next++;
1421 } else {
1422 clear_index_entries(s, validate_pos);
1423 flv->validate_count = 0;
1424 }
1425 } else if (pos > validate_pos) {
1426 clear_index_entries(s, validate_pos);
1427 flv->validate_count = 0;
1428 }
1429 }
1430
1431 if (size == 0) {
1432 ret = FFERROR_REDO;
1433 goto leave;
1434 }
1435
1436 next = size + avio_tell(s->pb);
1437
1438 if (type == FLV_TAG_TYPE_AUDIO) {
1439 stream_type = FLV_STREAM_TYPE_AUDIO;
1440 flags = avio_r8(s->pb);
1441 size--;
1442
1444 enhanced_flv = 1;
1445 pkt_type = flags & ~FLV_AUDIO_CODECID_MASK;
1446
1447 while (pkt_type == PacketTypeModEx) {
1448 ret = flv_parse_mod_ex_data(s, &pkt_type, &size, &dts);
1449 if (ret < 0)
1450 goto leave;
1451 }
1452
1453 if (pkt_type == AudioPacketTypeMultitrack) {
1454 uint8_t types = avio_r8(s->pb);
1455 multitrack_type = types & 0xF0;
1456 pkt_type = types & 0xF;
1457
1458 multitrack = 1;
1459 size--;
1460 }
1461
1462 codec_id = avio_rb32(s->pb);
1463 size -= 4;
1464
1465 if (multitrack) {
1466 track_idx = avio_r8(s->pb);
1467 size--;
1468 }
1469 }
1470 } else if (type == FLV_TAG_TYPE_VIDEO) {
1471 stream_type = FLV_STREAM_TYPE_VIDEO;
1472 flags = avio_r8(s->pb);
1474 /*
1475 * Reference Enhancing FLV 2023-03-v1.0.0-B.8
1476 * https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf
1477 * */
1478 enhanced_flv = (flags >> 7) & 1;
1479 pkt_type = enhanced_flv ? codec_id : 0;
1480 size--;
1481
1482 while (pkt_type == PacketTypeModEx) {
1483 ret = flv_parse_mod_ex_data(s, &pkt_type, &size, &dts);
1484 if (ret < 0)
1485 goto leave;
1486 }
1487
1488 if (enhanced_flv && pkt_type != PacketTypeMetadata &&
1490 goto skip;
1491
1492 if (pkt_type == PacketTypeMultitrack) {
1493 uint8_t types = avio_r8(s->pb);
1494 multitrack_type = types & 0xF0;
1495 pkt_type = types & 0xF;
1496
1497 multitrack = 1;
1498 size--;
1499 }
1500
1501 if (enhanced_flv) {
1502 codec_id = avio_rb32(s->pb);
1503 size -= 4;
1504 }
1505 if (multitrack) {
1506 track_idx = avio_r8(s->pb);
1507 size--;
1508 }
1509
1510 if (enhanced_flv && (flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_VIDEO_INFO_CMD) {
1511 if (pkt_type == PacketTypeMetadata) {
1512 ret = flv_parse_video_color_info(s, st, next);
1513 if (ret < 0)
1514 goto leave;
1515 }
1516 goto skip;
1518 goto skip;
1519 }
1520 } else if (type == FLV_TAG_TYPE_META) {
1521 stream_type=FLV_STREAM_TYPE_SUBTITLE;
1522 if (size > 13 + 1 + 4) { // Header-type metadata stuff
1523 int type;
1524 meta_pos = avio_tell(s->pb);
1525 type = flv_read_metabody(s, next);
1526 if (type == 0 && dts == 0 || type < 0) {
1527 if (type < 0 && flv->validate_count &&
1528 flv->validate_index[0].pos > next &&
1529 flv->validate_index[0].pos - 4 < next) {
1530 av_log(s, AV_LOG_WARNING, "Adjusting next position due to index mismatch\n");
1531 next = flv->validate_index[0].pos - 4;
1532 }
1533 goto skip;
1534 } else if (type == TYPE_ONTEXTDATA) {
1535 avpriv_request_sample(s, "OnTextData packet");
1536 return flv_data_packet(s, pkt, dts, next);
1537 } else if (type == TYPE_ONCAPTION) {
1538 return flv_data_packet(s, pkt, dts, next);
1539 } else if (type == TYPE_UNKNOWN) {
1540 stream_type = FLV_STREAM_TYPE_DATA;
1541 }
1542 avio_seek(s->pb, meta_pos, SEEK_SET);
1543 }
1544 } else {
1546 "Skipping flv packet: type %d, size %d, flags %d.\n",
1547 type, size, flags);
1548skip:
1549 if (avio_seek(s->pb, next, SEEK_SET) != next) {
1550 // This can happen if flv_read_metabody above read past
1551 // next, on a non-seekable input, and the preceding data has
1552 // been flushed out from the IO buffer.
1553 av_log(s, AV_LOG_ERROR, "Unable to seek to the next packet\n");
1554 return AVERROR_INVALIDDATA;
1555 }
1556 ret = FFERROR_REDO;
1557 goto leave;
1558 }
1559
1560 /* skip empty data packets */
1561 if (!size) {
1562 ret = FFERROR_REDO;
1563 goto leave;
1564 }
1565
1566 for (;;) {
1567 int track_size = size;
1568 if (size < 0) {
1569 ret = FFERROR_REDO;
1570 goto leave;
1571 }
1572
1573 if (multitrack_type != MultitrackTypeOneTrack) {
1574 track_size = avio_rb24(s->pb);
1575 size -= 3;
1576 }
1577
1578 /* now find stream */
1579 for (i = 0; i < s->nb_streams; i++) {
1580 st = s->streams[i];
1581 if (stream_type == FLV_STREAM_TYPE_AUDIO) {
1583 (s->audio_codec_id || flv_same_audio_codec(st->codecpar, flags, codec_id)) &&
1584 st->id == track_idx)
1585 break;
1586 } else if (stream_type == FLV_STREAM_TYPE_VIDEO) {
1588 (s->video_codec_id || flv_same_video_codec(st->codecpar, codec_id)) &&
1589 st->id == track_idx)
1590 break;
1591 } else if (stream_type == FLV_STREAM_TYPE_SUBTITLE) {
1593 break;
1594 } else if (stream_type == FLV_STREAM_TYPE_DATA) {
1596 break;
1597 }
1598 }
1599 if (i == s->nb_streams) {
1601 st = create_stream(s, stream_types[stream_type], track_idx);
1602 if (!st)
1603 return AVERROR(ENOMEM);
1604 }
1605 av_log(s, AV_LOG_TRACE, "%d %X %d \n", stream_type, flags, st->discard);
1606
1607 if (flv->time_pos <= pos) {
1608 dts += flv->time_offset;
1609 }
1610
1611 if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) &&
1613 stream_type == FLV_STREAM_TYPE_AUDIO))
1614 av_add_index_entry(st, pos, dts, track_size, 0, AVINDEX_KEYFRAME);
1615
1616 if ((st->discard >= AVDISCARD_NONKEY && !((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY || stream_type == FLV_STREAM_TYPE_AUDIO)) ||
1618 st->discard >= AVDISCARD_ALL) {
1619 avio_seek(s->pb, next, SEEK_SET);
1620 ret = FFERROR_REDO;
1621 goto leave;
1622 }
1623
1624 // if not streamed and no duration from metadata then seek to end to find
1625 // the duration from the timestamps
1626 if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) &&
1627 (!s->duration || s->duration == AV_NOPTS_VALUE) &&
1628 !flv->searched_for_end) {
1629 int final_size;
1630 const int64_t pos = avio_tell(s->pb);
1631 // Read the last 4 bytes of the file, this should be the size of the
1632 // previous FLV tag. Use the timestamp of its payload as duration.
1633 int64_t fsize = avio_size(s->pb);
1634retry_duration:
1635 avio_seek(s->pb, fsize - 4, SEEK_SET);
1636 final_size = avio_rb32(s->pb);
1637 if (final_size > 0 && final_size < fsize) {
1638 // Seek to the start of the last FLV tag at position (fsize - 4 - final_size)
1639 // but skip the byte indicating the type.
1640 avio_seek(s->pb, fsize - 3 - final_size, SEEK_SET);
1641 if (final_size == avio_rb24(s->pb) + 11) {
1642 uint32_t ts = avio_rb24(s->pb);
1643 ts |= (unsigned)avio_r8(s->pb) << 24;
1644 if (ts)
1645 s->duration = ts * (int64_t)AV_TIME_BASE / 1000;
1646 else if (fsize >= 8 && fsize - 8 >= final_size) {
1647 fsize -= final_size+4;
1648 goto retry_duration;
1649 }
1650 }
1651 }
1652
1653 avio_seek(s->pb, pos, SEEK_SET);
1654 flv->searched_for_end = 1;
1655 }
1656
1657 if (stream_type == FLV_STREAM_TYPE_AUDIO && !enhanced_flv) {
1658 int bits_per_coded_sample;
1660 sample_rate = 44100 << ((flags & FLV_AUDIO_SAMPLERATE_MASK) >>
1662 bits_per_coded_sample = (flags & FLV_AUDIO_SAMPLESIZE_MASK) ? 16 : 8;
1664 !st->codecpar->sample_rate ||
1668 st->codecpar->sample_rate = sample_rate;
1669 st->codecpar->bits_per_coded_sample = bits_per_coded_sample;
1670 }
1671 if (!st->codecpar->codec_id) {
1672 ret = flv_set_audio_codec(s, st, st->codecpar,
1674 if (ret < 0)
1675 goto leave;
1676 flv->last_sample_rate =
1677 sample_rate = st->codecpar->sample_rate;
1678 flv->last_channels =
1680 } else {
1682 if (!par) {
1683 ret = AVERROR(ENOMEM);
1684 goto leave;
1685 }
1686 par->sample_rate = sample_rate;
1687 par->bits_per_coded_sample = bits_per_coded_sample;
1689 if (ret < 0)
1690 goto leave;
1691 sample_rate = par->sample_rate;
1693 }
1694 } else if (stream_type == FLV_STREAM_TYPE_AUDIO) {
1695 if (!st->codecpar->codec_id) {
1696 ret = flv_set_audio_codec(s, st, st->codecpar,
1698 if (ret < 0)
1699 goto leave;
1700 }
1701
1702 // These are not signalled in the flags anymore
1703 channels = 0;
1704 sample_rate = 0;
1705
1706 if (pkt_type == AudioPacketTypeMultichannelConfig) {
1707 int channel_order = avio_r8(s->pb);
1708 channels = avio_r8(s->pb);
1709 size -= 2;
1710 track_size -= 2;
1711
1713
1714 if (channel_order == AudioChannelOrderCustom) {
1716 if (ret < 0)
1717 return ret;
1718
1719 for (i = 0; i < channels; i++) {
1720 uint8_t id = avio_r8(s->pb);
1721 size--;
1722 track_size--;
1723
1724 if (id < 18)
1725 st->codecpar->ch_layout.u.map[i].id = id;
1726 else if (id >= 18 && id <= 23)
1728 else if (id == 0xFE)
1730 else
1732 }
1733 } else if (channel_order == AudioChannelOrderNative) {
1734 uint64_t mask = avio_rb32(s->pb);
1735 size -= 4;
1736 track_size -= 4;
1737
1738 // The first 18 entries in the mask match ours, but the remaining 6 entries start at AV_CHAN_LOW_FREQUENCY_2
1739 mask = (mask & 0x3FFFF) | ((mask & 0xFC0000) << (AV_CHAN_LOW_FREQUENCY_2 - 18));
1741 if (ret < 0)
1742 return ret;
1743 } else {
1745 }
1746
1747 av_log(s, AV_LOG_DEBUG, "Set channel data from MultiChannel info.\n");
1748
1749 goto next_track;
1750 }
1751 } else if (stream_type == FLV_STREAM_TYPE_VIDEO) {
1752 int sret = flv_set_video_codec(s, st, codec_id, 1);
1753 if (sret < 0)
1754 return sret;
1755 size -= sret;
1756 track_size -= sret;
1757 } else if (stream_type == FLV_STREAM_TYPE_SUBTITLE) {
1759 } else if (stream_type == FLV_STREAM_TYPE_DATA) {
1760 st->codecpar->codec_id = AV_CODEC_ID_NONE; // Opaque AMF data
1761 }
1762
1763 if (st->codecpar->codec_id == AV_CODEC_ID_AAC ||
1772 int type = 0;
1773 if (enhanced_flv) {
1774 type = pkt_type;
1775 } else {
1776 type = avio_r8(s->pb);
1777 size--;
1778 track_size--;
1779 }
1780
1781 if (size < 0 || track_size < 0) {
1782 ret = AVERROR_INVALIDDATA;
1783 goto leave;
1784 }
1785
1786 if (enhanced_flv && stream_type == FLV_STREAM_TYPE_VIDEO &&
1788 flv_update_video_color_info(s, st); // update av packet side data
1790 }
1791
1792 if (st->codecpar->codec_id == AV_CODEC_ID_MPEG4 ||
1796 (!enhanced_flv || type == PacketTypeCodedFrames))) {
1797 if (size < 3 || track_size < 3) {
1798 ret = AVERROR_INVALIDDATA;
1799 goto leave;
1800 }
1801 // sign extension
1802 int32_t cts = (avio_rb24(s->pb) + 0xff800000) ^ 0xff800000;
1803 pts = av_sat_add64(dts, cts);
1804 if (cts < 0) { // dts might be wrong
1805 if (!flv->wrong_dts)
1807 "Negative cts, previous timestamps might be wrong.\n");
1808 flv->wrong_dts = 1;
1809 } else if (FFABS(dts - pts) > 1000*60*15) {
1811 "invalid timestamps %"PRId64" %"PRId64"\n", dts, pts);
1812 dts = pts = AV_NOPTS_VALUE;
1813 }
1814 size -= 3;
1815 track_size -= 3;
1816 }
1817 if (type == 0 && (!st->codecpar->extradata || st->codecpar->codec_id == AV_CODEC_ID_AAC ||
1823
1824 if (st->codecpar->extradata) {
1825 if ((ret = flv_queue_extradata(flv, s->pb, multitrack ? track_idx : stream_type, track_size, multitrack)) < 0)
1826 return ret;
1827 ret = FFERROR_REDO;
1828 goto leave;
1829 }
1830 if ((ret = flv_get_extradata(s, st, track_size)) < 0)
1831 return ret;
1832
1833 /* Workaround for buggy Omnia A/XE encoder */
1834 t = av_dict_get(s->metadata, "Encoder", NULL, 0);
1835 if (st->codecpar->codec_id == AV_CODEC_ID_AAC && t && !strcmp(t->value, "Omnia A/XE"))
1836 st->codecpar->extradata_size = 2;
1837
1838 ret = FFERROR_REDO;
1839 goto leave;
1840 }
1841 }
1842
1843 /* skip empty or broken data packets */
1844 if (size <= 0 || track_size < 0) {
1845 ret = FFERROR_REDO;
1846 goto leave;
1847 }
1848
1849 /* skip empty data track */
1850 if (!track_size)
1851 goto next_track;
1852
1853 ret = av_get_packet(s->pb, pkt, track_size);
1854 if (ret < 0)
1855 return ret;
1856
1857 track_size -= ret;
1858 size -= ret;
1859
1860 pkt->dts = dts;
1861 pkt->pts = pts == AV_NOPTS_VALUE ? dts : pts;
1862 pkt->stream_index = st->index;
1863 pkt->pos = pos;
1864 if (!multitrack && flv->new_extradata[stream_type]) {
1866 flv->new_extradata[stream_type],
1867 flv->new_extradata_size[stream_type]);
1868 if (ret < 0)
1869 return ret;
1870
1871 flv->new_extradata[stream_type] = NULL;
1872 flv->new_extradata_size[stream_type] = 0;
1873 } else if (multitrack &&
1874 flv->mt_extradata_cnt > track_idx &&
1875 flv->mt_extradata[track_idx]) {
1877 flv->mt_extradata[track_idx],
1878 flv->mt_extradata_sz[track_idx]);
1879 if (ret < 0)
1880 return ret;
1881
1882 flv->mt_extradata[track_idx] = NULL;
1883 flv->mt_extradata_sz[track_idx] = 0;
1884 }
1885 if (stream_type == FLV_STREAM_TYPE_AUDIO && !enhanced_flv &&
1886 (sample_rate != flv->last_sample_rate ||
1887 channels != flv->last_channels)) {
1888 flv->last_sample_rate = sample_rate;
1889 flv->last_channels = channels;
1890 ff_add_param_change(pkt, channels, 0, sample_rate, 0, 0);
1891 }
1892
1893 if (stream_type == FLV_STREAM_TYPE_AUDIO ||
1895 stream_type == FLV_STREAM_TYPE_SUBTITLE ||
1896 stream_type == FLV_STREAM_TYPE_DATA)
1897 pkt->flags |= AV_PKT_FLAG_KEY;
1898
1899 ret = ff_buffer_packet(s, pkt);
1900 if (ret < 0)
1901 return ret;
1902 res = FFERROR_REDO;
1903
1904next_track:
1905 if (track_size) {
1906 av_log(s, AV_LOG_WARNING, "Track size mismatch: %d!\n", track_size);
1907 if (!avio_feof(s->pb)) {
1908 if (track_size > 0) {
1909 avio_skip(s->pb, track_size);
1910 size -= track_size;
1911 } else {
1912 /* We have somehow read more than the track had to offer, leave and re-sync */
1913 ret = FFERROR_REDO;
1914 goto leave;
1915 }
1916 }
1917 }
1918
1919 if (!size)
1920 break;
1921
1922 if (multitrack_type == MultitrackTypeOneTrack) {
1923 av_log(s, AV_LOG_ERROR, "Attempted to read next track in single-track mode.\n");
1924 ret = FFERROR_REDO;
1925 goto leave;
1926 }
1927
1928 if (multitrack_type == MultitrackTypeManyTracksManyCodecs) {
1929 codec_id = avio_rb32(s->pb);
1930 size -= 4;
1931 }
1932
1933 track_idx = avio_r8(s->pb);
1934 size--;
1935
1936 if (avio_feof(s->pb)) {
1937 av_log(s, AV_LOG_WARNING, "Premature EOF\n");
1938 /* return REDO so that any potentially queued up packages can be drained first */
1939 return FFERROR_REDO;
1940 }
1941 }
1942
1943 ret = 0;
1944leave:
1945 last = avio_rb32(s->pb);
1946 if (!flv->trust_datasize) {
1947 if (last != orig_size + 11 && last != orig_size + 10 &&
1948 !avio_feof(s->pb) &&
1949 (last != orig_size || !last) && last != flv->sum_flv_tag_size &&
1950 !flv->broken_sizes) {
1951 av_log(s, AV_LOG_ERROR, "Packet mismatch %d %d %"PRId64"\n", last, orig_size + 11, flv->sum_flv_tag_size);
1952 avio_seek(s->pb, pos + 1, SEEK_SET);
1953 ret = resync(s);
1955 if (ret >= 0) {
1956 goto retry;
1957 }
1958 }
1959 }
1960
1961 if (ret >= 0)
1962 flv->last_ts = pkt->dts;
1963
1964 return ret ? ret : res;
1965}
1966
1967static int flv_read_seek(AVFormatContext *s, int stream_index,
1968 int64_t ts, int flags)
1969{
1970 FLVContext *flv = s->priv_data;
1971 flv->validate_count = 0;
1972 return avio_seek_time(s->pb, stream_index, ts, flags);
1973}
1974
1975#define OFFSET(x) offsetof(FLVContext, x)
1976#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
1977static const AVOption options[] = {
1978 { "flv_metadata", "Allocate streams according to the onMetaData array", OFFSET(trust_metadata), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VD },
1979 { "flv_full_metadata", "Dump full metadata of the onMetadata", OFFSET(dump_full_metadata), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VD },
1980 { "flv_ignore_prevtag", "Ignore the Size of previous tag", OFFSET(trust_datasize), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VD },
1981 { NULL }
1982};
1983
1984static const AVClass flv_kux_class = {
1985 .class_name = "(live) flv/kux demuxer",
1986 .item_name = av_default_item_name,
1987 .option = options,
1988 .version = LIBAVUTIL_VERSION_INT,
1989};
1990
1992 .p.name = "flv",
1993 .p.long_name = NULL_IF_CONFIG_SMALL("FLV (Flash Video)"),
1994 .p.extensions = "flv",
1995 .p.priv_class = &flv_kux_class,
1996 .priv_data_size = sizeof(FLVContext),
2002};
2003
2005 .p.name = "live_flv",
2006 .p.long_name = NULL_IF_CONFIG_SMALL("live RTMP FLV (Flash Video)"),
2007 .p.extensions = "flv",
2008 .p.priv_class = &flv_kux_class,
2009 .p.flags = AVFMT_TS_DISCONT,
2010 .priv_data_size = sizeof(FLVContext),
2016};
2017
2019 .p.name = "kux",
2020 .p.long_name = NULL_IF_CONFIG_SMALL("KUX (YouKu)"),
2021 .p.extensions = "kux",
2022 .p.priv_class = &flv_kux_class,
2023 .priv_data_size = sizeof(FLVContext),
2029};
const FFInputFormat ff_live_flv_demuxer
Definition flvdec.c:2004
const FFInputFormat ff_flv_demuxer
Definition flvdec.c:1991
const FFInputFormat ff_kux_demuxer
Definition flvdec.c:2018
#define VD
Definition amfdec.c:787
static FILE * out
static void finish(void)
channels
Definition aptx.h:31
int32_t
static int64_t fsize(FILE *f)
Definition audiomatch.c:29
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition avassert.h:42
void avpriv_set_pts_info(AVStream *st, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition avformat.c:834
Main libavformat public API header.
#define AVFMT_EVENT_FLAG_METADATA_UPDATED
Definition avformat.h:1727
#define AVINDEX_KEYFRAME
Definition avformat.h:628
#define AVPROBE_SCORE_MAX
maximum score
Definition avformat.h:483
#define AVFMT_FLAG_IGNIDX
Ignore index.
Definition avformat.h:1486
#define AVFMTCTX_NOHEADER
signal that no header is present (streams are added dynamically)
Definition avformat.h:1284
#define AVFMT_TS_DISCONT
Format allows timestamp discontinuities.
Definition avformat.h:500
#define AVPROBE_SCORE_EXTENSION
score for file extension
Definition avformat.h:481
int av_get_packet(AVIOContext *s, AVPacket *pkt, int size)
Allocate and read the payload of a packet and initialize its fields with default values.
Definition utils.c:98
@ AVSTREAM_PARSE_HEADERS
Only parse headers, do not repack.
Definition avformat.h:612
@ AVSTREAM_PARSE_FULL
full parsing and repack
Definition avformat.h:611
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition aviobuf.c:236
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
Definition avio.h:41
uint64_t avio_rb64(AVIOContext *s)
Definition aviobuf.c:911
int64_t avio_size(AVIOContext *s)
Get the filesize.
Definition aviobuf.c:326
unsigned int avio_rb16(AVIOContext *s)
Definition aviobuf.c:749
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Definition aviobuf.c:349
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition avio.h:494
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition aviobuf.c:321
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition aviobuf.c:615
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.
Definition aviobuf.c:1235
unsigned int avio_rb24(AVIOContext *s)
Definition aviobuf.c:757
unsigned int avio_rb32(AVIOContext *s)
Definition aviobuf.c:764
int avio_r8(AVIOContext *s)
Definition aviobuf.c:606
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
static void BS_FUNC skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
static uint32_t BS_FUNC read(BSCTX *bc, unsigned int n)
Return n bits from the buffer, n has to be in the 0-32 range.
static int FUNC metadata(CodedBitstreamContext *ctx, RWContext *rw, APVRawMetadata *current)
#define flags(name, subs,...)
Definition cbs_h264.c:74
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
static int read_probe(const AVProbeData *p)
Definition cdg.c:30
Public libavutil channel layout APIs header.
AVCodecParameters * avcodec_parameters_alloc(void)
Definition codec_par.c:57
void avcodec_parameters_free(AVCodecParameters **ppar)
Definition codec_par.c:67
#define av_sat_add64
Definition common.h:139
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition common.h:74
#define NULL
Definition coverity.c:32
long long int64_t
Definition coverity.c:34
int ff_buffer_packet(AVFormatContext *s, AVPacket *pkt)
Definition demux.c:622
int ff_add_param_change(AVPacket *pkt, int32_t channels, uint64_t channel_layout, int32_t sample_rate, int32_t width, int32_t height)
Add side data to a packet for changing parameters to the given values.
#define FFERROR_REDO
Returned by demuxers to indicate that data was consumed but discarded (ignored streams or junk data).
Definition demux.h:224
int ff_get_extradata(void *logctx, AVCodecParameters *par, AVIOContext *pb, int size)
Allocate extradata with additional AV_INPUT_BUFFER_PADDING_SIZE at end which is always set to 0 and f...
static AVPacket * pkt
Public dictionary API.
enum AVCodecID id
Definition dts2pts.c:607
const char * key
static int read_header(FFV1Context *f, RangeCoder *c)
Definition ffv1dec.c:578
FLV common header.
@ PacketTypeMultitrack
Definition flv.h:132
@ PacketTypeModEx
Definition flv.h:133
@ PacketTypeMetadata
Definition flv.h:130
@ PacketTypeCodedFrames
Definition flv.h:127
FlvTagType
Definition flv.h:65
@ FLV_TAG_TYPE_AUDIO
Definition flv.h:66
@ FLV_TAG_TYPE_META
Definition flv.h:68
@ FLV_TAG_TYPE_VIDEO
Definition flv.h:67
@ FLV_STEREO
Definition flv.h:81
@ FLV_CODECID_SCREEN2
Definition flv.h:116
@ FLV_CODECID_MPEG4
Definition flv.h:119
@ FLV_CODECID_VP6A
Definition flv.h:115
@ FLV_CODECID_X_HEVC
Definition flv.h:122
@ FLV_CODECID_SCREEN
Definition flv.h:113
@ FLV_CODECID_REALH263
Definition flv.h:118
@ FLV_CODECID_H263
Definition flv.h:112
@ FLV_CODECID_VP6
Definition flv.h:114
@ FLV_CODECID_H264
Definition flv.h:117
@ FLV_STREAM_TYPE_AUDIO
Definition flv.h:73
@ FLV_STREAM_TYPE_DATA
Definition flv.h:75
@ FLV_STREAM_TYPE_SUBTITLE
Definition flv.h:74
@ FLV_STREAM_TYPE_NB
Definition flv.h:76
@ FLV_STREAM_TYPE_VIDEO
Definition flv.h:72
#define FLV_VIDEO_FRAMETYPE_MASK
Definition flv.h:51
@ FLV_HEADER_FLAG_HASVIDEO
Definition flv.h:61
@ FLV_HEADER_FLAG_HASAUDIO
Definition flv.h:62
#define FLV_AUDIO_SAMPLERATE_OFFSET
Definition flv.h:33
#define KEYFRAMES_TIMESTAMP_TAG
Definition flv.h:56
AMFDataType
Definition flv.h:167
@ AMF_DATA_TYPE_OBJECT_END
Definition flv.h:176
@ AMF_DATA_TYPE_OBJECT
Definition flv.h:171
@ AMF_DATA_TYPE_BOOL
Definition flv.h:169
@ AMF_DATA_TYPE_NUMBER
Definition flv.h:168
@ AMF_DATA_TYPE_MIXEDARRAY
Definition flv.h:175
@ AMF_DATA_TYPE_UNSUPPORTED
Definition flv.h:180
@ AMF_DATA_TYPE_NULL
Definition flv.h:172
@ AMF_DATA_TYPE_STRING
Definition flv.h:170
@ AMF_DATA_TYPE_UNDEFINED
Definition flv.h:173
@ AMF_DATA_TYPE_ARRAY
Definition flv.h:177
@ AMF_DATA_TYPE_DATE
Definition flv.h:178
#define FLV_AUDIO_SAMPLESIZE_MASK
Definition flv.h:46
#define KEYFRAMES_TAG
Definition flv.h:55
#define FLV_AUDIO_CODECID_MASK
Definition flv.h:48
#define KEYFRAMES_BYTEOFFSET_TAG
Definition flv.h:57
#define AMF_END_OF_OBJECT
Definition flv.h:53
@ AudioChannelOrderNative
Definition flv.h:149
@ AudioChannelOrderCustom
Definition flv.h:150
@ FLV_CODECID_NELLYMOSER_16KHZ_MONO
Definition flv.h:101
@ FLV_CODECID_PCM
Definition flv.h:97
@ FLV_CODECID_EX_HEADER
Definition flv.h:106
@ FLV_CODECID_AAC
Definition flv.h:107
@ FLV_CODECID_MP3
Definition flv.h:99
@ FLV_CODECID_PCM_LE
Definition flv.h:100
@ FLV_CODECID_NELLYMOSER
Definition flv.h:103
@ FLV_CODECID_PCM_MULAW
Definition flv.h:105
@ FLV_CODECID_PCM_ALAW
Definition flv.h:104
@ FLV_CODECID_SPEEX
Definition flv.h:108
@ FLV_CODECID_ADPCM
Definition flv.h:98
@ FLV_CODECID_NELLYMOSER_8KHZ_MONO
Definition flv.h:102
#define FLV_AUDIO_CODECID_OFFSET
Definition flv.h:34
@ MultitrackTypeOneTrack
Definition flv.h:154
@ MultitrackTypeManyTracksManyCodecs
Definition flv.h:156
#define FLV_AUDIO_SAMPLERATE_MASK
Definition flv.h:47
@ FLV_FRAME_DISP_INTER
disposable inter frame (H.263 only)
Definition flv.h:162
@ FLV_FRAME_KEY
key frame (for AVC, a seekable frame)
Definition flv.h:160
@ FLV_FRAME_VIDEO_INFO_CMD
video info/command frame
Definition flv.h:164
#define FLV_VIDEO_CODECID_MASK
Definition flv.h:50
#define FLV_AUDIO_CHANNEL_MASK
Definition flv.h:45
@ PacketModExTypeTimestampOffsetNano
Definition flv.h:144
@ AudioPacketTypeMultichannelConfig
Definition flv.h:139
@ AudioPacketTypeMultitrack
Definition flv.h:140
static const int32_t max_pos[4]
Size of the MP-MLQ fixed excitation codebooks.
Definition g723_1dec.c:97
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition codec_id.h:47
@ AV_CODEC_ID_ADPCM_SWF
Definition codec_id.h:383
@ AV_CODEC_ID_FLV1
Definition codec_id.h:71
@ AV_CODEC_ID_VP6F
Definition codec_id.h:142
@ AV_CODEC_ID_EAC3
Definition codec_id.h:493
@ AV_CODEC_ID_PCM_U8
Definition codec_id.h:335
@ AV_CODEC_ID_PCM_S16LE
Definition codec_id.h:330
@ AV_CODEC_ID_TEXT
raw UTF-8 text
Definition codec_id.h:568
@ AV_CODEC_ID_H264
Definition codec_id.h:77
@ AV_CODEC_ID_NONE
Definition codec_id.h:48
@ AV_CODEC_ID_PCM_S16BE
Definition codec_id.h:331
@ AV_CODEC_ID_VVC
Definition codec_id.h:247
@ AV_CODEC_ID_AV1
Definition codec_id.h:275
@ AV_CODEC_ID_FLASHSV2
Definition codec_id.h:181
@ AV_CODEC_ID_PCM_ALAW
Definition codec_id.h:337
@ AV_CODEC_ID_VP6A
Definition codec_id.h:156
@ AV_CODEC_ID_HEVC
Definition codec_id.h:223
@ AV_CODEC_ID_AAC
Definition codec_id.h:455
@ AV_CODEC_ID_NELLYMOSER
Definition codec_id.h:486
@ AV_CODEC_ID_FLAC
Definition codec_id.h:465
@ AV_CODEC_ID_H263
Definition codec_id.h:54
@ AV_CODEC_ID_AC3
Definition codec_id.h:456
@ AV_CODEC_ID_MPEG4
Definition codec_id.h:62
@ AV_CODEC_ID_SPEEX
Definition codec_id.h:488
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
Definition codec_id.h:454
@ AV_CODEC_ID_VP9
Definition codec_id.h:217
@ AV_CODEC_ID_FLASHSV
Definition codec_id.h:136
@ AV_CODEC_ID_OPUS
Definition codec_id.h:513
@ AV_CODEC_ID_PCM_MULAW
Definition codec_id.h:336
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
Definition defs.h:40
@ AVDISCARD_ALL
discard all
Definition defs.h:232
@ AVDISCARD_NONKEY
discard all frames except keyframes
Definition defs.h:231
@ AVDISCARD_BIDIR
discard all bidirectional frames
Definition defs.h:229
AVPacketSideData * av_packet_side_data_add(AVPacketSideData **psd, int *pnb_sd, enum AVPacketSideDataType type, void *data, size_t size, int flags)
Wrap existing data as packet side data.
Definition packet.c:613
@ AV_PKT_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata (based on SMPTE-2086:2014).
Definition packet.h:219
@ 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...
Definition packet.h:56
@ AV_PKT_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
Definition packet.h:232
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition packet.c:434
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition packet.h:650
int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type, uint8_t *data, size_t size)
Wrap an existing array as a packet side data.
Definition packet.c:197
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
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.
Definition seek.c:122
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
int av_channel_layout_custom_init(AVChannelLayout *channel_layout, int nb_channels)
Initialize a custom channel layout with the specified number of channels.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask)
Initialize a native channel layout from a bitmask indicating which channels are present.
int av_channel_layout_check(const AVChannelLayout *channel_layout)
Check whether a channel layout is valid, i.e.
@ AV_CHAN_UNUSED
Channel is empty can be safely skipped.
@ AV_CHAN_LOW_FREQUENCY_2
@ AV_CHAN_UNKNOWN
Channel contains data, but its position is unknown.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
Definition dict.c:60
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition dict.c:86
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition error.h:64
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition error.h:52
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition error.h:61
#define AVERROR_EOF
End of file.
Definition error.h:57
#define AVERROR(e)
Definition error.h:45
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition log.h:236
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition log.h:231
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
#define AV_LOG_INFO
Standard information.
Definition log.h:221
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
AVRational av_d2q(double d, int max)
Convert a double precision floating point number to a rational.
Definition rational.c:110
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Definition mem.c:217
AVMediaType
Definition avutil.h:198
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201
@ AVMEDIA_TYPE_SUBTITLE
Definition avutil.h:203
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
Definition avutil.h:202
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.
Definition avstring.c:85
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition avutil.h:247
#define AV_TIME_BASE
Internal time base represented as integer.
Definition avutil.h:253
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
cl_device_type type
static av_always_inline double av_int2double(uint64_t i)
Reinterpret a 64-bit integer as a double.
Definition intfloat.h:60
#define AV_RB32(p)
#define AV_RB24(x)
unsigned offset
Definition libaomenc.c:763
static const int factor[16]
Definition vf_pp7.c:98
static int flv_read_metabody(AVFormatContext *s, int64_t next_pos)
Definition flvdec.c:860
static void add_keyframes_index(AVFormatContext *s)
Definition flvdec.c:168
static int flv_read_header(AVFormatContext *s)
Definition flvdec.c:917
static int flv_parse_video_color_info(AVFormatContext *s, AVStream *st, int64_t next_pos)
Definition flvdec.c:1209
static AVStream * create_stream(AVFormatContext *s, int codec_type, int track_idx)
Definition flvdec.c:199
static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition flvdec.c:1379
static const AVClass flv_kux_class
Definition flvdec.c:1984
#define RESYNC_BUFFER_SIZE
Definition flvdec.c:45
static int flv_update_video_color_info(AVFormatContext *s, AVStream *st)
Definition flvdec.c:1246
static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vstream, const char *key, int64_t max_pos, int depth)
Definition flvdec.c:618
FLVMetaColorInfoFlag
Definition flvdec.c:71
@ FLV_COLOR_INFO_FLAG_NONE
Definition flvdec.c:72
@ FLV_COLOR_INFO_FLAG_GOT
Definition flvdec.c:73
@ FLV_COLOR_INFO_FLAG_PARSING
Definition flvdec.c:74
static int flv_get_extradata(AVFormatContext *s, AVStream *st, int size)
Definition flvdec.c:971
#define MAX_DEPTH
arbitrary limit to prevent unbounded recursion
Definition flvdec.c:47
static int kux_probe(const AVProbeData *p)
Definition flvdec.c:154
#define TYPE_UNKNOWN
Definition flvdec.c:858
static int amf_get_string(AVIOContext *ioc, char *buffer, int buffsize)
Definition flvdec.c:503
#define TYPE_ONCAPTIONINFO
Definition flvdec.c:857
#define VALIDATE_INDEX_TS_THRESH
Definition flvdec.c:43
static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, int64_t max_pos)
Definition flvdec.c:523
#define TYPE_ONTEXTDATA
Definition flvdec.c:855
#define TYPE_ONCAPTION
Definition flvdec.c:856
static int flv_data_packet(AVFormatContext *s, AVPacket *pkt, int64_t dts, int64_t next)
Definition flvdec.c:1098
static int resync(AVFormatContext *s)
Definition flvdec.c:1167
static int flv_probe(const AVProbeData *p)
Definition flvdec.c:144
static int probe(const AVProbeData *p, int live)
Definition flvdec.c:125
static int flv_set_audio_codec(AVFormatContext *s, AVStream *astream, AVCodecParameters *apar, int flv_codecid)
Definition flvdec.c:305
static int live_flv_probe(const AVProbeData *p)
Definition flvdec.c:149
static int flv_same_video_codec(AVCodecParameters *vpar, uint32_t flv_codecid)
Definition flvdec.c:394
#define OFFSET(x)
Definition flvdec.c:1975
static int flv_same_audio_codec(AVCodecParameters *apar, int flags, uint32_t codec_fourcc)
Definition flvdec.c:233
static void clear_index_entries(AVFormatContext *s, int64_t pos)
Definition flvdec.c:1032
static int flv_queue_extradata(FLVContext *flv, AVIOContext *pb, int stream, int size, int multitrack)
Definition flvdec.c:983
static int flv_read_close(AVFormatContext *s)
Definition flvdec.c:956
static int amf_skip_tag(AVIOContext *pb, AMFDataType type, int depth)
Definition flvdec.c:1047
static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, uint32_t flv_codecid, int read)
Definition flvdec.c:427
static int flv_parse_mod_ex_data(AVFormatContext *s, int *pkt_type, int *size, int64_t *dts)
Definition flvdec.c:1323
static int flv_read_seek(AVFormatContext *s, int stream_index, int64_t ts, int flags)
Definition flvdec.c:1967
int ff_dict_set_timestamp(AVDictionary **dict, const char *key, int64_t timestamp)
Set a dictionary value to an ISO-8601 compliant timestamp string.
Definition utils.c:617
static av_always_inline FFStream * ffstream(AVStream *st)
Definition internal.h:365
int ff_alloc_extradata(AVCodecParameters *par, int size)
Allocate extradata with additional AV_INPUT_BUFFER_PADDING_SIZE at end which is always set to 0.
Definition utils.c:237
static av_always_inline FFFormatContext * ffformatcontext(AVFormatContext *s)
Definition internal.h:130
Macro definitions for various function/variable attributes.
#define av_fallthrough
Definition attributes.h:67
#define av_unused
Definition attributes.h:164
#define av_uninit(x)
Definition attributes.h:187
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static av_cold int read_close(AVFormatContext *ctx)
Definition libcdio.c:143
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition libcdio.c:151
version
Definition libkvazaar.c:313
#define isfinite(x)
Definition libm.h:361
#define isnan(x)
Definition libm.h:342
static const uint16_t mask[17]
Definition lzw.c:38
#define FFMIN(a, b)
Definition macros.h:49
#define MKBETAG(a, b, c, d)
Definition macros.h:56
AVContentLightMetadata * av_content_light_metadata_alloc(size_t *size)
Allocate an AVContentLightMetadata structure and set its fields to default values.
AVMasteringDisplayMetadata * av_mastering_display_metadata_alloc_size(size_t *size)
Allocate an AVMasteringDisplayMetadata structure and set its fields to default values.
Memory handling functions.
#define av_malloc(s)
Definition ops_static.c:52
AVOptions.
AVColorPrimaries
Chromaticity coordinates of the source primaries.
Definition pixfmt.h:642
@ AVCOL_PRI_RESERVED
Definition pixfmt.h:646
@ AVCOL_PRI_RESERVED0
Definition pixfmt.h:643
AVColorTransferCharacteristic
Color Transfer Characteristic.
Definition pixfmt.h:672
@ AVCOL_TRC_RESERVED
Definition pixfmt.h:676
@ AVCOL_TRC_RESERVED0
Definition pixfmt.h:673
AVColorSpace
YUV colorspace type.
Definition pixfmt.h:706
@ AVCOL_SPC_RESERVED
reserved for future use by ITU-T and ISO/IEC just like 15-255 are
Definition pixfmt.h:710
enum AVMediaType codec_type
Definition rtp.c:37
#define snprintf
Definition snprintf.h:34
unsigned int pos
Definition spdifenc.c:431
enum AVChannel id
union AVChannelLayout::@162063043056170047076125117143030261346263330336 u
Details about which channels are present in this layout.
int nb_channels
Number of channels in this layout.
AVChannelCustom * map
This member must be used when the channel order is AV_CHANNEL_ORDER_CUSTOM.
Describe the class of an AVClass context structure.
Definition log.h:76
This struct describes the properties of an encoded stream.
Definition codec_par.h:49
enum AVColorSpace color_space
Definition codec_par.h:192
int extradata_size
Size of the extradata content in bytes.
Definition codec_par.h:75
int height
The height of the video frame in pixels.
Definition codec_par.h:150
int nb_coded_side_data
Amount of entries in coded_side_data.
Definition codec_par.h:88
int bits_per_coded_sample
The number of bits per sample in the codedwords.
Definition codec_par.h:113
AVChannelLayout ch_layout
The channel layout and number of channels.
Definition codec_par.h:207
int width
The width of the video frame in pixels.
Definition codec_par.h:143
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
Definition codec_par.h:99
enum AVMediaType codec_type
General type of the encoded data.
Definition codec_par.h:53
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
Definition codec_par.h:61
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition codec_par.h:71
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition codec_par.h:57
enum AVColorPrimaries color_primaries
Definition codec_par.h:190
int sample_rate
The number of audio samples per second.
Definition codec_par.h:213
enum AVColorTransferCharacteristic color_trc
Definition codec_par.h:191
AVPacketSideData * coded_side_data
Additional data associated with the entire stream.
Definition codec_par.h:83
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
char * value
Definition dict.h:92
Format I/O context.
Definition avformat.h:1333
Bytestream IO Context.
Definition avio.h:160
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
Definition avio.h:261
int eof_reached
true if was unable to read due to error or eof
Definition avio.h:238
int64_t pos
Definition avformat.h:621
Mastering display metadata capable of representing the color volume of the display used to master the...
AVOption.
Definition opt.h:428
This structure stores auxiliary information for decoding, presenting, or otherwise processing the cod...
Definition packet.h:424
This structure stores compressed data.
Definition packet.h:580
This structure contains the data a format has to probe a file.
Definition avformat.h:471
Rational number (pair of numerator and denominator).
Definition rational.h:58
Stream structure.
Definition avformat.h:766
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition avformat.h:789
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
Definition avformat.h:837
int id
Format-specific stream ID.
Definition avformat.h:778
int index
stream index in AVFormatContext
Definition avformat.h:772
AVRational avg_frame_rate
Average framerate.
Definition avformat.h:855
int nb_index_entries
Definition internal.h:193
int need_context_update
Whether the internal avctx needs to be updated from codecpar (after a late change to codecpar)
Definition internal.h:180
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
Definition internal.h:191
enum AVStreamParseType need_parsing
Definition internal.h:321
uint8_t resync_buffer[2 *RESYNC_BUFFER_SIZE]
Definition flvdec.c:95
FLVMetaVideoColor meta_color_info
Definition flvdec.c:111
int wrong_dts
wrong dts due to negative cts
Definition flvdec.c:82
int new_extradata_size[FLV_STREAM_TYPE_NB]
Definition flvdec.c:84
uint8_t ** mt_extradata
Definition flvdec.c:114
int trust_datasize
trust data size of FLVTag
Definition flvdec.c:80
int broken_sizes
Definition flvdec.c:97
int64_t sum_flv_tag_size
Definition flvdec.c:98
int last_keyframe_stream_index
Definition flvdec.c:100
int * mt_extradata_sz
Definition flvdec.c:115
uint8_t * new_extradata[FLV_STREAM_TYPE_NB]
Definition flvdec.c:83
AVRational framerate
Definition flvdec.c:106
int searched_for_end
Definition flvdec.c:93
int keyframe_count
Definition flvdec.c:101
enum FLVMetaColorInfoFlag meta_color_info_flag
Definition flvdec.c:112
int64_t * keyframe_filepositions
Definition flvdec.c:105
int64_t pos
Definition flvdec.c:89
int64_t last_ts
Definition flvdec.c:107
int validate_next
Definition flvdec.c:91
int validate_count
Definition flvdec.c:92
int dump_full_metadata
Dump full metadata of the onMetadata.
Definition flvdec.c:81
int last_channels
Definition flvdec.c:86
int trust_metadata
configure streams according onMetaData
Definition flvdec.c:79
int64_t * keyframe_times
Definition flvdec.c:104
int64_t time_pos
Definition flvdec.c:109
int64_t time_offset
Definition flvdec.c:108
int64_t video_bit_rate
Definition flvdec.c:102
int64_t audio_bit_rate
Definition flvdec.c:103
int64_t dts
Definition flvdec.c:88
int mt_extradata_cnt
Definition flvdec.c:116
int last_sample_rate
Definition flvdec.c:85
struct FLVContext::@173004043364206277106171202240343110252007345313 validate_index[2]
float white_y
Definition flvdec.c:57
float min_luminance
Definition flvdec.c:59
float white_x
Definition flvdec.c:56
float max_luminance
Definition flvdec.c:58
FLVMasteringMeta mastering_meta
Definition flvdec.c:68
uint16_t max_cll
Definition flvdec.c:66
enum AVColorPrimaries primaries
Definition flvdec.c:65
enum AVColorSpace matrix_coefficients
Definition flvdec.c:63
enum AVColorTransferCharacteristic trc
Definition flvdec.c:64
uint16_t max_fall
Definition flvdec.c:67
int16_t timezone
Definition flvdec.c:122
double milliseconds
Definition flvdec.c:121
#define av_free(p)
#define av_mallocz(s)
#define avpriv_request_sample(...)
#define av_freep(p)
#define av_log(a,...)
static uint8_t tmp[40]
Definition aes_ctr.c:52
static int array[MAX_W *MAX_W]
static char buffer[20]
Definition seek.c:32
static int64_t pts
int size
enum AVCodecID codec_id