46 {
"movflags",
"MOV muxer flags", offsetof(
MOVMuxContext,
flags),
AV_OPT_TYPE_FLAGS, {.dbl = 0}, INT_MIN, INT_MAX,
AV_OPT_FLAG_ENCODING_PARAM,
"movflags" },
55 #define MOV_CLASS(flavor)\
56 static const AVClass flavor ## _muxer_class = {\
57 .class_name = #flavor " muxer",\
58 .item_name = av_default_item_name,\
60 .version = LIBAVUTIL_VERSION_INT,\
88 for (i=0; i<track->
entry; i++) {
101 int i, j, entries = 0, tst = -1, oldtst = -1;
108 for (i=0; i<track->
entry; i++) {
110 if(oldtst != -1 && tst != oldtst) {
118 sSize =
FFMAX(1, sSize);
125 for (i=0; i<track->
entry; i++) {
138 int index = 0, oldval = -1, i;
139 int64_t entryPos, curpos;
147 for (i=0; i<track->
entry; i++) {
168 int64_t curpos, entryPos;
176 for (i=0; i<track->
entry; i++) {
208 int fscod, bsid, bsmod, acmod, lfeon, frmsizecod;
225 if ((acmod & 1) && acmod != 1)
270 avio_w8(pb, (size>>(7*i)) | 0x80);
277 int decoderSpecificInfoLen = track->
vosLen ? 5+track->
vosLen : 0;
284 putDescr(pb, 0x03, 3 + 5+13 + decoderSpecificInfoLen + 5+1);
289 putDescr(pb, 0x04, 13 + decoderSpecificInfoLen);
347 uint32_t layout_tag, bitmap;
355 "lack of channel information\n");
448 uint32_t
tag = track->
tag;
501 else if(track->
tag ==
MKTAG(
'm',
'p',
'4',
'a'))
509 else if(track->
vosLen > 0)
590 for (i = 0; i < 10; i++)
632 (tag ==
MKTAG(
't',
'x',
'3',
'g') ||
633 tag ==
MKTAG(
't',
'e',
'x',
't'))))
638 "Quicktime/Ipod might not play the file\n");
650 else tag =
MKTAG(
'd',
'v',
'c',
' ');
653 else tag =
MKTAG(
'd',
'v',
'p',
'p');
656 else tag =
MKTAG(
'd',
'v',
'h',
'p');
659 else tag =
MKTAG(
'd',
'v',
'h',
'6');
668 static const struct {
724 "the file may be unplayable!\n");
731 tag =
MKTAG(
'm',
's', ((ms_tag >> 8) & 0xff), (ms_tag & 0xff));
733 "the file may be unplayable!\n");
787 0x0000, 0x0100, 0x0201, 0x0206, 0x0209, 0x020e
792 unsigned mov_field_order = 0;
834 char compressor_name[32];
865 memset(compressor_name,0,32);
869 avio_w8(pb, strlen(compressor_name));
877 if(track->
tag ==
MKTAG(
'm',
'p',
'4',
'v'))
891 else if(track->
vosLen > 0)
943 uint32_t entries = 0;
947 ctts_entries =
av_malloc((track->
entry + 1) *
sizeof(*ctts_entries));
948 ctts_entries[0].
count = 1;
950 for (i=1; i<track->
entry; i++) {
952 ctts_entries[entries].
count++;
956 ctts_entries[entries].
count = 1;
960 atom_size = 16 + (entries * 8);
965 for (i=0; i<entries; i++) {
977 uint32_t entries = -1;
982 stts_entries =
av_malloc(
sizeof(*stts_entries));
988 for (i=0; i<track->
entry; i++) {
992 if (i && duration == stts_entries[entries].duration) {
993 stts_entries[entries].
count++;
997 stts_entries[entries].
count = 1;
1002 atom_size = 16 + (entries * 8);
1007 for (i=0; i<entries; i++) {
1105 const char *hdlr, *descr =
NULL, *hdlr_type =
NULL;
1111 descr =
"DataHandler";
1113 hdlr = (track->
mode ==
MODE_MOV) ?
"mhlr" :
"\0\0\0\0";
1116 descr =
"VideoHandler";
1119 descr =
"SoundHandler";
1121 if (track->
tag ==
MKTAG(
't',
'x',
'3',
'g')) hdlr_type =
"sbtl";
1122 else hdlr_type =
"text";
1123 descr =
"SubtitleHandler";
1126 descr =
"HintHandler";
1173 }
else if (track->
tag ==
MKTAG(
'r',
't',
'p',
' ')) {
1205 "FATAL error, file duration too long for timebase, this file will not be\n"
1206 "playable with quicktime. Choose a different timebase or a different\n"
1207 "container format\n");
1276 sample_aspect_ratio = 1;
1319 int entry_size, entry_count,
size;
1320 int64_t delay, start_ct = track->
cluster[0].
cts;
1325 entry_size = (version == 1) ? 20 : 12;
1326 entry_count = 1 + (delay > 0);
1327 size = 24 + entry_count * entry_size;
1392 char buf[1000] =
"";
1396 av_strlcatf(buf,
sizeof(buf),
"a=control:streamid=%d\r\n", index);
1422 if (track->
tag ==
MKTAG(
'r',
't',
'p',
' '))
1426 if (0.0 != sample_aspect_ratio && 1.0 != sample_aspect_ratio)
1434 int i, has_audio = 0, has_video = 0;
1444 if (audio_profile < 0)
1445 audio_profile = 0xFF - has_audio;
1446 if (video_profile < 0)
1447 video_profile = 0xFF - has_video;
1463 int maxTrackID = 1, i;
1464 int64_t maxTrackLenTemp, maxTrackLen = 0;
1473 if(maxTrackLen < maxTrackLenTemp)
1474 maxTrackLen = maxTrackLenTemp;
1475 if(maxTrackID < mov->tracks[i].trackID)
1541 int size = 16 + strlen(data);
1554 return strlen(data) + 4;
1560 if (value && value[0]) {
1571 const char *
name,
const char *
tag,
1574 int l, lang = 0,
len, len2;
1582 snprintf(tag2,
sizeof(tag2),
"%s-", tag);
1584 len2 = strlen(t2->
key);
1599 int size = 0, track = t ? atoi(t->
value) : 0;
1684 return (((str[0]-0x60) & 0x1F) << 10) + (((str[1]-0x60) & 0x1F) << 5) + ((str[2]-0x60) & 0x1F);
1688 const char *
tag,
const char *str)
1697 if (!strcmp(tag,
"yrrc"))
1702 if (!strcmp(tag,
"albm") &&
1720 for (i = 0; i < nb_chapters; i++) {
1789 const char *str,
const char *lang,
int type)
1900 int has_h264 = 0, has_video = 0;
1917 minor = has_h264 ? 0x100 : 0x200;
1920 minor = has_h264 ? 0x20000 : 0x10000;
1958 int audio_kbitrate= AudioCodec->
bit_rate / 1000;
1959 int video_kbitrate=
FFMIN(VideoCodec->
bit_rate / 1000, 800 - audio_kbitrate);
2016 int i, closed_gop = 0;
2018 for (i = 0; i < pkt->
size - 4; i++) {
2019 c = (c<<8) + pkt->
data[i];
2021 closed_gop = pkt->
data[i+4]>>6 & 0x01;
2022 }
else if (c == 0x100) {
2023 int temp_ref = (pkt->
data[i+1]<<2) | (pkt->
data[i+2]>>6);
2024 if (!temp_ref || closed_gop)
2040 unsigned int samplesInChunk = 0;
2042 uint8_t *reformatted_data =
NULL;
2045 if (!size)
return 0;
2049 static uint16_t packed_size[16] =
2050 {13, 14, 16, 18, 20, 21, 27, 32, 6, 0, 0, 0, 0, 0, 0, 1};
2053 while (len < size && samplesInChunk < 100) {
2054 len += packed_size[(pkt->
data[
len] >> 3) & 0x0F];
2057 if(samplesInChunk > 1){
2058 av_log(s,
AV_LOG_ERROR,
"fatal error, input is not a single packet, implement a AVParser for it\n");
2114 if (pkt->
dts != pkt->
pts)
2138 reformatted_data, size);
2153 track->
tag =
MKTAG(
't',
'e',
'x',
't');
2164 pkt.duration = end - pkt.dts;
2167 len = strlen(
t->value);
2171 memcpy(pkt.data+2,
t->value,
len);
2183 int i, hint_track = 0;
2214 #if FF_API_FLAG_RTP_HINT
2215 if (s->
flags & AVFMT_FLAG_RTP_HINT) {
2217 "via the -movflags rtphint muxer option "
2251 "codec not currently supported in container\n", i);
2258 if (track->
tag ==
MKTAG(
'm',
'x',
'3',
'p') || track->
tag ==
MKTAG(
'm',
'x',
'3',
'n') ||
2259 track->
tag ==
MKTAG(
'm',
'x',
'4',
'p') || track->
tag ==
MKTAG(
'm',
'x',
'4',
'n') ||
2260 track->
tag ==
MKTAG(
'm',
'x',
'5',
'p') || track->
tag ==
MKTAG(
'm',
'x',
'5',
'n')) {
2265 track->
height = track->
tag>>24 ==
'n' ? 486 : 576;
2270 "WARNING codec timebase is very high. If duration is too long,\n"
2271 "file may not be playable by quicktime. Specify a shorter timebase\n"
2272 "or choose different container.\n");
2294 "sample rate %dhz\n", i, track->
timescale);
2314 #if FF_API_TIMESTAMP
2316 mov->
time = s->timestamp;
2322 mov->
time += 0x7C25B080;
2390 #if CONFIG_MOV_MUXER
2395 .extensions =
"mov",
2408 .priv_class = &mov_muxer_class,
2411 #if CONFIG_TGP_MUXER
2416 .extensions =
"3gp",
2425 .priv_class = &tgp_muxer_class,
2428 #if CONFIG_MP4_MUXER
2433 .mime_type =
"application/mp4",
2434 .extensions =
"mp4",
2447 .priv_class = &mp4_muxer_class,
2450 #if CONFIG_PSP_MUXER
2455 .extensions =
"mp4,psp",
2468 .priv_class = &psp_muxer_class,
2471 #if CONFIG_TG2_MUXER
2476 .extensions =
"3g2",
2485 .priv_class = &tg2_muxer_class,
2488 #if CONFIG_IPOD_MUXER
2493 .mime_type =
"application/mp4",
2494 .extensions =
"m4v,m4a",
2503 .priv_class = &ipod_muxer_class,