155 "FLV only supports wideband (16kHz) Speex audio\n");
193 "FLV does not support sample rate %d, "
194 "choose from (44100, 22050, 11025)\n", par->
sample_rate);
246 size_t len = strlen(str);
257 avio_w8(pb, (ts >> 24) & 0x7F);
303 int metadata_count = 0;
326 if (write_duration_filesize) {
331 if (write_duration_filesize) {
382 if( !strcmp(
tag->key,
"width")
383 ||!strcmp(
tag->key,
"height")
384 ||!strcmp(
tag->key,
"videodatarate")
385 ||!strcmp(
tag->key,
"framerate")
386 ||!strcmp(
tag->key,
"videocodecid")
387 ||!strcmp(
tag->key,
"audiodatarate")
388 ||!strcmp(
tag->key,
"audiosamplerate")
389 ||!strcmp(
tag->key,
"audiosamplesize")
390 ||!strcmp(
tag->key,
"stereo")
391 ||!strcmp(
tag->key,
"audiocodecid")
392 ||!strcmp(
tag->key,
"duration")
393 ||!strcmp(
tag->key,
"onMetaData")
394 ||!strcmp(
tag->key,
"datasize")
395 ||!strcmp(
tag->key,
"lasttimestamp")
396 ||!strcmp(
tag->key,
"totalframes")
397 ||!strcmp(
tag->key,
"hasAudio")
398 ||!strcmp(
tag->key,
"hasVideo")
399 ||!strcmp(
tag->key,
"hasCuePoints")
400 ||!strcmp(
tag->key,
"hasMetadata")
401 ||!strcmp(
tag->key,
"hasKeyframes")
412 if (write_duration_filesize) {
490 avio_seek(pb, metadata_count_pos, SEEK_SET);
666 total_size =
avio_tell(pb) - metadata_size_pos - 10;
667 avio_seek(pb, metadata_size_pos, SEEK_SET);
680 "%s codec %s not compatible with flv\n",
693 int samplerate_index;
698 for (samplerate_index = 0; samplerate_index < 16;
706 put_bits(&pbc, 4, samplerate_index);
812 int extended_flv = 0;
904 avio_seek(pb, -data_size - 10, SEEK_CUR);
950 metadata_size += 2 + 13;
951 metadata_size += 2 + 5;
956 if (metadata_size < 0)
957 return metadata_size;
975 int video_ctr = 0, audio_ctr = 0;
984 for (
i = 0;
i <
s->nb_streams;
i++) {
999 if (
s->streams[
i]->avg_frame_rate.den &&
1000 s->streams[
i]->avg_frame_rate.num) {
1006 "at most one video stream is supported in flv with keyframe index\n");
1010 "more than one video stream is not supported by most flv demuxers.\n");
1025 "use vstrict=-1 / -strict -1 to use it anyway.\n");
1030 "Muxing VP6 in flv will produce flipped video on playback.\n");
1047 "more than one audio stream is not supported by most flv demuxers.\n");
1054 "16-bit big-endian audio in flv is valid but most likely unplayable (hardware dependent); use s16le\n");
1096 for (
i = 0;
i <
s->nb_streams;
i++)
1097 if (
s->streams[
i]->codecpar->codec_tag == 5) {
1112 for (
i = 0;
i <
s->nb_streams;
i++) {
1129 if (build_keyframes_idx) {
1176 for (
i = 0;
i <
s->nb_streams;
i++) {
1186 if (build_keyframes_idx) {
1219 int flags = -1, flags_size, ret = 0;
1261 memcpy(par->
extradata, side, side_size);
1272 "Packets are not in the proper order with respect to DTS\n");
1330 if (!
s->streams[
pkt->stream_index]->nb_frames) {
1332 "use the audio bitstream filter 'aac_adtstoasc' to fix it "
1333 "('-bsf:a aac_adtstoasc' option with ffmpeg)\n");
1342 "8 frames per packet. Adobe Flash "
1343 "Player cannot handle this!\n");
1348 if (
size + flags_size >= 1<<24) {
1350 size + flags_size, 1<<24);
1382 data_size =
avio_tell(pb) - metadata_size_pos;
1383 avio_seek(pb, metadata_size_pos - 10, SEEK_SET);
1385 avio_seek(pb, data_size + 10 - 3, SEEK_CUR);
1394 if (extended_video) {
1400 if (h26456 &&
pkt->pts ==
pkt->dts)
1416 }
else if (extended_audio) {
1426 }
else if (track_idx) {
1492 if (
pkt->size > 2 && (
AV_RB16(
pkt->data) & 0xfff0) == 0xfff0)
1524 {
"flvflags",
"FLV muxer flags", offsetof(
FLVContext,
flags),
AV_OPT_TYPE_FLAGS, {.i64 = 0}, INT_MIN, INT_MAX,
AV_OPT_FLAG_ENCODING_PARAM, .unit =
"flvflags" },
1534 .class_name =
"flv muxer",
1543 .p.mime_type =
"video/x-flv",
1544 .p.extensions =
"flv",
1554 .p.codec_tag = (
const AVCodecTag*
const []) {
int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size, int write_seq_header)
Writes AV1 extradata (Sequence Header and Metadata OBUs) to the provided AVIOContext.
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_isom_write_avcc(AVIOContext *pb, const uint8_t *data, int len)
void avio_write_marker(AVIOContext *s, int64_t time, enum AVIODataMarkerType type)
Mark the written bytestream as a specific type.
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
void avio_w8(AVIOContext *s, int b)
void avio_wb32(AVIOContext *s, unsigned int val)
void avio_wb16(AVIOContext *s, unsigned int val)
@ AVIO_DATA_MARKER_BOUNDARY_POINT
A point in the output bytestream where a demuxer can start parsing (for non self synchronizing bytest...
@ AVIO_DATA_MARKER_SYNC_POINT
A point in the output bytestream where a decoder can start decoding (i.e.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
void avio_wb24(AVIOContext *s, unsigned int val)
void avio_wb64(AVIOContext *s, uint64_t val)
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
#define FF_COMPLIANCE_UNOFFICIAL
Allow unofficial extensions.
@ PacketTypeSequenceStart
@ FLV_HEADER_FLAG_HASVIDEO
@ FLV_HEADER_FLAG_HASAUDIO
@ AMF_DATA_TYPE_MIXEDARRAY
#define AMF_END_OF_OBJECT
@ AudioChannelOrderNative
@ AudioChannelOrderCustom
@ AudioChannelOrderUnspecified
@ FLV_CODECID_NELLYMOSER_16KHZ_MONO
@ FLV_CODECID_NELLYMOSER_8KHZ_MONO
@ FLV_SAMPLERATE_SPECIAL
signifies 5512Hz and 8000Hz in the case of NELLYMOSER
#define FLV_AUDIO_CODECID_OFFSET
@ FLV_FRAME_INTER
inter frame (for AVC, a non-seekable frame)
@ FLV_FRAME_KEY
key frame (for AVC, a seekable frame)
@ FLV_FRAME_VIDEO_INFO_CMD
video info/command frame
@ AudioPacketTypeMultichannelConfig
@ AudioPacketTypeSequenceStart
@ AudioPacketTypeMultitrack
@ AudioPacketTypeCodedFrames
#define AV_OPT_FLAG_ENCODING_PARAM
A generic parameter which can be set by the user for muxing or encoding.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
AVCodecID
Identify the syntax and semantics of the bitstream.
@ AV_CODEC_ID_TEXT
raw UTF-8 text
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
const AVPacketSideData * av_packet_side_data_get(const AVPacketSideData *sd, int nb_sd, enum AVPacketSideDataType type)
Get side information from a side data array.
@ AV_PKT_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata (based on SMPTE-2086:2014).
@ 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...
@ AV_PKT_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size)
Get side information from packet.
#define AV_CHANNEL_LAYOUT_STEREO
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1)
Check whether two channel layouts are semantically the same, i.e.
#define AV_CHANNEL_LAYOUT_MONO
@ AV_CHANNEL_ORDER_NATIVE
The native channel order, i.e.
@ AV_CHANNEL_ORDER_CUSTOM
The channel order does not correspond to any other predefined order and is stored as an explicit map.
@ AV_CHAN_UNUSED
Channel is empty can be safely skipped.
@ AV_CHAN_LOW_FREQUENCY_2
@ AV_CHAN_BOTTOM_FRONT_RIGHT
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
const char * av_get_media_type_string(enum AVMediaType media_type)
Return a string describing the media_type enum, NULL if media_type is unknown.
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define AV_TIME_BASE
Internal time base represented as integer.
#define LIBAVUTIL_VERSION_INT
int ff_hevc_annexb2mp4_buf(const uint8_t *buf_in, uint8_t **buf_out, int *size, int filter_ps, int *ps_count)
Writes Annex B formatted HEVC NAL units to a data buffer.
int ff_isom_write_hvcc(AVIOContext *pb, const uint8_t *data, int size, int ps_array_completeness, void *logctx)
Writes HEVC extradata (parameter sets and declarative SEI NAL units with nuh_layer_id == 0,...
static av_always_inline uint64_t av_double2int(double f)
Reinterpret a double as a 64-bit integer.
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Macro definitions for various function/variable attributes.
#define av_builtin_constant_p
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static const uint16_t mask[17]
#define MKBETAG(a, b, c, d)
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
const int ff_mpeg4audio_sample_rates[16]
int ff_format_shift_data(AVFormatContext *s, int64_t read_start, int shift_size)
Make shift_size amount of space at read_start by shifting data in the output at read_start until the ...
int ff_standardize_creation_time(AVFormatContext *s)
Standardize creation_time metadata in AVFormatContext to an ISO-8601 timestamp string.
int ff_nal_parse_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size)
@ AVCOL_PRI_NB
Not part of ABI.
@ AVCOL_TRC_NB
Not part of ABI.
@ AVCOL_SPC_NB
Not part of ABI.
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
An AVChannelLayout holds information about the channel layout of audio data.
enum AVChannelOrder order
Channel order used in this layout.
uint64_t mask
This member must be used for AV_CHANNEL_ORDER_NATIVE, and may be used for AV_CHANNEL_ORDER_AMBISONIC ...
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.
This struct describes the properties of a single codec described by an AVCodecID.
This struct describes the properties of an encoded stream.
enum AVColorSpace color_space
int extradata_size
Size of the extradata content in bytes.
int height
The height of the video frame in pixels.
int nb_coded_side_data
Amount of entries in coded_side_data.
int bits_per_coded_sample
The number of bits per sample in the codedwords.
AVChannelLayout ch_layout
The channel layout and number of channels.
int width
The width of the video frame in pixels.
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
enum AVMediaType codec_type
General type of the encoded data.
int profile
Codec-specific bitstream restrictions that the stream conforms to.
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
enum AVColorPrimaries color_primaries
int sample_rate
The number of audio samples per second.
enum AVColorTransferCharacteristic color_trc
AVPacketSideData * coded_side_data
Additional data associated with the entire stream.
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
unsigned MaxFALL
Max average light level per frame (cd/m^2).
unsigned MaxCLL
Max content light level (cd/m^2).
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
This structure stores auxiliary information for decoding, presenting, or otherwise processing the cod...
This structure stores compressed data.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int64_t lastkeyframelocation
int64_t filepositions_count
AVCodecParameters * data_par
int64_t keyframes_info_offset
int64_t metadata_totalsize
int64_t lastkeyframetimestamp_offset
int64_t metadata_totalsize_pos
int64_t delay
first dts delay (needed for AVC & Speex)
AVCodecParameters * video_par
FLVFileposition * filepositions
int64_t metadata_size_pos
int64_t lastkeyframelocation_offset
AVCodecParameters * audio_par
FLVFileposition * head_filepositions
double lastkeyframetimestamp
int * metadata_pkt_written
int64_t keyframe_index_size
int64_t lasttimestamp_offset
struct FLVFileposition * next
double keyframe_timestamp
int64_t keyframe_position
static void error(const char *err)
int ff_isom_write_vpcc(void *logctx, AVIOContext *pb, const uint8_t *data, int len, const AVCodecParameters *par)
Writes VP codec configuration to the provided AVIOContext.
internal header for VPx codec configuration utilities.
int ff_vvc_annexb2mp4_buf(const uint8_t *buf_in, uint8_t **buf_out, int *size, int filter_ps, int *ps_count)
Writes Annex B formatted H.266/VVC NAL units to a data buffer.
int ff_isom_write_vvcc(AVIOContext *pb, const uint8_t *data, int size, int ps_array_completeness)
Writes H.266/VVC extradata (parameter sets, declarative SEI NAL units) to the provided AVIOContext.