35 #include "libavutil/avstring.h"
36 #include "libavutil/intfloat.h"
37 #include "libavutil/mathematics.h"
38 #include "libavutil/opt.h"
39 #include "libavutil/dict.h"
47 {
"movflags",
"MOV muxer flags", offsetof(
MOVMuxContext,
flags),
AV_OPT_TYPE_FLAGS, {.i64 = 0}, INT_MIN, INT_MAX,
AV_OPT_FLAG_ENCODING_PARAM,
"movflags" },
49 {
"moov_size",
"maximum moov size so it can be placed at the begin", offsetof(
MOVMuxContext, reserved_moov_size),
AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX,
AV_OPT_FLAG_ENCODING_PARAM, 0 },
70 #define MOV_CLASS(flavor)\
71 static const AVClass flavor ## _muxer_class = {\
72 .class_name = #flavor " muxer",\
73 .item_name = av_default_item_name,\
75 .version = LIBAVUTIL_VERSION_INT,\
117 for (i = 0; i < track->
entry; i++) {
132 int i, j, entries = 0, tst = -1, oldtst = -1;
139 for (i = 0; i < track->
entry; i++) {
141 if (oldtst != -1 && tst != oldtst)
146 if (equalChunks && track->
entry) {
148 sSize =
FFMAX(1, sSize);
154 for (i = 0; i < track->
entry; i++) {
167 int index = 0, oldval = -1, i;
168 int64_t entryPos, curpos;
176 for (i = 0; i < track->
entry; i++) {
196 int64_t curpos, entryPos;
204 for (i = 0; i < track->
entry; i++) {
236 int fscod, bsid, bsmod, acmod, lfeon, frmsizecod;
253 if ((acmod & 1) && acmod != 1)
306 avio_w8(pb, (size >> (7 * i)) | 0x80);
316 for (i = 0; i < track->
entry; i++)
324 int decoder_specific_info_len = track->
vos_len ? 5 + track->
vos_len : 0;
325 unsigned avg_bitrate;
332 put_descr(pb, 0x03, 3 + 5+13 + decoder_specific_info_len + 5+1);
337 put_descr(pb, 0x04, 13 + decoder_specific_info_len);
410 uint32_t layout_tag, bitmap;
418 "lack of channel information\n");
478 int unescaped_size, seq_found = 0;
479 int level = 0, interlace = 0;
489 packet_seq = packet_entry = 1;
496 for (next = start; next <
end; start = next) {
500 size = next - start - 4;
607 if (cluster_idx >= track->
entry)
610 if (cluster_idx + 1 == track->
entry)
613 next_dts = track->
cluster[cluster_idx + 1].
dts;
615 return next_dts - track->
cluster[cluster_idx].
dts;
620 int i, first_duration;
632 for (i = 1; i < track->
entry; i++) {
636 return first_duration;
643 uint32_t
tag = track->
tag;
727 else if (track->
tag ==
MKTAG(
'm',
'p',
'4',
'a'))
808 for (i = 0; i < 10; i++)
851 (tag ==
MKTAG(
't',
'x',
'3',
'g') ||
852 tag ==
MKTAG(
't',
'e',
'x',
't'))))
857 "Quicktime/Ipod might not play the file\n");
869 else tag =
MKTAG(
'd',
'v',
'c',
' ');
872 else tag =
MKTAG(
'd',
'v',
'p',
'p');
875 else tag =
MKTAG(
'd',
'v',
'h',
'p');
878 else tag =
MKTAG(
'd',
'v',
'h',
'6');
902 int tag =
MKTAG(
'm',
'2',
'v',
'1');
910 if (rate == 24) tag =
MKTAG(
'x',
'd',
'v',
'4');
911 else if (rate == 25) tag =
MKTAG(
'x',
'd',
'v',
'5');
912 else if (rate == 30) tag =
MKTAG(
'x',
'd',
'v',
'1');
913 else if (rate == 50) tag =
MKTAG(
'x',
'd',
'v',
'a');
914 else if (rate == 60) tag =
MKTAG(
'x',
'd',
'v',
'9');
918 if (rate == 24) tag =
MKTAG(
'x',
'd',
'v',
'6');
919 else if (rate == 25) tag =
MKTAG(
'x',
'd',
'v',
'7');
920 else if (rate == 30) tag =
MKTAG(
'x',
'd',
'v',
'8');
922 if (rate == 25) tag =
MKTAG(
'x',
'd',
'v',
'3');
923 else if (rate == 30) tag =
MKTAG(
'x',
'd',
'v',
'2');
927 if (rate == 24) tag =
MKTAG(
'x',
'd',
'v',
'd');
928 else if (rate == 25) tag =
MKTAG(
'x',
'd',
'v',
'e');
929 else if (rate == 30) tag =
MKTAG(
'x',
'd',
'v',
'f');
931 if (rate == 25) tag =
MKTAG(
'x',
'd',
'v',
'c');
932 else if (rate == 30) tag =
MKTAG(
'x',
'd',
'v',
'b');
938 if (rate == 24) tag =
MKTAG(
'x',
'd',
'5',
'4');
939 else if (rate == 25) tag =
MKTAG(
'x',
'd',
'5',
'5');
940 else if (rate == 30) tag =
MKTAG(
'x',
'd',
'5',
'1');
941 else if (rate == 50) tag =
MKTAG(
'x',
'd',
'5',
'a');
942 else if (rate == 60) tag =
MKTAG(
'x',
'd',
'5',
'9');
946 if (rate == 24) tag =
MKTAG(
'x',
'd',
'5',
'd');
947 else if (rate == 25) tag =
MKTAG(
'x',
'd',
'5',
'e');
948 else if (rate == 30) tag =
MKTAG(
'x',
'd',
'5',
'f');
950 if (rate == 25) tag =
MKTAG(
'x',
'd',
'5',
'c');
951 else if (rate == 30) tag =
MKTAG(
'x',
'd',
'5',
'b');
959 static const struct {
1020 "the file may be unplayable!\n");
1027 tag =
MKTAG(
'm',
's', ((ms_tag >> 8) & 0xff), (ms_tag & 0xff));
1029 "the file may be unplayable!\n");
1068 tag =
MKTAG(
'w',
'm',
'a',
' ');
1098 0x0000, 0x0100, 0x0201, 0x0206, 0x0209, 0x020e
1103 unsigned mov_field_order = 0;
1157 }
else if(track->
enc->
width == 1440) {
1164 av_strlcatf(compressor_name, len,
"%d", rate * (interlaced + 1));
1171 char compressor_name[32] = { 0 };
1204 avio_w8(pb, strlen(compressor_name));
1212 if (track->
tag ==
MKTAG(
'm',
'p',
'4',
'v'))
1232 }
else if (track->
vos_len > 0)
1276 if (nb_frames > 255) {
1327 uint32_t entries = 0;
1331 ctts_entries =
av_malloc((track->
entry + 1) *
sizeof(*ctts_entries));
1332 ctts_entries[0].
count = 1;
1334 for (i = 1; i < track->
entry; i++) {
1336 ctts_entries[entries].
count++;
1340 ctts_entries[entries].
count = 1;
1344 atom_size = 16 + (entries * 8);
1349 for (i = 0; i < entries; i++) {
1361 uint32_t entries = -1;
1366 stts_entries =
av_malloc(
sizeof(*stts_entries));
1371 stts_entries = track->
entry ?
1374 for (i = 0; i < track->
entry; i++) {
1376 if (i && duration == stts_entries[entries].duration) {
1377 stts_entries[entries].
count++;
1381 stts_entries[entries].
count = 1;
1386 atom_size = 16 + (entries * 8);
1391 for (i = 0; i < entries; i++) {
1456 const char *font =
"Lucida Grande";
1496 if (track->
tag !=
MKTAG(
'c',
'6',
'0',
'8')) {
1542 const char *hdlr, *descr = NULL, *hdlr_type = NULL;
1547 descr =
"DataHandler";
1550 hdlr = (track->
mode ==
MODE_MOV) ?
"mhlr" :
"\0\0\0\0";
1553 descr =
"VideoHandler";
1556 descr =
"SoundHandler";
1558 if (track->
tag ==
MKTAG(
'c',
'6',
'0',
'8')) {
1560 descr =
"ClosedCaptionHandler";
1562 if (track->
tag ==
MKTAG(
't',
'x',
'3',
'g')) hdlr_type =
"sbtl";
1563 else hdlr_type =
"text";
1564 descr =
"SubtitleHandler";
1568 descr =
"HintHandler";
1571 descr =
"TimeCodeHandler";
1578 "Unknown hldr_type for %s / 0x%04X, writing dummy values\n",
1624 if (track->
tag ==
MKTAG(
't',
'e',
'x',
't') || track->
tag ==
MKTAG(
'c',
'6',
'0',
'8')) {
1629 }
else if (track->
tag ==
MKTAG(
'r',
't',
'p',
' ')) {
1631 }
else if (track->
tag ==
MKTAG(
't',
'm',
'c',
'd')) {
1661 (version == 1) ?
avio_wb64(pb, UINT64_C(0xffffffffffffffff)) :
avio_wb32(pb, 0xffffffff);
1669 "FATAL error, file duration too long for timebase, this file will not be\n"
1670 "playable with quicktime. Choose a different timebase or a different\n"
1671 "container format\n");
1693 int16_t d, int16_t tx, int16_t ty)
1710 int version = duration < INT32_MAX ? 0 : 1;
1732 (version == 1) ?
avio_wb64(pb, UINT64_C(0xffffffffffffffff)) :
avio_wb32(pb, 0xffffffff);
1750 rotation = (rot && rot->
value) ? atoi(rot->
value) : 0;
1752 if (rotation == 90) {
1754 }
else if (rotation == 180) {
1756 }
else if (rotation == 270) {
1770 sample_aspect_ratio = 1;
1817 int version = duration < INT32_MAX ? 0 : 1;
1818 int entry_size, entry_count,
size;
1819 int64_t delay, start_ct = track->
cluster[0].
cts;
1822 version |= delay < INT32_MAX ? 0 : 1;
1824 entry_size = (version == 1) ? 20 : 12;
1825 entry_count = 1 + (delay > 0);
1826 size = 24 + entry_count * entry_size;
1896 char buf[1000] =
"";
1900 NULL, NULL, 0, 0, ctx);
1928 if (track->
tag ==
MKTAG(
'r',
't',
'p',
' '))
1940 int i, has_audio = 0, has_video = 0;
1950 if (audio_profile < 0)
1951 audio_profile = 0xFF - has_audio;
1952 if (video_profile < 0)
1953 video_profile = 0xFF - has_video;
1993 int max_track_id = 1, i;
1994 int64_t max_track_len_temp, max_track_len = 0;
2003 if (max_track_len < max_track_len_temp)
2004 max_track_len = max_track_len_temp;
2005 if (max_track_id < mov->tracks[i].track_id)
2010 version = max_track_len < UINT32_MAX ? 0 : 1;
2063 int size = 16 + strlen(data);
2076 return strlen(data) + 4;
2081 const char *
value,
int lang,
int long_style)
2084 if (value && value[0]) {
2095 const char *
name,
const char *
tag,
2098 int l, lang = 0,
len, len2;
2106 snprintf(tag2,
sizeof(tag2),
"%s-", tag);
2108 len2 = strlen(t2->
key);
2122 int size = 0, tmpo = t ? atoi(t->
value) : 0;
2141 disc ?
"disc" :
"track",
2143 int size = 0, track = t ? atoi(t->
value) : 0;
2146 char *slash = strchr(t->
value,
'/');
2148 tracks = atoi(slash + 1);
2165 const char *
name,
const char *
tag,
2172 if (len != 1 && len != 4)
2177 num = atoi(t->
value);
2265 return (((str[0] - 0x60) & 0x1F) << 10) +
2266 (((str[1] - 0x60) & 0x1F) << 5) +
2267 (( str[2] - 0x60) & 0x1F);
2271 const char *
tag,
const char *str)
2280 if (!strcmp(tag,
"yrrc"))
2285 if (!strcmp(tag,
"albm") &&
2303 for (i = 0; i < nb_chapters; i++) {
2375 const char *str,
const char *lang,
int type)
2428 uint64_t chunkSize = chunk->
size;
2433 for (i = 1; i<trk->
entry; i++){
2441 chunkSize = chunk->
size;
2508 avio_printf(pb,
"<param name=\"%s\" value=\"%d\" valuetype=\"data\"/>\n", name, value);
2513 avio_printf(pb,
"<param name=\"%s\" value=\"%s\" valuetype=\"data\"/>\n", name, value);
2519 len =
FFMIN(
sizeof(buf) / 2 - 1, len);
2521 buf[2 *
len] =
'\0';
2522 avio_printf(pb,
"<param name=\"%s\" value=\"%s\" valuetype=\"data\"/>\n", name, buf);
2529 static const uint8_t uuid[] = {
2530 0xa5, 0xd4, 0x0b, 0x30, 0xe8, 0x14, 0x11, 0xdd,
2531 0xba, 0x2f, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66
2539 avio_printf(pb,
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
2540 avio_printf(pb,
"<smil xmlns=\"http://www.w3.org/2001/SMIL20/Language\">\n");
2542 avio_printf(pb,
"<meta name=\"creator\" content=\"%s\" />\n",
2552 int track_id = i + 1;
2561 avio_printf(pb,
"<%s systemBitrate=\"%d\">\n", type,
2621 MOVTrack *track, int64_t moof_offset)
2626 if (!track->
entry) {
2684 for (i = 0; i < track->
entry; i++) {
2713 for (i = 0; i < track->
entry; i++) {
2718 if (flags & MOV_TRUN_SAMPLE_FLAGS)
2730 static const uint8_t uuid[] = {
2731 0x6d, 0x1d, 0x9b, 0x05, 0x42, 0xd5, 0x44, 0xe6,
2732 0x80, 0xe2, 0x14, 0x1d, 0xaf, 0xf7, 0x57, 0xb2
2751 int size = 8 + 16 + 4 + 1 + 16*
n;
2752 static const uint8_t uuid[] = {
2753 0xd4, 0x80, 0x7e, 0xf2, 0xca, 0x39, 0x46, 0x95,
2754 0x8e, 0x54, 0x26, 0xcb, 0x9e, 0x46, 0xa7, 0x9f
2767 for (i = 0; i <
n; i++) {
2768 int index = entry + 1 + i;
2772 if (n < mov->ism_lookahead) {
2797 MOVTrack *track, int64_t moof_offset,
2815 for (i = 0; i <
size; i++)
2824 int tracks,
int moof_size)
2835 if (tracks >= 0 && i != tracks)
2923 int has_h264 = 0, has_video = 0;
2940 minor = has_h264 ? 0x100 : 0x200;
2943 minor = has_h264 ? 0x20000 : 0x10000;
2988 int audio_kbitrate = audio_codec->
bit_rate / 1000;
2989 int video_kbitrate =
FFMIN(video_codec->
bit_rate / 1000, 800 - audio_kbitrate);
3046 int i, closed_gop = 0;
3048 for (i = 0; i < pkt->
size - 4; i++) {
3049 c = (c << 8) + pkt->
data[i];
3051 closed_gop = pkt->
data[i + 4] >> 6 & 0x01;
3052 }
else if (c == 0x100) {
3053 int temp_ref = (pkt->
data[i + 1] << 2) | (pkt->
data[i + 2] >> 6);
3054 if (!temp_ref || closed_gop)
3067 int seq = 0, entry = 0;
3070 for (next = start; next <
end; start = next) {
3084 if (!trk->
entry && !fragment) {
3091 for (i = 0; i < trk->
entry; i++)
3124 int i, first_track = -1;
3125 int64_t mdat_size = 0;
3133 int buf_size, moov_size;
3139 if (i < mov->nb_streams)
3177 if (first_track < 0)
3186 int buf_size, write_moof = 1, moof_tracks = -1;
3199 write_moof = i == first_track;
3252 unsigned int samples_in_chunk = 0;
3254 uint8_t *reformatted_data = NULL;
3275 static uint16_t packed_size[16] =
3276 {13, 14, 16, 18, 20, 21, 27, 32, 6, 0, 0, 0, 0, 0, 0, 1};
3279 while (len < size && samples_in_chunk < 100) {
3280 len += packed_size[(pkt->
data[
len] >> 3) & 0x0F];
3283 if (samples_in_chunk > 1) {
3284 av_log(s,
AV_LOG_ERROR,
"fatal error, input is not a single packet, implement a AVParser for it\n");
3293 samples_in_chunk = 1;
3306 "use audio bitstream filter 'aac_adtstoasc' to fix it "
3307 "('-bsf:a aac_adtstoasc' option with ffmpeg)\n");
3369 if (pkt->
dts != pkt->
pts)
3393 reformatted_data, size);
3403 int64_t frag_duration = 0;
3456 if (!pkt->
size)
return 0;
3485 if (ret < 0)
return ret;
3506 track->
tag =
MKTAG(
't',
'e',
'x',
't');
3514 uint8_t chapter_properties[43] = { 0, 0, 0, 0, 0, 0, 0, 1, };
3517 memcpy(track->
enc->
extradata, chapter_properties,
sizeof(chapter_properties));
3573 len = strlen(
t->value);
3605 track->
tag =
MKTAG(
't',
'm',
'c',
'd');
3668 if (!enabled[i] && first[i] >= 0)
3706 int i, hint_track = 0, tmcd_track = 0;
3739 "with fragmentation and custom IO, disabling faststart\n");
3759 int video_streams_nb = 0, audio_streams_nb = 0, other_streams_nb = 0;
3770 if (video_streams_nb != 1 || audio_streams_nb != 1 || other_streams_nb) {
3810 "so timecode metadata are now ignored\n");
3839 "codec not currently supported in container\n", i);
3847 if (track->
tag ==
MKTAG(
'm',
'x',
'3',
'p') || track->
tag ==
MKTAG(
'm',
'x',
'3',
'n') ||
3848 track->
tag ==
MKTAG(
'm',
'x',
'4',
'p') || track->
tag ==
MKTAG(
'm',
'x',
'4',
'n') ||
3849 track->
tag ==
MKTAG(
'm',
'x',
'5',
'p') || track->
tag ==
MKTAG(
'm',
'x',
'5',
'n')) {
3854 track->
height = track->
tag >> 24 ==
'n' ? 486 : 576;
3865 "WARNING codec timebase is very high. If duration is too long,\n"
3866 "file may not be playable by quicktime. Specify a shorter timebase\n"
3867 "or choose different container.\n");
3944 mov->
time += 0x7C25B080;
4017 int i, moov_size, moov_size2;
4033 if (moov_size2 != moov_size)
4042 int ret = 0, moov_size;
4046 int read_buf_id = 0;
4058 read_buf[1] = buf + moov_size;
4067 "the second pass (faststart)\n", s->
filename);
4080 #define READ_BLOCK do { \
4081 read_size[read_buf_id] = avio_read(read_pb, read_buf[read_buf_id], moov_size); \
4090 n = read_size[read_buf_id];
4095 }
while (pos < pos_end);
4154 av_log(s,
AV_LOG_INFO,
"Starting second pass: moving the moov atom to the beginning of the file\n");
4165 av_log(s,
AV_LOG_ERROR,
"reserved_moov_size is too small, needed %"PRId64
" additional\n", 8-size);
4170 for (i = 0; i <
size; i++)
4200 #if CONFIG_MOV_MUXER
4205 .extensions =
"mov",
4217 .priv_class = &mov_muxer_class,
4220 #if CONFIG_TGP_MUXER
4225 .extensions =
"3gp",
4234 .priv_class = &tgp_muxer_class,
4237 #if CONFIG_MP4_MUXER
4242 .mime_type =
"application/mp4",
4243 .extensions =
"mp4",
4253 .priv_class = &mp4_muxer_class,
4256 #if CONFIG_PSP_MUXER
4261 .extensions =
"mp4,psp",
4271 .priv_class = &psp_muxer_class,
4274 #if CONFIG_TG2_MUXER
4279 .extensions =
"3g2",
4288 .priv_class = &tg2_muxer_class,
4291 #if CONFIG_IPOD_MUXER
4296 .mime_type =
"application/mp4",
4297 .extensions =
"m4v,m4a",
4306 .priv_class = &ipod_muxer_class,
4309 #if CONFIG_ISMV_MUXER
4314 .mime_type =
"application/mp4",
4315 .extensions =
"ismv,isma",
4324 .priv_class = &ismv_muxer_class,
4327 #if CONFIG_F4V_MUXER
4332 .mime_type =
"application/f4v",
4333 .extensions =
"f4v",
4342 .priv_class = &f4v_muxer_class,
unsigned int nb_chapters
Number of chapters in AVChapter array.
static int utf8len(const uint8_t *b)
static int mov_write_extradata_tag(AVIOContext *pb, MOVTrack *track)
This function writes extradata "as is".
int ff_mov_iso639_to_lang(const char lang[4], int mp4)
static void av_unused put_bits32(PutBitContext *s, uint32_t value)
Write exactly 32 bits into a bitstream.
const char const char void * val
static int mov_write_moof_tag_internal(AVIOContext *pb, MOVMuxContext *mov, int tracks, int moof_size)
static int ascii_to_wc(AVIOContext *pb, const uint8_t *b)
#define FF_MOV_FLAG_FASTSTART
static int get_cluster_duration(MOVTrack *track, int cluster_idx)
static int mov_write_dinf_tag(AVIOContext *pb)
void av_free_packet(AVPacket *pkt)
Free a packet.
static AVRational find_fps(AVFormatContext *s, AVStream *st)
int ffio_close_null_buf(AVIOContext *s)
Close a null buffer.
static int mov_write_ac3_tag(AVIOContext *pb, MOVTrack *track)
static void mov_write_psp_udta_tag(AVIOContext *pb, const char *str, const char *lang, int type)
#define MOV_TFHD_DEFAULT_DURATION
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding) av_const
Rescale a 64-bit integer with specified rounding.
static int mov_write_tmcd_tag(AVIOContext *pb, MOVTrack *track)
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static void param_write_int(AVIOContext *pb, const char *name, int value)
#define AV_LOG_WARNING
Something somehow does not look correct.
#define FF_MOV_FLAG_FRAGMENT
static void find_compressor(char *compressor_name, int len, MOVTrack *track)
static int mov_write_subtitle_end_packet(AVFormatContext *s, int stream_index, int64_t dts)
static int mov_write_enda_tag_be(AVIOContext *pb)
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0 ...
static void skip_bits_long(GetBitContext *s, int n)
static int mov_write_dref_tag(AVIOContext *pb)
static int mov_write_string_metadata(AVFormatContext *s, AVIOContext *pb, const char *name, const char *tag, int long_style)
static const AVCodecTag codec_f4v_tags[]
AVDictionaryEntry * av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
static int mov_pcm_be_gt16(enum AVCodecID codec_id)
int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt, int track_index, int sample, uint8_t *sample_data, int sample_size)
packed RGB 8:8:8, 24bpp, RGBRGB...
AVCodecContext * codec
Codec context associated with this stream.
static int mov_get_rawvideo_codec_tag(AVFormatContext *s, MOVTrack *track)
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
#define MOV_TRUN_SAMPLE_CTS
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
static int mov_write_ms_tag(AVIOContext *pb, MOVTrack *track)
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static int mov_write_moof_tag(AVIOContext *pb, MOVMuxContext *mov, int tracks)
static int mov_write_pasp_tag(AVIOContext *pb, MOVTrack *track)
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag)
Put a string representing the codec tag codec_tag in buf.
static int mov_write_tcmi_tag(AVIOContext *pb, MOVTrack *track)
#define MOV_TFHD_DURATION_IS_EMPTY
static uint16_t language_code(const char *str)
static int mov_write_hdlr_tag(AVIOContext *pb, MOVTrack *track)
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
static int mov_write_tfrf_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track, int entry)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
int last_sample_is_subtitle_end
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
struct MOVTrack::@152 vc1_info
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static int mov_write_glbl_tag(AVIOContext *pb, MOVTrack *track)
#define MOV_TKHD_FLAG_ENABLED
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
if((e=av_dict_get(options,"", NULL, AV_DICT_IGNORE_SUFFIX)))
static int shift_data(AVFormatContext *s)
static int mov_write_stsc_tag(AVIOContext *pb, MOVTrack *track)
static int mov_write_trkn_tag(AVIOContext *pb, MOVMuxContext *mov, AVFormatContext *s, int disc)
static int mov_write_packet(AVFormatContext *s, AVPacket *pkt)
packed RGB 8:8:8, 24bpp, BGRBGR...
static int mov_write_fiel_tag(AVIOContext *pb, MOVTrack *track)
static int mov_write_single_packet(AVFormatContext *s, AVPacket *pkt)
static int mov_write_uuidusmt_tag(AVIOContext *pb, AVFormatContext *s)
#define FF_MOV_FLAG_EMPTY_MOOV
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
static int mov_write_uuid_tag_psp(AVIOContext *pb, MOVTrack *mov)
unsigned frag_info_capacity
unsigned int samples_in_chunk
#define MOV_CLASS(flavor)
static int get_samples_per_packet(MOVTrack *track)
static int mov_get_mpeg2_xdcam_codec_tag(AVFormatContext *s, MOVTrack *track)
const AVCodecTag ff_codec_movvideo_tags[]
static int mov_pcm_le_gt16(enum AVCodecID codec_id)
static av_cold int end(AVCodecContext *avctx)
static int mov_get_codec_tag(AVFormatContext *s, MOVTrack *track)
static void mov_write_uuidprof_tag(AVIOContext *pb, AVFormatContext *s)
const char * name
Name of the codec implementation.
static int mov_write_tapt_tag(AVIOContext *pb, MOVTrack *track)
static int mov_create_chapter_track(AVFormatContext *s, int tracknum)
static int mov_write_vmhd_tag(AVIOContext *pb)
static int mov_write_amr_tag(AVIOContext *pb, MOVTrack *track)
static int mov_write_moov_tag(AVIOContext *pb, MOVMuxContext *mov, AVFormatContext *s)
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
static double av_q2d(AVRational a)
Convert rational to double.
int ff_avc_write_annexb_extradata(const uint8_t *in, uint8_t **buf, int *size)
int chapter_track
qt chapter track number
#define FF_MOV_FLAG_OMIT_TFHD_OFFSET
int start
timecode frame start (first base frame number)
static void mov_free(AVFormatContext *s)
static int mov_write_minf_tag(AVIOContext *pb, MOVTrack *track)
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
#define MOV_TRUN_SAMPLE_SIZE
static int mov_write_itunes_hdlr_tag(AVIOContext *pb, MOVMuxContext *mov, AVFormatContext *s)
static int mov_write_subtitle_tag(AVIOContext *pb, MOVTrack *track)
static int mov_write_chan_tag(AVIOContext *pb, MOVTrack *track)
bitstream reader API header.
int max_fragment_duration
enum AVPixelFormat pix_fmt
#define CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
int av_match_ext(const char *filename, const char *extensions)
Return a positive value if the given filename has one of the given extensions, 0 otherwise.
static int mov_write_wave_tag(AVIOContext *pb, MOVTrack *track)
void ff_mov_close_hinting(MOVTrack *track)
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
static int mov_write_uuid_tag_ipod(AVIOContext *pb)
Write uuid atom.
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
static av_always_inline void ffio_wfourcc(AVIOContext *pb, const uint8_t *s)
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
const OptionDef options[]
static const uint16_t fiel_data[]
#define MOV_TFHD_DEFAULT_SIZE
static int mov_write_nmhd_tag(AVIOContext *pb)
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
static int mov_find_codec_tag(AVFormatContext *s, MOVTrack *track)
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const
Rescale a 64-bit integer by 2 rational numbers.
#define MOV_TIMECODE_FLAG_DROPFRAME
static int mov_write_udta_sdp(AVIOContext *pb, MOVTrack *track)
#define FF_COMPLIANCE_NORMAL
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
AVCodecID
Identify the syntax and semantics of the bitstream.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
static int mov_write_meta_tag(AVIOContext *pb, MOVMuxContext *mov, AVFormatContext *s)
#define MOV_FRAG_SAMPLE_FLAG_DEPENDS_NO
static int mov_write_mdat_tag(AVIOContext *pb, MOVMuxContext *mov)
static int mov_write_stsz_tag(AVIOContext *pb, MOVTrack *track)
static void put_descr(AVIOContext *pb, int tag, unsigned int size)
static int mov_flush_fragment(AVFormatContext *s)
void * priv_data
Format private data.
static int mov_write_ilst_tag(AVIOContext *pb, MOVMuxContext *mov, AVFormatContext *s)
char filename[1024]
input or output filename
static int mov_write_avid_tag(AVIOContext *pb, MOVTrack *track)
static int mov_write_int8_metadata(AVFormatContext *s, AVIOContext *pb, const char *name, const char *tag, int len)
int video_track_timescale
static void mov_parse_vc1_frame(AVPacket *pkt, MOVTrack *trk, int fragment)
static int mov_write_dvc1_structs(MOVTrack *track, uint8_t *buf)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
preferred ID for decoding MPEG audio layer 1, 2 or 3
static int mov_write_tkhd_tag(AVIOContext *pb, MOVTrack *track, AVStream *st)
int rc_max_rate
maximum bitrate
static int mov_write_isml_manifest(AVIOContext *pb, MOVMuxContext *mov)
int height
active picture (w/o VBI) height for D-10/IMX
#define FF_MOV_FLAG_SEPARATE_MOOF
static int mov_write_trun_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track, int moof_size)
AVRational avg_frame_rate
Average framerate.
const AVCodecTag ff_codec_wav_tags[]
int ff_avc_parse_nal_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size)
AVPixelFormat
Pixel format.
#define MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES
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.
const AVCodecTag ff_mp4_obj_type[]
const AVCodecTag ff_codec_movsubtitle_tags[]
static int mov_write_mdhd_tag(AVIOContext *pb, MOVTrack *track)
int flags
A combination of AV_PKT_FLAG values.
uint64_t channel_layout
Audio channel layout.
int rc_buffer_size
decoder bitstream buffer size
static int mov_write_wfex_tag(AVIOContext *pb, MOVTrack *track)
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
unsigned int nb_streams
A list of all streams in the file.
int ff_avc_parse_nal_units(AVIOContext *pb, const uint8_t *buf_in, int size)
#define FF_ARRAY_ELEMS(a)
#define MOV_FRAG_INFO_ALLOC_INCREMENT
#define MOV_TRACK_ENABLED
static int mov_write_stts_tag(AVIOContext *pb, MOVTrack *track)
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
int bit_rate
the average bitrate
Opaque data information usually continuous.
static int mov_write_tfhd_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track, int64_t moof_offset)
int64_t av_rescale(int64_t a, int64_t b, int64_t c) av_const
Rescale a 64-bit integer with rounding to nearest.
void ffio_fill(AVIOContext *s, int b, int count)
int nb_meta_tmcd
number of new created tmcd track based on metadata (aka not data copy)
const AVCodecTag ff_codec_bmp_tags[]
static int mov_write_mvex_tag(AVIOContext *pb, MOVMuxContext *mov)
static int mov_write_chpl_tag(AVIOContext *pb, AVFormatContext *s)
#define MOV_TKHD_FLAG_IN_MOVIE
#define MOV_PARTIAL_SYNC_SAMPLE
int width
picture width / height.
int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index)
static int write_trailer(AVFormatContext *s1)
static int mov_write_avcc_tag(AVIOContext *pb, MOVTrack *track)
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static int mov_write_trak_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track, AVStream *st)
internal header for RIFF based (de)muxers do NOT include this in end user applications ...
static int mov_get_dv_codec_tag(AVFormatContext *s, MOVTrack *track)
static int mov_write_string_tag(AVIOContext *pb, const char *name, const char *value, int lang, int long_style)
static int mov_write_smhd_tag(AVIOContext *pb)
int avoid_negative_ts
Avoid negative timestamps during muxing.
int reserved_moov_size
0 for disabled, -1 for automatic, size otherwise
static int mov_write_stco_tag(AVIOContext *pb, MOVTrack *track)
static void param_write_string(AVIOContext *pb, const char *name, const char *value)
#define MOV_TRUN_SAMPLE_DURATION
static int mov_write_trex_tag(AVIOContext *pb, MOVTrack *track)
preferred ID for MPEG-1/2 video decoding
static int mov_write_mfhd_tag(AVIOContext *pb, MOVMuxContext *mov)
int64_t reserved_moov_pos
int64_t end
chapter start/end time in time_base units
int frame_size
Number of samples per channel in an audio frame.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define AV_LOG_INFO
Standard information.
static int mov_write_esds_tag(AVIOContext *pb, MOVTrack *track)
#define MOV_INDEX_CLUSTER_SIZE
static int mov_write_d263_tag(AVIOContext *pb)
enum AVMediaType codec_type
const AVCodecTag ff_codec_movaudio_tags[]
static int mov_write_ctts_tag(AVIOContext *pb, MOVTrack *track)
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
int sample_rate
samples per second
#define FF_RTP_FLAG_OPTS(ctx, fieldname)
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
main external API structure.
#define MOV_TRUN_FIRST_SAMPLE_FLAGS
#define FF_MOV_FLAG_FRAG_CUSTOM
int hint_track
the track that hints this track, -1 if no hint track is set
static int mov_write_video_tag(AVIOContext *pb, MOVTrack *track)
static int mov_write_hmhd_tag(AVIOContext *pb)
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
static int mov_parse_mpeg2_frame(AVPacket *pkt, uint32_t *flags)
static int mov_write_dvc1_tag(AVIOContext *pb, MOVTrack *track)
static void build_chunks(MOVTrack *trk)
static int supports_edts(MOVMuxContext *mov)
AVIOContext * pb
I/O context.
static unsigned int get_bits1(GetBitContext *s)
static int mov_write_edts_tag(AVIOContext *pb, MOVTrack *track)
#define MKTAG(a, b, c, d)
#define FF_MOV_FLAG_RTP_HINT
static void skip_bits(GetBitContext *s, int n)
unsigned int chunkNum
Chunk number if the current entry is a chunk start otherwise 0.
static int co64_required(const MOVTrack *track)
rational number numerator/denominator
static void param_write_hex(AVIOContext *pb, const char *name, const uint8_t *value, int len)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
int ffio_open_null_buf(AVIOContext **s)
Open a write-only fake memory stream.
#define MOV_TFHD_DEFAULT_FLAGS
Usually treated as AVMEDIA_TYPE_DATA.
MOVFragmentInfo * frag_info
#define MOV_TRUN_SAMPLE_FLAGS
static const AVCodecTag codec_3gp_tags[]
static int mov_write_enda_tag(AVIOContext *pb)
static int mov_write_gmhd_tag(AVIOContext *pb, MOVTrack *track)
static void write_matrix(AVIOContext *pb, int16_t a, int16_t b, int16_t c, int16_t d, int16_t tx, int16_t ty)
static int mp4_get_codec_tag(AVFormatContext *s, MOVTrack *track)
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
AVFormatContext * rtp_ctx
the format context for the hinting rtp muxer
int av_timecode_init_from_string(AVTimecode *tc, AVRational rate, const char *str, void *log_ctx)
Parse timecode representation (hh:mm:ss[:;.
static int mov_write_udta_tag(AVIOContext *pb, MOVMuxContext *mov, AVFormatContext *s)
static int mov_write_trailer(AVFormatContext *s)
#define FF_MOV_FLAG_FRAG_KEYFRAME
static int mov_write_3gp_udta_tag(AVIOContext *pb, AVFormatContext *s, const char *tag, const char *str)
static int mov_write_mvhd_tag(AVIOContext *pb, MOVMuxContext *mov)
static int mov_write_tfrf_tags(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track)
static int mov_write_tfra_tag(AVIOContext *pb, MOVTrack *track)
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
#define MOV_TFHD_BASE_DATA_OFFSET
static uint32_t get_sample_flags(MOVTrack *track, MOVIentry *entry)
static int mov_write_tfxd_tag(AVIOContext *pb, MOVTrack *track)
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
int disposition
AV_DISPOSITION_* bit field.
int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc)
int src_track
the track that this hint (or tmcd) track describes
AVRational time_base
time base in which the start/end timestamps are specified
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
static int mov_write_mdia_tag(AVIOContext *pb, MOVTrack *track)
int64_t nb_frames
number of frames in this stream if known or 0
static int mov_write_traf_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track, int64_t moof_offset, int moof_size)
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
#define AV_OPT_FLAG_ENCODING_PARAM
a generic parameter which can be set by the user for muxing or encoding
static int mov_create_timecode_track(AVFormatContext *s, int index, int src_index, const char *tcstr)
static int mov_write_tmpo_tag(AVIOContext *pb, AVFormatContext *s)
struct AVOutputFormat * oformat
static int mov_write_audio_tag(AVIOContext *pb, MOVTrack *track)
static int mov_write_iods_tag(AVIOContext *pb, MOVMuxContext *mov)
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
static int mov_write_stss_tag(AVIOContext *pb, MOVTrack *track, uint32_t flag)
uint32_t default_sample_flags
int av_timecode_check_frame_rate(AVRational rate)
Check if the timecode feature is available for the given frame rate.
static int mov_write_mfra_tag(AVIOContext *pb, MOVMuxContext *mov)
int channels
number of audio channels
static int mov_write_string_data_tag(AVIOContext *pb, const char *data, int lang, int long_style)
static int mov_write_header(AVFormatContext *s)
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
static void write_header(FFV1Context *f)
static int64_t update_size(AVIOContext *pb, int64_t pos)
static av_always_inline uint64_t av_double2int(double f)
Reinterpret a double as a 64-bit integer.
#define MOV_TRUN_DATA_OFFSET
static av_always_inline int vc1_unescape_buffer(const uint8_t *src, int size, uint8_t *dst)
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
int tref_id
trackID of the referenced track
static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s)
static const AVCodecTag codec_ipod_tags[]
static unsigned compute_avg_bitrate(MOVTrack *track)
enum AVFieldOrder field_order
Field order.
#define AV_DICT_IGNORE_SUFFIX
static int mov_write_rtp_tag(AVIOContext *pb, MOVTrack *track)
static struct @151 mov_pix_fmt_tags[]
static int mov_write_tref_tag(AVIOContext *pb, MOVTrack *track)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
unsigned cluster_capacity
int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
static int mov_get_lpcm_flags(enum AVCodecID codec_id)
Compute flags for 'lpcm' tag.
static int mov_write_stbl_tag(AVIOContext *pb, MOVTrack *track)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0 ...
uint32_t ff_mov_get_channel_layout_tag(enum AVCodecID codec_id, uint64_t channel_layout, uint32_t *bitmap)
Get the channel layout tag for the specified codec id and channel layout.
static int ipod_get_codec_tag(AVFormatContext *s, MOVTrack *track)
static int mov_write_stsd_tag(AVIOContext *pb, MOVTrack *track)
#define CONFIG_LIBX264_ENCODER
static void enable_tracks(AVFormatContext *s)
uint32_t flags
flags such as drop frame, +24 hours support, ...
#define GET_UTF8(val, GET_BYTE, ERROR)
This structure stores compressed data.
int min_fragment_duration
static int write_packet(AVFormatContext *s1, AVPacket *pkt)
int strict_std_compliance
strictly follow the standard (MPEG4, ...).
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...) av_printf_format(3
Append output to a string, according to a format.
int ff_isom_write_avcc(AVIOContext *pb, const uint8_t *data, int len)
#define AV_NOPTS_VALUE
Undefined timestamp value.
static av_always_inline const uint8_t * find_next_marker(const uint8_t *src, const uint8_t *end)
Find VC-1 marker in buffer.
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC
static int compute_moov_size(AVFormatContext *s)
static int get_moov_size(AVFormatContext *s)