annotate movenc.c @ 791:f961db8ea65d libavformat

This trivial patch adds "avc1" as fourcc for h264 in mp4, which makes it a little bit more standard, although it still seems to lack some metadata. Anyway, recent mplayer plays these streams without problems. It also has two globally scoped global structs changed to "static". patch by (Erik Slagter <erik slagter name)
author michael
date Sun, 19 Jun 2005 23:45:54 +0000
parents 5697cc32e295
children e446442b0851
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1 /*
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
2 * MOV, 3GP, MP4 encoder.
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
3 * Copyright (c) 2003 Thomas Raivio.
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
4 * Copyright (c) 2004 Gildas Bazin <gbazin at videolan dot org>.
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
5 *
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
6 * This library is free software; you can redistribute it and/or
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
7 * modify it under the terms of the GNU Lesser General Public
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
8 * License as published by the Free Software Foundation; either
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
9 * version 2 of the License, or (at your option) any later version.
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
10 *
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
11 * This library is distributed in the hope that it will be useful,
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
14 * Lesser General Public License for more details.
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
15 *
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
16 * You should have received a copy of the GNU Lesser General Public
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
17 * License along with this library; if not, write to the Free Software
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
19 */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
20 #include "avformat.h"
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
21 #include "avi.h"
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
22 #include "avio.h"
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
23
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
24 #undef NDEBUG
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
25 #include <assert.h>
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
26
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
27 #define MOV_INDEX_CLUSTER_SIZE 16384
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
28 #define globalTimescale 1000
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
29
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
30 #define MODE_MP4 0
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
31 #define MODE_MOV 1
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
32 #define MODE_3GP 2
659
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
33 #define MODE_PSP 3 // example working PSP command line:
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
34 // ffmpeg -i testinput.avi -f psp -r 14.985 -s 320x240 -b 768 -ar 24000 -ab 32 M4V00001.MP4
677
6d6a11ba402a quick patch for adding 3g2 support to ffmpeg (muxer and demuxer). No movie fragment support yet patch by (tjraivio cc.hut fi)
michael
parents: 676
diff changeset
35 #define MODE_3G2 4
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
36
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
37 typedef struct MOVIentry {
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
38 unsigned int flags, pos, size;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
39 unsigned int samplesInChunk;
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
40 char key_frame;
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
41 unsigned int entries;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
42 } MOVIentry;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
43
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
44 typedef struct MOVIndex {
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
45 int mode;
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
46 int entry;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
47 int mdat_size;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
48 int ents_allocated;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
49 long timescale;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
50 long time;
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
51 long trackDuration;
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
52 long sampleCount;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
53 long sampleDuration;
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
54 int hasKeyframes;
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
55 int trackID;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
56 AVCodecContext *enc;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
57
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
58 int vosLen;
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
59 uint8_t *vosData;
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
60 MOVIentry** cluster;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
61 } MOVTrack;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
62
659
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
63 typedef struct MOVContext {
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
64 int mode;
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
65 long time;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
66 int nb_streams;
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
67 int mdat_written;
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
68 offset_t mdat_pos;
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
69 long timescale;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
70 MOVTrack tracks[MAX_STREAMS];
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
71 } MOVContext;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
72
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
73 static int mov_write_esds_tag(ByteIOContext *pb, MOVTrack* track);
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
74
710
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
75 const CodecTag ff_mov_obj_type[] = {
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
76 { CODEC_ID_MPEG4 , 32 },
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
77 { CODEC_ID_AAC , 64 },
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
78 { CODEC_ID_MPEG1VIDEO, 106 },
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
79 { CODEC_ID_MPEG2VIDEO, 96 },//mpeg2 profiles
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
80 { CODEC_ID_MP2 , 107 },//FIXME mpeg2 mpeg audio -> 105
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
81 { CODEC_ID_MP3 , 107 },//FIXME mpeg2 mpeg audio -> 105
779
5697cc32e295 according to the standard the object_type for H264 is 33, not 241
nicodvb
parents: 761
diff changeset
82 { CODEC_ID_H264 , 33 },
710
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
83 { CODEC_ID_H263 , 242 },
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
84 { CODEC_ID_H261 , 243 },
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
85 { CODEC_ID_MJPEG , 108 },
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
86 { CODEC_ID_PCM_S16LE , 224 },
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
87 { CODEC_ID_VORBIS , 225 },
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
88 { CODEC_ID_AC3 , 226 },
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
89 { CODEC_ID_PCM_ALAW , 227 },
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
90 { CODEC_ID_PCM_MULAW , 228 },
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
91 { CODEC_ID_PCM_S16BE , 230 },
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
92 { 0,0 },
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
93 };
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
94
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
95 //FIXME supprt 64bit varaint with wide placeholders
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
96 static int updateSize (ByteIOContext *pb, int pos)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
97 {
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
98 long curpos = url_ftell(pb);
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
99 url_fseek(pb, pos, SEEK_SET);
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
100 put_be32(pb, curpos - pos); /* rewrite size */
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
101 url_fseek(pb, curpos, SEEK_SET);
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
102
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
103 return curpos - pos;
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
104 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
105
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
106 /* Chunk offset atom */
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
107 static int mov_write_stco_tag(ByteIOContext *pb, MOVTrack* track)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
108 {
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
109 int i;
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
110 int pos = url_ftell(pb);
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
111 put_be32(pb, 0); /* size */
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
112 put_tag(pb, "stco");
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
113 put_be32(pb, 0); /* version & flags */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
114 put_be32(pb, track->entry); /* entry count */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
115 for (i=0; i<track->entry; i++) {
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
116 int cl = i / MOV_INDEX_CLUSTER_SIZE;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
117 int id = i % MOV_INDEX_CLUSTER_SIZE;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
118 put_be32(pb, track->cluster[cl][id].pos);
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
119 }
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
120 return updateSize (pb, pos);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
121 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
122
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
123 /* Sample size atom */
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
124 static int mov_write_stsz_tag(ByteIOContext *pb, MOVTrack* track)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
125 {
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
126 int equalChunks = 1;
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
127 int i, j, entries = 0, tst = -1, oldtst = -1;
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
128
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
129 int pos = url_ftell(pb);
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
130 put_be32(pb, 0); /* size */
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
131 put_tag(pb, "stsz");
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
132 put_be32(pb, 0); /* version & flags */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
133
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
134 for (i=0; i<track->entry; i++) {
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
135 int cl = i / MOV_INDEX_CLUSTER_SIZE;
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
136 int id = i % MOV_INDEX_CLUSTER_SIZE;
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
137 tst = track->cluster[cl][id].size/track->cluster[cl][id].entries;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
138 if(oldtst != -1 && tst != oldtst) {
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
139 equalChunks = 0;
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
140 }
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
141 oldtst = tst;
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
142 entries += track->cluster[cl][id].entries;
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
143 }
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
144 if (equalChunks) {
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
145 int sSize = track->cluster[0][0].size/track->cluster[0][0].entries;
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
146 put_be32(pb, sSize); // sample size
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
147 put_be32(pb, entries); // sample count
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
148 }
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
149 else {
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
150 put_be32(pb, 0); // sample size
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
151 put_be32(pb, entries); // sample count
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
152 for (i=0; i<track->entry; i++) {
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
153 int cl = i / MOV_INDEX_CLUSTER_SIZE;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
154 int id = i % MOV_INDEX_CLUSTER_SIZE;
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
155 for ( j=0; j<track->cluster[cl][id].entries; j++) {
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
156 put_be32(pb, track->cluster[cl][id].size /
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
157 track->cluster[cl][id].entries);
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
158 }
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
159 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
160 }
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
161 return updateSize (pb, pos);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
162 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
163
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
164 /* Sample to chunk atom */
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
165 static int mov_write_stsc_tag(ByteIOContext *pb, MOVTrack* track)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
166 {
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
167 int index = 0, oldval = -1, i, entryPos, curpos;
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
168
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
169 int pos = url_ftell(pb);
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
170 put_be32(pb, 0); /* size */
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
171 put_tag(pb, "stsc");
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
172 put_be32(pb, 0); // version & flags
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
173 entryPos = url_ftell(pb);
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
174 put_be32(pb, track->entry); // entry count
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
175 for (i=0; i<track->entry; i++) {
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
176 int cl = i / MOV_INDEX_CLUSTER_SIZE;
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
177 int id = i % MOV_INDEX_CLUSTER_SIZE;
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
178 if(oldval != track->cluster[cl][id].samplesInChunk)
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
179 {
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
180 put_be32(pb, i+1); // first chunk
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
181 put_be32(pb, track->cluster[cl][id].samplesInChunk); // samples per chunk
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
182 put_be32(pb, 0x1); // sample description index
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
183 oldval = track->cluster[cl][id].samplesInChunk;
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
184 index++;
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
185 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
186 }
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
187 curpos = url_ftell(pb);
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
188 url_fseek(pb, entryPos, SEEK_SET);
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
189 put_be32(pb, index); // rewrite size
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
190 url_fseek(pb, curpos, SEEK_SET);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
191
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
192 return updateSize (pb, pos);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
193 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
194
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
195 /* Sync sample atom */
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
196 static int mov_write_stss_tag(ByteIOContext *pb, MOVTrack* track)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
197 {
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
198 long curpos;
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
199 int i, index = 0, entryPos;
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
200 int pos = url_ftell(pb);
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
201 put_be32(pb, 0); // size
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
202 put_tag(pb, "stss");
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
203 put_be32(pb, 0); // version & flags
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
204 entryPos = url_ftell(pb);
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
205 put_be32(pb, track->entry); // entry count
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
206 for (i=0; i<track->entry; i++) {
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
207 int cl = i / MOV_INDEX_CLUSTER_SIZE;
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
208 int id = i % MOV_INDEX_CLUSTER_SIZE;
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
209 if(track->cluster[cl][id].key_frame == 1) {
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
210 put_be32(pb, i+1);
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
211 index++;
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
212 }
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
213 }
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
214 curpos = url_ftell(pb);
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
215 url_fseek(pb, entryPos, SEEK_SET);
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
216 put_be32(pb, index); // rewrite size
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
217 url_fseek(pb, curpos, SEEK_SET);
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
218 return updateSize (pb, pos);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
219 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
220
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
221 static int mov_write_damr_tag(ByteIOContext *pb)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
222 {
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
223 put_be32(pb, 0x11); /* size */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
224 put_tag(pb, "damr");
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
225 put_tag(pb, "FFMP");
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
226 put_byte(pb, 0);
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
227
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
228 put_be16(pb, 0x80); /* Mode set (all modes for AMR_NB) */
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
229 put_be16(pb, 0xa); /* Mode change period (no restriction) */
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
230 //put_be16(pb, 0x81ff); /* Mode set (all modes for AMR_NB) */
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
231 //put_be16(pb, 1); /* Mode change period (no restriction) */
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
232 return 0x11;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
233 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
234
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
235 static int mov_write_wave_tag(ByteIOContext *pb, MOVTrack* track)
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
236 {
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
237 int pos = url_ftell(pb);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
238
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
239 put_be32(pb, 0); /* size */
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
240 put_tag(pb, "wave");
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
241
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
242 put_be32(pb, 12); /* size */
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
243 put_tag(pb, "frma");
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
244 put_tag(pb, "mp4a");
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
245
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
246 put_be32(pb, 12); /* size */
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
247 put_tag(pb, "mp4a");
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
248 put_be32(pb, 0);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
249
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
250 mov_write_esds_tag(pb, track);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
251
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
252 put_be32(pb, 12); /* size */
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
253 put_tag(pb, "srcq");
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
254 put_be32(pb, 0x40);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
255
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
256 put_be32(pb, 8); /* size */
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
257 put_be32(pb, 0); /* null tag */
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
258
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
259 return updateSize (pb, pos);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
260 }
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
261
791
f961db8ea65d This trivial patch adds "avc1" as fourcc for h264 in mp4, which makes it
michael
parents: 779
diff changeset
262 static const CodecTag codec_movaudio_tags[] = {
422
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
263 { CODEC_ID_PCM_MULAW, MKTAG('u', 'l', 'a', 'w') },
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
264 { CODEC_ID_PCM_ALAW, MKTAG('a', 'l', 'a', 'w') },
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
265 { CODEC_ID_ADPCM_IMA_QT, MKTAG('i', 'm', 'a', '4') },
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
266 { CODEC_ID_MACE3, MKTAG('M', 'A', 'C', '3') },
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
267 { CODEC_ID_MACE6, MKTAG('M', 'A', 'C', '6') },
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
268 { CODEC_ID_AAC, MKTAG('m', 'p', '4', 'a') },
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
269 { CODEC_ID_AMR_NB, MKTAG('s', 'a', 'm', 'r') },
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
270 { CODEC_ID_PCM_S16BE, MKTAG('t', 'w', 'o', 's') },
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
271 { CODEC_ID_PCM_S16LE, MKTAG('s', 'o', 'w', 't') },
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
272 { CODEC_ID_MP3, MKTAG('.', 'm', 'p', '3') },
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
273 { 0, 0 },
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
274 };
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
275
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
276 static int mov_write_audio_tag(ByteIOContext *pb, MOVTrack* track)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
277 {
494
abc8a657a8dd warn user if ms style codec tag is used
michael
parents: 468
diff changeset
278 int pos = url_ftell(pb);
abc8a657a8dd warn user if ms style codec tag is used
michael
parents: 468
diff changeset
279 int tag;
422
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
280
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
281 put_be32(pb, 0); /* size */
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
282
619
7d50b0a324ea add -vtag and-atag support to mov patch by (Roine Gustafsson <roine at users sourceforge net>)
michael
parents: 513
diff changeset
283 tag = track->enc->codec_tag;
7d50b0a324ea add -vtag and-atag support to mov patch by (Roine Gustafsson <roine at users sourceforge net>)
michael
parents: 513
diff changeset
284 if (!tag)
422
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
285 tag = codec_get_tag(codec_movaudio_tags, track->enc->codec_id);
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
286 // if no mac fcc found, try with Microsoft tags
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
287 if (!tag)
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
288 {
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
289 int tmp = codec_get_tag(codec_wav_tags, track->enc->codec_id);
494
abc8a657a8dd warn user if ms style codec tag is used
michael
parents: 468
diff changeset
290 tag = MKTAG('m', 's', ((tmp >> 8) & 0xff), (tmp & 0xff));
422
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
291 }
494
abc8a657a8dd warn user if ms style codec tag is used
michael
parents: 468
diff changeset
292 put_le32(pb, tag); // store it byteswapped
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
293
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
294 put_be32(pb, 0); /* Reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
295 put_be16(pb, 0); /* Reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
296 put_be16(pb, 1); /* Data-reference index, XXX == 1 */
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
297
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
298 /* SoundDescription */
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
299 if(track->mode == MODE_MOV && track->enc->codec_id == CODEC_ID_AAC)
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
300 put_be16(pb, 1); /* Version 1 */
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
301 else
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
302 put_be16(pb, 0); /* Version 0 */
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
303 put_be16(pb, 0); /* Revision level */
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
304 put_be32(pb, 0); /* Reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
305
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
306 put_be16(pb, track->enc->channels); /* Number of channels */
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
307 /* TODO: Currently hard-coded to 16-bit, there doesn't seem
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
308 to be a good way to get number of bits of audio */
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
309 put_be16(pb, 0x10); /* Reserved */
505
e996e7da971c AAC in mov/mp4 patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 494
diff changeset
310
e996e7da971c AAC in mov/mp4 patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 494
diff changeset
311 if(track->enc->codec_id == CODEC_ID_AAC ||
e996e7da971c AAC in mov/mp4 patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 494
diff changeset
312 track->enc->codec_id == CODEC_ID_MP3)
e996e7da971c AAC in mov/mp4 patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 494
diff changeset
313 {
e996e7da971c AAC in mov/mp4 patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 494
diff changeset
314 put_be16(pb, 0xfffe); /* compression ID (vbr)*/
e996e7da971c AAC in mov/mp4 patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 494
diff changeset
315 }
e996e7da971c AAC in mov/mp4 patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 494
diff changeset
316 else
e996e7da971c AAC in mov/mp4 patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 494
diff changeset
317 {
e996e7da971c AAC in mov/mp4 patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 494
diff changeset
318 put_be16(pb, 0); /* compression ID (= 0) */
e996e7da971c AAC in mov/mp4 patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 494
diff changeset
319 }
399
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
320 put_be16(pb, 0); /* packet size (= 0) */
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
321 put_be16(pb, track->timescale); /* Time scale */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
322 put_be16(pb, 0); /* Reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
323
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
324 if(track->mode == MODE_MOV && track->enc->codec_id == CODEC_ID_AAC)
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
325 {
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
326 /* SoundDescription V1 extended info */
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
327 put_be32(pb, track->enc->frame_size); /* Samples per packet */
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
328 put_be32(pb, 1536); /* Bytes per packet */
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
329 put_be32(pb, 2); /* Bytes per frame */
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
330 put_be32(pb, 2); /* Bytes per sample */
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
331 }
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
332
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
333 if(track->enc->codec_id == CODEC_ID_AAC) {
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
334 if( track->mode == MODE_MOV ) mov_write_wave_tag(pb, track);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
335 else mov_write_esds_tag(pb, track);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
336 }
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
337 if(track->enc->codec_id == CODEC_ID_AMR_NB)
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
338 mov_write_damr_tag(pb);
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
339 return updateSize (pb, pos);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
340 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
341
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
342 static int mov_write_d263_tag(ByteIOContext *pb)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
343 {
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
344 put_be32(pb, 0xf); /* size */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
345 put_tag(pb, "d263");
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
346 put_tag(pb, "FFMP");
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
347 put_be16(pb, 0x0a);
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
348 put_byte(pb, 0);
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
349 return 0xf;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
350 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
351
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
352 /* TODO: No idea about these values */
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
353 static int mov_write_svq3_tag(ByteIOContext *pb)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
354 {
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
355 put_be32(pb, 0x15);
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
356 put_tag(pb, "SMI ");
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
357 put_tag(pb, "SEQH");
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
358 put_be32(pb, 0x5);
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
359 put_be32(pb, 0xe2c0211d);
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
360 put_be32(pb, 0xc0000000);
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
361 put_byte(pb, 0);
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
362 return 0x15;
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
363 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
364
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
365 static unsigned int descrLength(unsigned int len)
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
366 {
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
367 if (len < 0x00000080)
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
368 return 2 + len;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
369 else if (len < 0x00004000)
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
370 return 3 + len;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
371 else if(len < 0x00200000)
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
372 return 4 + len;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
373 else
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
374 return 5 + len;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
375 }
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
376
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
377 static void putDescr(ByteIOContext *pb, int tag, int size)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
378 {
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
379 uint32_t len;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
380 uint8_t vals[4];
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
381
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
382 len = size;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
383 vals[3] = (uint8_t)(len & 0x7f);
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
384 len >>= 7;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
385 vals[2] = (uint8_t)((len & 0x7f) | 0x80);
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
386 len >>= 7;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
387 vals[1] = (uint8_t)((len & 0x7f) | 0x80);
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
388 len >>= 7;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
389 vals[0] = (uint8_t)((len & 0x7f) | 0x80);
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
390
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
391 put_byte(pb, tag); // DescriptorTag
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
392
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
393 if (size < 0x00000080)
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
394 {
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
395 put_byte(pb, vals[3]);
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
396 }
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
397 else if (size < 0x00004000)
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
398 {
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
399 put_byte(pb, vals[2]);
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
400 put_byte(pb, vals[3]);
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
401 }
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
402 else if (size < 0x00200000)
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
403 {
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
404 put_byte(pb, vals[1]);
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
405 put_byte(pb, vals[2]);
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
406 put_byte(pb, vals[3]);
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
407 }
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
408 else if (size < 0x10000000)
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
409 {
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
410 put_byte(pb, vals[0]);
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
411 put_byte(pb, vals[1]);
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
412 put_byte(pb, vals[2]);
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
413 put_byte(pb, vals[3]);
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
414 }
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
415 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
416
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
417 static int mov_write_esds_tag(ByteIOContext *pb, MOVTrack* track) // Basic
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
418 {
663
570274d13064 fix the patch to allow Sony PSP MP4 creation
mmu_man
parents: 661
diff changeset
419 int decoderSpecificInfoLen;
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
420 int pos = url_ftell(pb);
659
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
421 void *vosDataBackup=track->vosData;
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
422 int vosLenBackup=track->vosLen;
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
423
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
424 // we should be able to have these passed in, via vosData, then we wouldn't need to attack this routine at all
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
425 static const char PSPAACData[]={0x13,0x10};
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
426 static const char PSPMP4Data[]={0x00,0x00,0x01,0xB0,0x03,0x00,0x00,0x01,0xB5,0x09,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x20,0x00,0x84,0x5D,0x4C,0x28,0x50,0x20,0xF0,0xA3,0x1F };
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
427
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
428
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
429 if (track->mode == MODE_PSP) // fails on psp if this is not here
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
430 {
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
431 if (track->enc->codec_id == CODEC_ID_AAC)
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
432 {
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
433 track->vosLen = 2;
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
434 track->vosData = PSPAACData;
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
435 }
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
436
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
437 if (track->enc->codec_id == CODEC_ID_MPEG4)
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
438 {
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
439 track->vosLen = 28;
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
440 track->vosData = PSPMP4Data;
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
441 }
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
442 }
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
443
663
570274d13064 fix the patch to allow Sony PSP MP4 creation
mmu_man
parents: 661
diff changeset
444 decoderSpecificInfoLen = track->vosLen ? descrLength(track->vosLen):0;
570274d13064 fix the patch to allow Sony PSP MP4 creation
mmu_man
parents: 661
diff changeset
445
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
446 put_be32(pb, 0); // size
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
447 put_tag(pb, "esds");
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
448 put_be32(pb, 0); // Version
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
449
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
450 // ES descriptor
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
451 putDescr(pb, 0x03, 3 + descrLength(13 + decoderSpecificInfoLen) +
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
452 descrLength(1));
710
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
453 put_be16(pb, track->trackID);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
454 put_byte(pb, 0x00); // flags (= no flags)
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
455
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
456 // DecoderConfig descriptor
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
457 putDescr(pb, 0x04, 13 + decoderSpecificInfoLen);
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
458
710
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
459 // Object type indication
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
460 put_byte(pb, codec_get_tag(ff_mov_obj_type, track->enc->codec_id));
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
461
779
5697cc32e295 according to the standard the object_type for H264 is 33, not 241
nicodvb
parents: 761
diff changeset
462 // the following fields is made of 6 bits to identify the streamtype (4 for video, 5 for audio)
5697cc32e295 according to the standard the object_type for H264 is 33, not 241
nicodvb
parents: 761
diff changeset
463 // plus 1 bit to indicate upstream and 1 bit set to 1 (reserved)
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
464 if(track->enc->codec_type == CODEC_TYPE_AUDIO)
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
465 put_byte(pb, 0x15); // flags (= Audiostream)
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
466 else
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
467 put_byte(pb, 0x11); // flags (= Visualstream)
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
468
710
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
469 put_byte(pb, track->enc->rc_buffer_size>>(3+16)); // Buffersize DB (24 bits)
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
470 put_be16(pb, (track->enc->rc_buffer_size>>3)&0xFFFF); // Buffersize DB
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
471
710
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
472 put_be32(pb, FFMAX(track->enc->bit_rate, track->enc->rc_max_rate)); // maxbitrate (FIXME should be max rate in any 1 sec window)
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
473 if(track->enc->rc_max_rate != track->enc->rc_min_rate || track->enc->rc_min_rate==0)
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
474 put_be32(pb, 0); // vbr
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
475 else
020ebcb662d5 trying to fix a few minor values in the mp4/mov muxer
michael
parents: 683
diff changeset
476 put_be32(pb, track->enc->rc_max_rate); // avg bitrate
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
477
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
478 if (track->vosLen)
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
479 {
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
480 // DecoderSpecific info descriptor
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
481 putDescr(pb, 0x05, track->vosLen);
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
482 put_buffer(pb, track->vosData, track->vosLen);
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
483 }
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
484
659
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
485 track->vosData = vosDataBackup;
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
486 track->vosLen = vosLenBackup;
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
487
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
488 // SL descriptor
377
d58f2852730e 10l (1 vs. descrLength(1)) found by (Jean Le Feuvre - jeanlf)
michael
parents: 365
diff changeset
489 putDescr(pb, 0x06, 1);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
490 put_byte(pb, 0x02);
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
491 return updateSize (pb, pos);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
492 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
493
791
f961db8ea65d This trivial patch adds "avc1" as fourcc for h264 in mp4, which makes it
michael
parents: 779
diff changeset
494 static const CodecTag codec_movvideo_tags[] = {
422
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
495 { CODEC_ID_SVQ1, MKTAG('S', 'V', 'Q', '1') },
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
496 { CODEC_ID_SVQ3, MKTAG('S', 'V', 'Q', '3') },
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
497 { CODEC_ID_MPEG4, MKTAG('m', 'p', '4', 'v') },
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
498 { CODEC_ID_H263, MKTAG('s', '2', '6', '3') },
791
f961db8ea65d This trivial patch adds "avc1" as fourcc for h264 in mp4, which makes it
michael
parents: 779
diff changeset
499 { CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') },
422
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
500 { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', ' ') },
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
501 { 0, 0 },
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
502 };
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
503
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
504 static int mov_write_video_tag(ByteIOContext *pb, MOVTrack* track)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
505 {
494
abc8a657a8dd warn user if ms style codec tag is used
michael
parents: 468
diff changeset
506 int pos = url_ftell(pb);
657
5b9575f5b6e8 mov header field and compressor name patch by Roine Gustafsson <roine AT users DOT sourceforge DOT net>
mmu_man
parents: 619
diff changeset
507 char compressor_name[32];
494
abc8a657a8dd warn user if ms style codec tag is used
michael
parents: 468
diff changeset
508 int tag;
422
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
509
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
510 put_be32(pb, 0); /* size */
422
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
511
619
7d50b0a324ea add -vtag and-atag support to mov patch by (Roine Gustafsson <roine at users sourceforge net>)
michael
parents: 513
diff changeset
512 tag = track->enc->codec_tag;
7d50b0a324ea add -vtag and-atag support to mov patch by (Roine Gustafsson <roine at users sourceforge net>)
michael
parents: 513
diff changeset
513 if (!tag)
422
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
514 tag = codec_get_tag(codec_movvideo_tags, track->enc->codec_id);
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
515 // if no mac fcc found, try with Microsoft tags
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
516 if (!tag)
2f30932cda1f support for wider range of codecs
alex
parents: 400
diff changeset
517 tag = codec_get_tag(codec_bmp_tags, track->enc->codec_id);
494
abc8a657a8dd warn user if ms style codec tag is used
michael
parents: 468
diff changeset
518 put_le32(pb, tag); // store it byteswapped
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
519
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
520 put_be32(pb, 0); /* Reserved */
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
521 put_be16(pb, 0); /* Reserved */
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
522 put_be16(pb, 1); /* Data-reference index */
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
523
657
5b9575f5b6e8 mov header field and compressor name patch by Roine Gustafsson <roine AT users DOT sourceforge DOT net>
mmu_man
parents: 619
diff changeset
524 put_be16(pb, 0); /* Codec stream version */
5b9575f5b6e8 mov header field and compressor name patch by Roine Gustafsson <roine AT users DOT sourceforge DOT net>
mmu_man
parents: 619
diff changeset
525 put_be16(pb, 0); /* Codec stream revision (=0) */
5b9575f5b6e8 mov header field and compressor name patch by Roine Gustafsson <roine AT users DOT sourceforge DOT net>
mmu_man
parents: 619
diff changeset
526 put_tag(pb, "FFMP"); /* Vendor */
5b9575f5b6e8 mov header field and compressor name patch by Roine Gustafsson <roine AT users DOT sourceforge DOT net>
mmu_man
parents: 619
diff changeset
527 if(track->enc->codec_id == CODEC_ID_RAWVIDEO) {
5b9575f5b6e8 mov header field and compressor name patch by Roine Gustafsson <roine AT users DOT sourceforge DOT net>
mmu_man
parents: 619
diff changeset
528 put_be32(pb, 0); /* Temporal Quality */
5b9575f5b6e8 mov header field and compressor name patch by Roine Gustafsson <roine AT users DOT sourceforge DOT net>
mmu_man
parents: 619
diff changeset
529 put_be32(pb, 0x400); /* Spatial Quality = lossless*/
5b9575f5b6e8 mov header field and compressor name patch by Roine Gustafsson <roine AT users DOT sourceforge DOT net>
mmu_man
parents: 619
diff changeset
530 } else {
5b9575f5b6e8 mov header field and compressor name patch by Roine Gustafsson <roine AT users DOT sourceforge DOT net>
mmu_man
parents: 619
diff changeset
531 put_be32(pb, 0x200); /* Temporal Quality = normal */
5b9575f5b6e8 mov header field and compressor name patch by Roine Gustafsson <roine AT users DOT sourceforge DOT net>
mmu_man
parents: 619
diff changeset
532 put_be32(pb, 0x200); /* Spatial Quality = normal */
5b9575f5b6e8 mov header field and compressor name patch by Roine Gustafsson <roine AT users DOT sourceforge DOT net>
mmu_man
parents: 619
diff changeset
533 }
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
534 put_be16(pb, track->enc->width); /* Video width */
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
535 put_be16(pb, track->enc->height); /* Video height */
657
5b9575f5b6e8 mov header field and compressor name patch by Roine Gustafsson <roine AT users DOT sourceforge DOT net>
mmu_man
parents: 619
diff changeset
536 put_be32(pb, 0x00480000); /* Horizontal resolution 72dpi */
5b9575f5b6e8 mov header field and compressor name patch by Roine Gustafsson <roine AT users DOT sourceforge DOT net>
mmu_man
parents: 619
diff changeset
537 put_be32(pb, 0x00480000); /* Vertical resolution 72dpi */
399
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
538 put_be32(pb, 0); /* Data size (= 0) */
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
539 put_be16(pb, 1); /* Frame count (= 1) */
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
540
657
5b9575f5b6e8 mov header field and compressor name patch by Roine Gustafsson <roine AT users DOT sourceforge DOT net>
mmu_man
parents: 619
diff changeset
541 memset(compressor_name,0,32);
664
76d0af843707 don't crash on null codec; by matthieu castet <castet DOT matthieu AT free DOT fr>
mmu_man
parents: 663
diff changeset
542 if (track->enc->codec && track->enc->codec->name)
657
5b9575f5b6e8 mov header field and compressor name patch by Roine Gustafsson <roine AT users DOT sourceforge DOT net>
mmu_man
parents: 619
diff changeset
543 strncpy(compressor_name,track->enc->codec->name,31);
664
76d0af843707 don't crash on null codec; by matthieu castet <castet DOT matthieu AT free DOT fr>
mmu_man
parents: 663
diff changeset
544 put_byte(pb, strlen(compressor_name));
657
5b9575f5b6e8 mov header field and compressor name patch by Roine Gustafsson <roine AT users DOT sourceforge DOT net>
mmu_man
parents: 619
diff changeset
545 put_buffer(pb, compressor_name, 31);
399
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
546
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
547 put_be16(pb, 0x18); /* Reserved */
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
548 put_be16(pb, 0xffff); /* Reserved */
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
549 if(track->enc->codec_id == CODEC_ID_MPEG4)
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
550 mov_write_esds_tag(pb, track);
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
551 else if(track->enc->codec_id == CODEC_ID_H263)
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
552 mov_write_d263_tag(pb);
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
553 else if(track->enc->codec_id == CODEC_ID_SVQ3)
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
554 mov_write_svq3_tag(pb);
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
555
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
556 return updateSize (pb, pos);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
557 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
558
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
559 static int mov_write_stsd_tag(ByteIOContext *pb, MOVTrack* track)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
560 {
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
561 int pos = url_ftell(pb);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
562 put_be32(pb, 0); /* size */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
563 put_tag(pb, "stsd");
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
564 put_be32(pb, 0); /* version & flags */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
565 put_be32(pb, 1); /* entry count */
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
566 if (track->enc->codec_type == CODEC_TYPE_VIDEO)
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
567 mov_write_video_tag(pb, track);
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
568 else if (track->enc->codec_type == CODEC_TYPE_AUDIO)
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
569 mov_write_audio_tag(pb, track);
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
570 return updateSize(pb, pos);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
571 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
572
676
8512c400e3bc nonsense comment
michael
parents: 665
diff changeset
573 /* TODO: */
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
574 /* Time to sample atom */
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
575 static int mov_write_stts_tag(ByteIOContext *pb, MOVTrack* track)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
576 {
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
577 put_be32(pb, 0x18); /* size */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
578 put_tag(pb, "stts");
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
579 put_be32(pb, 0); /* version & flags */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
580 put_be32(pb, 1); /* entry count */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
581
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
582 put_be32(pb, track->sampleCount); /* sample count */
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
583 put_be32(pb, track->sampleDuration); /* sample duration */
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
584 return 0x18;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
585 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
586
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
587 static int mov_write_dref_tag(ByteIOContext *pb)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
588 {
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
589 put_be32(pb, 28); /* size */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
590 put_tag(pb, "dref");
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
591 put_be32(pb, 0); /* version & flags */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
592 put_be32(pb, 1); /* entry count */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
593
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
594 put_be32(pb, 0xc); /* size */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
595 put_tag(pb, "url ");
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
596 put_be32(pb, 1); /* version & flags */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
597
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
598 return 28;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
599 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
600
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
601 static int mov_write_stbl_tag(ByteIOContext *pb, MOVTrack* track)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
602 {
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
603 int pos = url_ftell(pb);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
604 put_be32(pb, 0); /* size */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
605 put_tag(pb, "stbl");
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
606 mov_write_stsd_tag(pb, track);
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
607 mov_write_stts_tag(pb, track);
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
608 if (track->enc->codec_type == CODEC_TYPE_VIDEO &&
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
609 track->hasKeyframes)
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
610 mov_write_stss_tag(pb, track);
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
611 mov_write_stsc_tag(pb, track);
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
612 mov_write_stsz_tag(pb, track);
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
613 mov_write_stco_tag(pb, track);
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
614 return updateSize(pb, pos);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
615 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
616
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
617 static int mov_write_dinf_tag(ByteIOContext *pb)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
618 {
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
619 int pos = url_ftell(pb);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
620 put_be32(pb, 0); /* size */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
621 put_tag(pb, "dinf");
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
622 mov_write_dref_tag(pb);
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
623 return updateSize(pb, pos);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
624 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
625
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
626 static int mov_write_smhd_tag(ByteIOContext *pb)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
627 {
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
628 put_be32(pb, 16); /* size */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
629 put_tag(pb, "smhd");
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
630 put_be32(pb, 0); /* version & flags */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
631 put_be16(pb, 0); /* reserved (balance, normally = 0) */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
632 put_be16(pb, 0); /* reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
633 return 16;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
634 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
635
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
636 static int mov_write_vmhd_tag(ByteIOContext *pb)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
637 {
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
638 put_be32(pb, 0x14); /* size (always 0x14) */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
639 put_tag(pb, "vmhd");
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
640 put_be32(pb, 0x01); /* version & flags */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
641 put_be64(pb, 0); /* reserved (graphics mode = copy) */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
642 return 0x14;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
643 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
644
399
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
645 static int mov_write_hdlr_tag(ByteIOContext *pb, MOVTrack* track)
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
646 {
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
647 char *descr, *hdlr, *hdlr_type;
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
648 int pos = url_ftell(pb);
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
649
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
650 if (!track) { /* no media --> data handler */
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
651 hdlr = "dhlr";
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
652 hdlr_type = "url ";
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
653 descr = "DataHandler";
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
654 } else {
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
655 hdlr = (track->mode == MODE_MOV) ? "mhlr" : "\0\0\0\0";
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
656 if (track->enc->codec_type == CODEC_TYPE_VIDEO) {
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
657 hdlr_type = "vide";
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
658 descr = "VideoHandler";
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
659 } else {
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
660 hdlr_type = "soun";
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
661 descr = "SoundHandler";
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
662 }
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
663 }
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
664
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
665 put_be32(pb, 0); /* size */
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
666 put_tag(pb, "hdlr");
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
667 put_be32(pb, 0); /* Version & flags */
400
62e4ea840c52 * fixing 10l in movenc.c + updating regression patterns.
romansh
parents: 399
diff changeset
668 put_buffer(pb, hdlr, 4); /* handler */
399
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
669 put_tag(pb, hdlr_type); /* handler type */
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
670 put_be32(pb ,0); /* reserved */
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
671 put_be32(pb ,0); /* reserved */
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
672 put_be32(pb ,0); /* reserved */
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
673 put_byte(pb, strlen(descr)); /* string counter */
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
674 put_buffer(pb, descr, strlen(descr)); /* handler description */
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
675 return updateSize(pb, pos);
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
676 }
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
677
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
678 static int mov_write_minf_tag(ByteIOContext *pb, MOVTrack* track)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
679 {
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
680 int pos = url_ftell(pb);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
681 put_be32(pb, 0); /* size */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
682 put_tag(pb, "minf");
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
683 if(track->enc->codec_type == CODEC_TYPE_VIDEO)
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
684 mov_write_vmhd_tag(pb);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
685 else
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
686 mov_write_smhd_tag(pb);
399
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
687 if (track->mode == MODE_MOV) /* FIXME: Why do it for MODE_MOV only ? */
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
688 mov_write_hdlr_tag(pb, NULL);
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
689 mov_write_dinf_tag(pb);
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
690 mov_write_stbl_tag(pb, track);
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
691 return updateSize(pb, pos);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
692 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
693
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
694 static int mov_write_mdhd_tag(ByteIOContext *pb, MOVTrack* track)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
695 {
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
696 put_be32(pb, 32); /* size */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
697 put_tag(pb, "mdhd");
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
698 put_be32(pb, 0); /* Version & flags */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
699 put_be32(pb, track->time); /* creation time */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
700 put_be32(pb, track->time); /* modification time */
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
701 put_be32(pb, track->timescale); /* time scale (sample rate for audio) */
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
702 put_be32(pb, track->trackDuration); /* duration */
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
703 put_be16(pb, 0); /* language, 0 = english */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
704 put_be16(pb, 0); /* reserved (quality) */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
705 return 32;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
706 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
707
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
708 static int mov_write_mdia_tag(ByteIOContext *pb, MOVTrack* track)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
709 {
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
710 int pos = url_ftell(pb);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
711 put_be32(pb, 0); /* size */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
712 put_tag(pb, "mdia");
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
713 mov_write_mdhd_tag(pb, track);
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
714 mov_write_hdlr_tag(pb, track);
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
715 mov_write_minf_tag(pb, track);
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
716 return updateSize(pb, pos);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
717 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
718
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
719 static int mov_write_tkhd_tag(ByteIOContext *pb, MOVTrack* track)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
720 {
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
721 put_be32(pb, 0x5c); /* size (always 0x5c) */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
722 put_tag(pb, "tkhd");
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
723 put_be32(pb, 0xf); /* version & flags (track enabled) */
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
724 put_be32(pb, track->time); /* creation time */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
725 put_be32(pb, track->time); /* modification time */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
726 put_be32(pb, track->trackID); /* track-id */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
727 put_be32(pb, 0); /* reserved */
761
805598adf3e9 round duration up in mov
michael
parents: 743
diff changeset
728 put_be32(pb, av_rescale_rnd(track->trackDuration, globalTimescale, track->timescale, AV_ROUND_UP)); /* duration */
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
729
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
730 put_be32(pb, 0); /* reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
731 put_be32(pb, 0); /* reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
732 put_be32(pb, 0x0); /* reserved (Layer & Alternate group) */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
733 /* Volume, only for audio */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
734 if(track->enc->codec_type == CODEC_TYPE_AUDIO)
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
735 put_be16(pb, 0x0100);
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
736 else
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
737 put_be16(pb, 0);
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
738 put_be16(pb, 0); /* reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
739
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
740 /* Matrix structure */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
741 put_be32(pb, 0x00010000); /* reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
742 put_be32(pb, 0x0); /* reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
743 put_be32(pb, 0x0); /* reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
744 put_be32(pb, 0x0); /* reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
745 put_be32(pb, 0x00010000); /* reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
746 put_be32(pb, 0x0); /* reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
747 put_be32(pb, 0x0); /* reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
748 put_be32(pb, 0x0); /* reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
749 put_be32(pb, 0x40000000); /* reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
750
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
751 /* Track width and height, for visual only */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
752 if(track->enc->codec_type == CODEC_TYPE_VIDEO) {
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
753 double sample_aspect_ratio = av_q2d(track->enc->sample_aspect_ratio);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
754 if( !sample_aspect_ratio ) sample_aspect_ratio = 1;
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
755 put_be32(pb, sample_aspect_ratio * track->enc->width*0x10000);
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
756 put_be32(pb, track->enc->height*0x10000);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
757 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
758 else {
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
759 put_be32(pb, 0);
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
760 put_be32(pb, 0);
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
761 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
762 return 0x5c;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
763 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
764
659
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
765 // This box seems important for the psp playback ... without it the movie seems to hang
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
766 static int mov_write_edts_tag(ByteIOContext *pb, MOVTrack *track)
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
767 {
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
768 put_be32(pb, 0x24); /* size */
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
769 put_tag(pb, "edts");
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
770 put_be32(pb, 0x1c); /* size */
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
771 put_tag(pb, "elst");
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
772 put_be32(pb, 0x0);
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
773 put_be32(pb, 0x1);
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
774
761
805598adf3e9 round duration up in mov
michael
parents: 743
diff changeset
775 put_be32(pb, av_rescale_rnd(track->trackDuration, globalTimescale, track->timescale, AV_ROUND_UP)); /* duration ... doesn't seem to effect psp */
659
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
776
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
777 put_be32(pb, 0x0);
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
778 put_be32(pb, 0x00010000);
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
779 return 0x24;
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
780 }
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
781
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
782 // goes at the end of each track! ... Critical for PSP playback ("Incompatible data" without it)
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
783 static int mov_write_uuid_tag_psp(ByteIOContext *pb, MOVTrack *mov)
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
784 {
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
785 put_be32(pb, 0x34); /* size ... reports as 28 in mp4box! */
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
786 put_tag(pb, "uuid");
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
787 put_tag(pb, "USMT");
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
788 put_be32(pb, 0x21d24fce);
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
789 put_be32(pb, 0xbb88695c);
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
790 put_be32(pb, 0xfac9c740);
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
791 put_be32(pb, 0x1c); // another size here!
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
792 put_tag(pb, "MTDT");
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
793 put_be32(pb, 0x00010012);
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
794 put_be32(pb, 0x0a);
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
795 put_be32(pb, 0x55c40000);
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
796 put_be32(pb, 0x1);
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
797 put_be32(pb, 0x0);
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
798 return 0x34;
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
799 }
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
800
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
801 static int mov_write_trak_tag(ByteIOContext *pb, MOVTrack* track)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
802 {
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
803 int pos = url_ftell(pb);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
804 put_be32(pb, 0); /* size */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
805 put_tag(pb, "trak");
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
806 mov_write_tkhd_tag(pb, track);
659
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
807 if (track->mode == MODE_PSP)
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
808 mov_write_edts_tag(pb, track); // PSP Movies require edts box
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
809 mov_write_mdia_tag(pb, track);
659
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
810 if (track->mode == MODE_PSP)
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
811 mov_write_uuid_tag_psp(pb,track); // PSP Movies require this uuid box
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
812 return updateSize(pb, pos);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
813 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
814
683
095009fc2f35 kill warnings patch by (M«©ns Rullg«©rd <mru inprovide com>)
michael
parents: 677
diff changeset
815 #if 0
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
816 /* TODO: Not sorted out, but not necessary either */
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
817 static int mov_write_iods_tag(ByteIOContext *pb, MOVContext *mov)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
818 {
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
819 put_be32(pb, 0x15); /* size */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
820 put_tag(pb, "iods");
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
821 put_be32(pb, 0); /* version & flags */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
822 put_be16(pb, 0x1007);
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
823 put_byte(pb, 0);
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
824 put_be16(pb, 0x4fff);
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
825 put_be16(pb, 0xfffe);
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
826 put_be16(pb, 0x01ff);
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
827 return 0x15;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
828 }
683
095009fc2f35 kill warnings patch by (M«©ns Rullg«©rd <mru inprovide com>)
michael
parents: 677
diff changeset
829 #endif
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
830
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
831 static int mov_write_mvhd_tag(ByteIOContext *pb, MOVContext *mov)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
832 {
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
833 int maxTrackID = 1, maxTrackLen = 0, i;
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
834 int64_t maxTrackLenTemp;
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
835
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
836 put_be32(pb, 0x6c); /* size (always 0x6c) */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
837 put_tag(pb, "mvhd");
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
838 put_be32(pb, 0); /* version & flags */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
839 put_be32(pb, mov->time); /* creation time */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
840 put_be32(pb, mov->time); /* modification time */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
841 put_be32(pb, mov->timescale); /* timescale */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
842 for (i=0; i<MAX_STREAMS; i++) {
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
843 if(mov->tracks[i].entry > 0) {
761
805598adf3e9 round duration up in mov
michael
parents: 743
diff changeset
844 maxTrackLenTemp = av_rescale_rnd(mov->tracks[i].trackDuration, globalTimescale, mov->tracks[i].timescale, AV_ROUND_UP);
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
845 if(maxTrackLen < maxTrackLenTemp)
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
846 maxTrackLen = maxTrackLenTemp;
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
847 if(maxTrackID < mov->tracks[i].trackID)
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
848 maxTrackID = mov->tracks[i].trackID;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
849 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
850 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
851 put_be32(pb, maxTrackLen); /* duration of longest track */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
852
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
853 put_be32(pb, 0x00010000); /* reserved (preferred rate) 1.0 = normal */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
854 put_be16(pb, 0x0100); /* reserved (preferred volume) 1.0 = normal */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
855 put_be16(pb, 0); /* reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
856 put_be32(pb, 0); /* reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
857 put_be32(pb, 0); /* reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
858
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
859 /* Matrix structure */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
860 put_be32(pb, 0x00010000); /* reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
861 put_be32(pb, 0x0); /* reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
862 put_be32(pb, 0x0); /* reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
863 put_be32(pb, 0x0); /* reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
864 put_be32(pb, 0x00010000); /* reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
865 put_be32(pb, 0x0); /* reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
866 put_be32(pb, 0x0); /* reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
867 put_be32(pb, 0x0); /* reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
868 put_be32(pb, 0x40000000); /* reserved */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
869
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
870 put_be32(pb, 0); /* reserved (preview time) */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
871 put_be32(pb, 0); /* reserved (preview duration) */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
872 put_be32(pb, 0); /* reserved (poster time) */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
873 put_be32(pb, 0); /* reserved (selection time) */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
874 put_be32(pb, 0); /* reserved (selection duration) */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
875 put_be32(pb, 0); /* reserved (current time) */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
876 put_be32(pb, maxTrackID+1); /* Next track id */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
877 return 0x6c;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
878 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
879
513
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
880 static int mov_write_itunes_hdlr_tag(ByteIOContext *pb, MOVContext* mov,
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
881 AVFormatContext *s)
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
882 {
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
883 int pos = url_ftell(pb);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
884 put_be32(pb, 0); /* size */
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
885 put_tag(pb, "hdlr");
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
886 put_be32(pb, 0);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
887 put_be32(pb, 0);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
888 put_tag(pb, "mdir");
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
889 put_tag(pb, "appl");
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
890 put_be32(pb, 0);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
891 put_be32(pb, 0);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
892 put_be16(pb, 0);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
893 return updateSize(pb, pos);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
894 }
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
895
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
896 /* helper function to write a data tag with the specified string as data */
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
897 static int mov_write_string_data_tag(ByteIOContext *pb, MOVContext* mov,
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
898 AVFormatContext *s, const char *data)
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
899 {
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
900 int pos = url_ftell(pb);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
901 put_be32(pb, 0); /* size */
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
902 put_tag(pb, "data");
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
903 put_be32(pb, 1);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
904 put_be32(pb, 0);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
905 put_buffer(pb, data, strlen(data));
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
906 return updateSize(pb, pos);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
907 }
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
908
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
909 /* iTunes name of the song/movie */
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
910 static int mov_write_nam_tag(ByteIOContext *pb, MOVContext* mov,
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
911 AVFormatContext *s)
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
912 {
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
913 int size = 0;
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
914 if ( s->title[0] ) {
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
915 int pos = url_ftell(pb);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
916 put_be32(pb, 0); /* size */
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
917 put_tag(pb, "\251nam");
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
918 mov_write_string_data_tag(pb, mov, s, s->title);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
919 size = updateSize(pb, pos);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
920 }
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
921 return size;
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
922 }
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
923
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
924 /* iTunes name of the artist/performer */
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
925 static int mov_write_ART_tag(ByteIOContext *pb, MOVContext* mov,
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
926 AVFormatContext *s)
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
927 {
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
928 int size = 0;
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
929 if ( s->author[0] ) {
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
930 int pos = url_ftell(pb);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
931 put_be32(pb, 0); /* size */
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
932 put_tag(pb, "\251ART");
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
933 // we use the author here as this is the only thing that we have...
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
934 mov_write_string_data_tag(pb, mov, s, s->author);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
935 size = updateSize(pb, pos);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
936 }
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
937 return size;
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
938 }
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
939
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
940 /* iTunes name of the writer */
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
941 static int mov_write_wrt_tag(ByteIOContext *pb, MOVContext* mov,
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
942 AVFormatContext *s)
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
943 {
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
944 int size = 0;
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
945 if ( s->author[0] ) {
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
946 int pos = url_ftell(pb);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
947 put_be32(pb, 0); /* size */
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
948 put_tag(pb, "\251wrt");
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
949 mov_write_string_data_tag(pb, mov, s, s->author);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
950 size = updateSize(pb, pos);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
951 }
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
952 return size;
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
953 }
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
954
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
955 /* iTunes name of the album */
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
956 static int mov_write_alb_tag(ByteIOContext *pb, MOVContext* mov,
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
957 AVFormatContext *s)
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
958 {
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
959 int size = 0;
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
960 if ( s->album[0] ) {
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
961 int pos = url_ftell(pb);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
962 put_be32(pb, 0); /* size */
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
963 put_tag(pb, "\251alb");
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
964 mov_write_string_data_tag(pb, mov, s, s->album);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
965 size = updateSize(pb, pos);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
966 }
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
967 return size;
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
968 }
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
969
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
970 /* iTunes year */
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
971 static int mov_write_day_tag(ByteIOContext *pb, MOVContext* mov,
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
972 AVFormatContext *s)
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
973 {
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
974 char year[5];
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
975 int size = 0;
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
976 if ( s->year ) {
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
977 int pos = url_ftell(pb);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
978 put_be32(pb, 0); /* size */
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
979 put_tag(pb, "\251day");
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
980 snprintf(year, 5, "%04d", s->year);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
981 mov_write_string_data_tag(pb, mov, s, year);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
982 size = updateSize(pb, pos);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
983 }
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
984 return size;
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
985 }
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
986
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
987 /* iTunes tool used to create the file */
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
988 static int mov_write_too_tag(ByteIOContext *pb, MOVContext* mov,
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
989 AVFormatContext *s)
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
990 {
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
991 int pos = url_ftell(pb);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
992 put_be32(pb, 0); /* size */
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
993 put_tag(pb, "\251too");
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
994 mov_write_string_data_tag(pb, mov, s, LIBAVFORMAT_IDENT);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
995 return updateSize(pb, pos);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
996 }
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
997
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
998 /* iTunes comment */
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
999 static int mov_write_cmt_tag(ByteIOContext *pb, MOVContext* mov,
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1000 AVFormatContext *s)
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1001 {
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1002 int size = 0;
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1003 if ( s->comment[0] ) {
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1004 int pos = url_ftell(pb);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1005 put_be32(pb, 0); /* size */
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1006 put_tag(pb, "\251cmt");
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1007 mov_write_string_data_tag(pb, mov, s, s->comment);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1008 size = updateSize(pb, pos);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1009 }
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1010 return size;
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1011 }
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1012
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1013 /* iTunes custom genre */
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1014 static int mov_write_gen_tag(ByteIOContext *pb, MOVContext* mov,
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1015 AVFormatContext *s)
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1016 {
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1017 int size = 0;
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1018 if ( s->genre[0] ) {
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1019 int pos = url_ftell(pb);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1020 put_be32(pb, 0); /* size */
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1021 put_tag(pb, "\251gen");
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1022 mov_write_string_data_tag(pb, mov, s, s->genre);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1023 size = updateSize(pb, pos);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1024 }
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1025 return size;
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1026 }
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1027
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1028 /* iTunes track number */
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1029 static int mov_write_trkn_tag(ByteIOContext *pb, MOVContext* mov,
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1030 AVFormatContext *s)
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1031 {
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1032 int size = 0;
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1033 if ( s->track ) {
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1034 int pos = url_ftell(pb);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1035 put_be32(pb, 0); /* size */
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1036 put_tag(pb, "trkn");
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1037 {
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1038 int pos = url_ftell(pb);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1039 put_be32(pb, 0); /* size */
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1040 put_tag(pb, "data");
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1041 put_be32(pb, 0); // 8 bytes empty
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1042 put_be32(pb, 0);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1043 put_be16(pb, 0); // empty
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1044 put_be16(pb, s->track); // track number
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1045 put_be16(pb, 0); // total track number
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1046 put_be16(pb, 0); // empty
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1047 updateSize(pb, pos);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1048 }
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1049 size = updateSize(pb, pos);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1050 }
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1051 return size;
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1052 }
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1053
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1054 /* iTunes meta data list */
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1055 static int mov_write_ilst_tag(ByteIOContext *pb, MOVContext* mov,
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1056 AVFormatContext *s)
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1057 {
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1058 int pos = url_ftell(pb);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1059 put_be32(pb, 0); /* size */
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1060 put_tag(pb, "ilst");
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1061 mov_write_nam_tag(pb, mov, s);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1062 mov_write_ART_tag(pb, mov, s);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1063 mov_write_wrt_tag(pb, mov, s);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1064 mov_write_alb_tag(pb, mov, s);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1065 mov_write_day_tag(pb, mov, s);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1066 mov_write_too_tag(pb, mov, s);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1067 mov_write_cmt_tag(pb, mov, s);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1068 mov_write_gen_tag(pb, mov, s);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1069 mov_write_trkn_tag(pb, mov, s);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1070 return updateSize(pb, pos);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1071 }
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1072
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1073 /* iTunes meta data tag */
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1074 static int mov_write_meta_tag(ByteIOContext *pb, MOVContext* mov,
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1075 AVFormatContext *s)
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1076 {
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1077 int size = 0;
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1078
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1079 // only save meta tag if required
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1080 if ( s->title[0] || s->author[0] || s->album[0] || s->year ||
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1081 s->comment[0] || s->genre[0] || s->track ) {
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1082 int pos = url_ftell(pb);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1083 put_be32(pb, 0); /* size */
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1084 put_tag(pb, "meta");
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1085 put_be32(pb, 0);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1086 mov_write_itunes_hdlr_tag(pb, mov, s);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1087 mov_write_ilst_tag(pb, mov, s);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1088 size = updateSize(pb, pos);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1089 }
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1090 return size;
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1091 }
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1092
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1093 static int mov_write_udta_tag(ByteIOContext *pb, MOVContext* mov,
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1094 AVFormatContext *s)
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1095 {
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1096 int pos = url_ftell(pb);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1097 int i;
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1098
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1099 put_be32(pb, 0); /* size */
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1100 put_tag(pb, "udta");
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1101
513
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1102 /* iTunes meta data */
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1103 mov_write_meta_tag(pb, mov, s);
2b4edca40885 iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents: 505
diff changeset
1104
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1105 /* Requirements */
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1106 for (i=0; i<MAX_STREAMS; i++) {
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1107 if(mov->tracks[i].entry <= 0) continue;
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1108 if (mov->tracks[i].enc->codec_id == CODEC_ID_AAC ||
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1109 mov->tracks[i].enc->codec_id == CODEC_ID_MPEG4) {
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1110 int pos = url_ftell(pb);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1111 put_be32(pb, 0); /* size */
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1112 put_tag(pb, "\251req");
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1113 put_be16(pb, sizeof("QuickTime 6.0 or greater") - 1);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1114 put_be16(pb, 0);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1115 put_buffer(pb, "QuickTime 6.0 or greater",
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1116 sizeof("QuickTime 6.0 or greater") - 1);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1117 updateSize(pb, pos);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1118 break;
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1119 }
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1120 }
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1121
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1122 /* Encoder */
661
ff3b403d0498 movenc illegal access patch by Roine Gustafsson <roine AT users DOT sourceforge DOT net>
mmu_man
parents: 659
diff changeset
1123 if(mov->tracks[0].enc && !(mov->tracks[0].enc->flags & CODEC_FLAG_BITEXACT))
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1124 {
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1125 int pos = url_ftell(pb);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1126 put_be32(pb, 0); /* size */
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1127 put_tag(pb, "\251enc");
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1128 put_be16(pb, sizeof(LIBAVFORMAT_IDENT) - 1); /* string length */
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1129 put_be16(pb, 0);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1130 put_buffer(pb, LIBAVFORMAT_IDENT, sizeof(LIBAVFORMAT_IDENT) - 1);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1131 updateSize(pb, pos);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1132 }
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1133
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1134 if( s->title[0] )
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1135 {
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1136 int pos = url_ftell(pb);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1137 put_be32(pb, 0); /* size */
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1138 put_tag(pb, "\251nam");
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1139 put_be16(pb, strlen(s->title)); /* string length */
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1140 put_be16(pb, 0);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1141 put_buffer(pb, s->title, strlen(s->title));
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1142 updateSize(pb, pos);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1143 }
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1144
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1145 if( s->author[0] )
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1146 {
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1147 int pos = url_ftell(pb);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1148 put_be32(pb, 0); /* size */
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1149 put_tag(pb, /*"\251aut"*/ "\251day" );
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1150 put_be16(pb, strlen(s->author)); /* string length */
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1151 put_be16(pb, 0);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1152 put_buffer(pb, s->author, strlen(s->author));
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1153 updateSize(pb, pos);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1154 }
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1155
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1156 if( s->comment[0] )
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1157 {
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1158 int pos = url_ftell(pb);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1159 put_be32(pb, 0); /* size */
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1160 put_tag(pb, "\251des");
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1161 put_be16(pb, strlen(s->comment)); /* string length */
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1162 put_be16(pb, 0);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1163 put_buffer(pb, s->comment, strlen(s->comment));
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1164 updateSize(pb, pos);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1165 }
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1166
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1167 return updateSize(pb, pos);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1168 }
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1169
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1170 static int mov_write_moov_tag(ByteIOContext *pb, MOVContext *mov,
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1171 AVFormatContext *s)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1172 {
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
1173 int pos, i;
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1174 pos = url_ftell(pb);
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1175 put_be32(pb, 0); /* size placeholder*/
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1176 put_tag(pb, "moov");
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1177 mov->timescale = globalTimescale;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1178
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1179 for (i=0; i<MAX_STREAMS; i++) {
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1180 if(mov->tracks[i].entry <= 0) continue;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1181
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1182 if(mov->tracks[i].enc->codec_type == CODEC_TYPE_VIDEO) {
743
af4e24d6310c switch to native time bases
michael
parents: 721
diff changeset
1183 mov->tracks[i].timescale = mov->tracks[i].enc->time_base.den;
af4e24d6310c switch to native time bases
michael
parents: 721
diff changeset
1184 mov->tracks[i].sampleDuration = mov->tracks[i].enc->time_base.num;
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1185 }
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1186 else if(mov->tracks[i].enc->codec_type == CODEC_TYPE_AUDIO) {
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1187 /* If AMR, track timescale = 8000, AMR_WB = 16000 */
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1188 if(mov->tracks[i].enc->codec_id == CODEC_ID_AMR_NB) {
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1189 mov->tracks[i].sampleDuration = 160; // Bytes per chunk
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1190 mov->tracks[i].timescale = 8000;
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1191 }
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1192 else {
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1193 mov->tracks[i].timescale = mov->tracks[i].enc->sample_rate;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1194 mov->tracks[i].sampleDuration = mov->tracks[i].enc->frame_size;
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1195 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1196 }
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1197
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1198 mov->tracks[i].trackDuration =
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1199 mov->tracks[i].sampleCount * mov->tracks[i].sampleDuration;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1200 mov->tracks[i].time = mov->time;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1201 mov->tracks[i].trackID = i+1;
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1202 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1203
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
1204 mov_write_mvhd_tag(pb, mov);
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
1205 //mov_write_iods_tag(pb, mov);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1206 for (i=0; i<MAX_STREAMS; i++) {
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1207 if(mov->tracks[i].entry > 0) {
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
1208 mov_write_trak_tag(pb, &(mov->tracks[i]));
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1209 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1210 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1211
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1212 mov_write_udta_tag(pb, mov, s);
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1213
238
3519903c6c2a mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents: 202
diff changeset
1214 return updateSize(pb, pos);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1215 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1216
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
1217 int mov_write_mdat_tag(ByteIOContext *pb, MOVContext* mov)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1218 {
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
1219 mov->mdat_pos = url_ftell(pb);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1220 put_be32(pb, 0); /* size placeholder*/
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1221 put_tag(pb, "mdat");
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1222 return 0;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1223 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1224
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1225 /* TODO: This needs to be more general */
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1226 int mov_write_ftyp_tag(ByteIOContext *pb, AVFormatContext *s)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1227 {
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1228 MOVContext *mov = s->priv_data;
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1229
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1230 put_be32(pb, 0x14 ); /* size */
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1231 put_tag(pb, "ftyp");
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1232
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1233 if ( mov->mode == MODE_3GP )
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1234 put_tag(pb, "3gp4");
677
6d6a11ba402a quick patch for adding 3g2 support to ffmpeg (muxer and demuxer). No movie fragment support yet patch by (tjraivio cc.hut fi)
michael
parents: 676
diff changeset
1235 else if ( mov->mode == MODE_3G2 )
6d6a11ba402a quick patch for adding 3g2 support to ffmpeg (muxer and demuxer). No movie fragment support yet patch by (tjraivio cc.hut fi)
michael
parents: 676
diff changeset
1236 put_tag(pb, "3g2a");
659
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1237 else if ( mov->mode == MODE_PSP )
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1238 put_tag(pb, "MSNV");
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1239 else
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1240 put_tag(pb, "isom");
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1241
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1242 put_be32(pb, 0x200 );
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1243
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1244 if ( mov->mode == MODE_3GP )
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1245 put_tag(pb, "3gp4");
677
6d6a11ba402a quick patch for adding 3g2 support to ffmpeg (muxer and demuxer). No movie fragment support yet patch by (tjraivio cc.hut fi)
michael
parents: 676
diff changeset
1246 else if ( mov->mode == MODE_3G2 )
6d6a11ba402a quick patch for adding 3g2 support to ffmpeg (muxer and demuxer). No movie fragment support yet patch by (tjraivio cc.hut fi)
michael
parents: 676
diff changeset
1247 put_tag(pb, "3g2a");
659
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1248 else if ( mov->mode == MODE_PSP )
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1249 put_tag(pb, "MSNV");
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1250 else
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1251 put_tag(pb, "mp41");
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1252
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1253 return 0x14;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1254 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1255
665
47d5b20c9aba fix segfault by matthieu castet <castet DOT matthieu AT free DOT fr>
mmu_man
parents: 664
diff changeset
1256 static void mov_write_uuidprof_tag(ByteIOContext *pb, AVFormatContext *s)
659
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1257 {
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1258 int AudioRate = s->streams[1]->codec.sample_rate;
743
af4e24d6310c switch to native time bases
michael
parents: 721
diff changeset
1259 int FrameRate = ((s->streams[0]->codec.time_base.den) * (0x10000))/ (s->streams[0]->codec.time_base.num);
659
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1260
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1261 //printf("audiorate = %d\n",AudioRate);
743
af4e24d6310c switch to native time bases
michael
parents: 721
diff changeset
1262 //printf("framerate = %d / %d = 0x%x\n",s->streams[0]->codec.time_base.den,s->streams[0]->codec.time_base.num,FrameRate);
659
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1263
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1264 put_be32(pb, 0x94 ); /* size */
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1265 put_tag(pb, "uuid");
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1266 put_tag(pb, "PROF");
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1267
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1268 put_be32(pb, 0x21d24fce ); /* 96 bit UUID */
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1269 put_be32(pb, 0xbb88695c );
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1270 put_be32(pb, 0xfac9c740 );
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1271
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1272 put_be32(pb, 0x0 ); /* ? */
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1273 put_be32(pb, 0x3 ); /* 3 sections ? */
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1274
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1275 put_be32(pb, 0x14 ); /* size */
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1276 put_tag(pb, "FPRF");
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1277 put_be32(pb, 0x0 ); /* ? */
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1278 put_be32(pb, 0x0 ); /* ? */
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1279 put_be32(pb, 0x0 ); /* ? */
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1280
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1281 put_be32(pb, 0x2c ); /* size */
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1282 put_tag(pb, "APRF"); /* audio */
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1283 put_be32(pb, 0x0 );
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1284 put_be32(pb, 0x2 );
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1285 put_tag(pb, "mp4a");
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1286 put_be32(pb, 0x20f );
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1287 put_be32(pb, 0x0 );
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1288 put_be32(pb, 0x40 );
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1289 put_be32(pb, 0x40 );
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1290 put_be32(pb, AudioRate ); //24000 ... audio rate?
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1291 put_be32(pb, 0x2 );
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1292
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1293 put_be32(pb, 0x34 ); /* size */
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1294 put_tag(pb, "VPRF"); /* video */
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1295 put_be32(pb, 0x0 );
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1296 put_be32(pb, 0x1 );
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1297 put_tag(pb, "mp4v");
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1298 put_be32(pb, 0x103 );
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1299 put_be32(pb, 0x0 );
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1300 put_be32(pb, 0xc0 );
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1301 put_be32(pb, 0xc0 );
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1302 put_be32(pb, FrameRate); // was 0xefc29
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1303 put_be32(pb, FrameRate ); // was 0xefc29
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1304 put_be16(pb, s->streams[0]->codec.width);
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1305 put_be16(pb, s->streams[0]->codec.height);
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1306 put_be32(pb, 0x010001 );
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1307 }
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1308
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1309 static int mov_write_header(AVFormatContext *s)
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1310 {
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1311 ByteIOContext *pb = &s->pb;
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1312 MOVContext *mov = s->priv_data;
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1313 int i;
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1314
494
abc8a657a8dd warn user if ms style codec tag is used
michael
parents: 468
diff changeset
1315 for(i=0; i<s->nb_streams; i++){
abc8a657a8dd warn user if ms style codec tag is used
michael
parents: 468
diff changeset
1316 AVCodecContext *c= &s->streams[i]->codec;
abc8a657a8dd warn user if ms style codec tag is used
michael
parents: 468
diff changeset
1317
abc8a657a8dd warn user if ms style codec tag is used
michael
parents: 468
diff changeset
1318 if (c->codec_type == CODEC_TYPE_VIDEO){
abc8a657a8dd warn user if ms style codec tag is used
michael
parents: 468
diff changeset
1319 if (!codec_get_tag(codec_movvideo_tags, c->codec_id)){
abc8a657a8dd warn user if ms style codec tag is used
michael
parents: 468
diff changeset
1320 if(!codec_get_tag(codec_bmp_tags, c->codec_id))
abc8a657a8dd warn user if ms style codec tag is used
michael
parents: 468
diff changeset
1321 return -1;
abc8a657a8dd warn user if ms style codec tag is used
michael
parents: 468
diff changeset
1322 else
abc8a657a8dd warn user if ms style codec tag is used
michael
parents: 468
diff changeset
1323 av_log(s, AV_LOG_INFO, "Warning, using MS style video codec tag, the file may be unplayable!\n");
abc8a657a8dd warn user if ms style codec tag is used
michael
parents: 468
diff changeset
1324 }
abc8a657a8dd warn user if ms style codec tag is used
michael
parents: 468
diff changeset
1325 }else if(c->codec_type == CODEC_TYPE_AUDIO){
abc8a657a8dd warn user if ms style codec tag is used
michael
parents: 468
diff changeset
1326 if (!codec_get_tag(codec_movaudio_tags, c->codec_id)){
abc8a657a8dd warn user if ms style codec tag is used
michael
parents: 468
diff changeset
1327 if(!codec_get_tag(codec_wav_tags, c->codec_id))
abc8a657a8dd warn user if ms style codec tag is used
michael
parents: 468
diff changeset
1328 return -1;
abc8a657a8dd warn user if ms style codec tag is used
michael
parents: 468
diff changeset
1329 else
abc8a657a8dd warn user if ms style codec tag is used
michael
parents: 468
diff changeset
1330 av_log(s, AV_LOG_INFO, "Warning, using MS style audio codec tag, the file may be unplayable!\n");
abc8a657a8dd warn user if ms style codec tag is used
michael
parents: 468
diff changeset
1331 }
abc8a657a8dd warn user if ms style codec tag is used
michael
parents: 468
diff changeset
1332 }
abc8a657a8dd warn user if ms style codec tag is used
michael
parents: 468
diff changeset
1333 }
abc8a657a8dd warn user if ms style codec tag is used
michael
parents: 468
diff changeset
1334
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1335 /* Default mode == MP4 */
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1336 mov->mode = MODE_MP4;
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1337
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1338 if (s->oformat != NULL) {
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1339 if (!strcmp("3gp", s->oformat->name)) mov->mode = MODE_3GP;
677
6d6a11ba402a quick patch for adding 3g2 support to ffmpeg (muxer and demuxer). No movie fragment support yet patch by (tjraivio cc.hut fi)
michael
parents: 676
diff changeset
1340 else if (!strcmp("3g2", s->oformat->name)) mov->mode = MODE_3G2;
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1341 else if (!strcmp("mov", s->oformat->name)) mov->mode = MODE_MOV;
659
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1342 else if (!strcmp("psp", s->oformat->name)) mov->mode = MODE_PSP;
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1343
677
6d6a11ba402a quick patch for adding 3g2 support to ffmpeg (muxer and demuxer). No movie fragment support yet patch by (tjraivio cc.hut fi)
michael
parents: 676
diff changeset
1344 if ( mov->mode == MODE_3GP || mov->mode == MODE_3G2 ||
6d6a11ba402a quick patch for adding 3g2 support to ffmpeg (muxer and demuxer). No movie fragment support yet patch by (tjraivio cc.hut fi)
michael
parents: 676
diff changeset
1345 mov->mode == MODE_MP4 || mov->mode == MODE_PSP )
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1346 mov_write_ftyp_tag(pb,s);
665
47d5b20c9aba fix segfault by matthieu castet <castet DOT matthieu AT free DOT fr>
mmu_man
parents: 664
diff changeset
1347 if ( mov->mode == MODE_PSP ) {
47d5b20c9aba fix segfault by matthieu castet <castet DOT matthieu AT free DOT fr>
mmu_man
parents: 664
diff changeset
1348 if ( s->nb_streams != 2 ) {
47d5b20c9aba fix segfault by matthieu castet <castet DOT matthieu AT free DOT fr>
mmu_man
parents: 664
diff changeset
1349 av_log(s, AV_LOG_ERROR, "PSP mode need one video and one audio stream\n");
47d5b20c9aba fix segfault by matthieu castet <castet DOT matthieu AT free DOT fr>
mmu_man
parents: 664
diff changeset
1350 return -1;
47d5b20c9aba fix segfault by matthieu castet <castet DOT matthieu AT free DOT fr>
mmu_man
parents: 664
diff changeset
1351 }
659
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1352 mov_write_uuidprof_tag(pb,s);
665
47d5b20c9aba fix segfault by matthieu castet <castet DOT matthieu AT free DOT fr>
mmu_man
parents: 664
diff changeset
1353 }
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1354 }
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1355
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1356 for (i=0; i<MAX_STREAMS; i++) {
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1357 mov->tracks[i].mode = mov->mode;
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
1358 }
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
1359
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1360 put_flush_packet(pb);
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1361
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1362 return 0;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1363 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1364
468
60f897e8dd2d pass AVPacket into av_write_frame()
michael
parents: 441
diff changeset
1365 static int mov_write_packet(AVFormatContext *s, AVPacket *pkt)
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1366 {
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1367 MOVContext *mov = s->priv_data;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1368 ByteIOContext *pb = &s->pb;
468
60f897e8dd2d pass AVPacket into av_write_frame()
michael
parents: 441
diff changeset
1369 AVCodecContext *enc = &s->streams[pkt->stream_index]->codec;
60f897e8dd2d pass AVPacket into av_write_frame()
michael
parents: 441
diff changeset
1370 MOVTrack* trk = &mov->tracks[pkt->stream_index];
202
d755254e8797 naughty, forbidden variable declarations
tmmm
parents: 201
diff changeset
1371 int cl, id;
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1372 unsigned int samplesInChunk = 0;
468
60f897e8dd2d pass AVPacket into av_write_frame()
michael
parents: 441
diff changeset
1373 int size= pkt->size;
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1374
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1375 if (url_is_streamed(&s->pb)) return 0; /* Can't handle that */
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1376 if (!size) return 0; /* Discard 0 sized packets */
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1377
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1378 if (enc->codec_type == CODEC_TYPE_VIDEO ) {
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1379 samplesInChunk = 1;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1380 }
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1381 else if (enc->codec_type == CODEC_TYPE_AUDIO ) {
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1382 if( enc->codec_id == CODEC_ID_AMR_NB) {
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
1383 /* We must find out how many AMR blocks there are in one packet */
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1384 static uint16_t packed_size[16] =
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1385 {13, 14, 16, 18, 20, 21, 27, 32, 6, 0, 0, 0, 0, 0, 0, 0};
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1386 int len = 0;
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1387
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1388 while (len < size && samplesInChunk < 100) {
468
60f897e8dd2d pass AVPacket into av_write_frame()
michael
parents: 441
diff changeset
1389 len += packed_size[(pkt->data[len] >> 3) & 0x0F];
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1390 samplesInChunk++;
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1391 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1392 }
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1393 else if(enc->codec_id == CODEC_ID_PCM_ALAW) {
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1394 samplesInChunk = size/enc->channels;
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1395 }
399
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
1396 else if(enc->codec_id == CODEC_ID_PCM_S16BE || enc->codec_id == CODEC_ID_PCM_S16LE) {
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
1397 samplesInChunk = size/(2*enc->channels);
6ab5454567b6 * making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents: 397
diff changeset
1398 }
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1399 else {
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1400 samplesInChunk = 1;
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1401 }
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1402 }
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1403
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1404 if ((enc->codec_id == CODEC_ID_MPEG4 || enc->codec_id == CODEC_ID_AAC)
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1405 && trk->vosLen == 0) {
424
dc59cb26955c support for -timestamp
alex
parents: 422
diff changeset
1406 // assert(enc->extradata_size);
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1407
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1408 trk->vosLen = enc->extradata_size;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1409 trk->vosData = av_malloc(trk->vosLen);
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1410 memcpy(trk->vosData, enc->extradata, trk->vosLen);
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1411 }
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1412
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1413 cl = trk->entry / MOV_INDEX_CLUSTER_SIZE;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1414 id = trk->entry % MOV_INDEX_CLUSTER_SIZE;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1415
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1416 if (trk->ents_allocated <= trk->entry) {
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1417 trk->cluster = av_realloc(trk->cluster, (cl+1)*sizeof(void*));
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1418 if (!trk->cluster)
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1419 return -1;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1420 trk->cluster[cl] = av_malloc(MOV_INDEX_CLUSTER_SIZE*sizeof(MOVIentry));
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1421 if (!trk->cluster[cl])
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1422 return -1;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1423 trk->ents_allocated += MOV_INDEX_CLUSTER_SIZE;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1424 }
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1425 if (mov->mdat_written == 0) {
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1426 mov_write_mdat_tag(pb, mov);
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1427 mov->mdat_written = 1;
711
03157dc4ac6f fix time stored in mov
michael
parents: 710
diff changeset
1428 mov->time = s->timestamp + 0x7C25B080; //1970 based -> 1904 based
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1429 }
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1430
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1431 trk->cluster[cl][id].pos = url_ftell(pb);
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1432 trk->cluster[cl][id].samplesInChunk = samplesInChunk;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1433 trk->cluster[cl][id].size = size;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1434 trk->cluster[cl][id].entries = samplesInChunk;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1435 if(enc->codec_type == CODEC_TYPE_VIDEO) {
468
60f897e8dd2d pass AVPacket into av_write_frame()
michael
parents: 441
diff changeset
1436 trk->cluster[cl][id].key_frame = !!(pkt->flags & PKT_FLAG_KEY);
60f897e8dd2d pass AVPacket into av_write_frame()
michael
parents: 441
diff changeset
1437 if(trk->cluster[cl][id].key_frame)
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
1438 trk->hasKeyframes = 1;
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1439 }
298
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1440 trk->enc = enc;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1441 trk->entry++;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1442 trk->sampleCount += samplesInChunk;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1443 trk->mdat_size += size;
0b2eed7b1210 movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 286
diff changeset
1444
468
60f897e8dd2d pass AVPacket into av_write_frame()
michael
parents: 441
diff changeset
1445 put_buffer(pb, pkt->data, size);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1446
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1447 put_flush_packet(pb);
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1448 return 0;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1449 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1450
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1451 static int mov_write_trailer(AVFormatContext *s)
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1452 {
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1453 MOVContext *mov = s->priv_data;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1454 ByteIOContext *pb = &s->pb;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1455 int res = 0;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1456 int i, j;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1457
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1458 offset_t moov_pos = url_ftell(pb);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1459
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1460 /* Write size of mdat tag */
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1461 for (i=0, j=0; i<MAX_STREAMS; i++) {
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1462 if(mov->tracks[i].ents_allocated > 0) {
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1463 j += mov->tracks[i].mdat_size;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1464 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1465 }
259
e091218eccd2 mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents: 241
diff changeset
1466 url_fseek(pb, mov->mdat_pos, SEEK_SET);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1467 put_be32(pb, j+8);
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1468 url_fseek(pb, moov_pos, SEEK_SET);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1469
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1470 mov_write_moov_tag(pb, mov, s);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1471
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1472 for (i=0; i<MAX_STREAMS; i++) {
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1473 for (j=0; j<mov->tracks[i].ents_allocated/MOV_INDEX_CLUSTER_SIZE; j++) {
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1474 av_free(mov->tracks[i].cluster[j]);
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1475 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1476 av_free(mov->tracks[i].cluster);
342
0c1b489c96bf memleak patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 299
diff changeset
1477 if( mov->tracks[i].vosLen ) av_free( mov->tracks[i].vosData );
0c1b489c96bf memleak patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 299
diff changeset
1478
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1479 mov->tracks[i].cluster = NULL;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1480 mov->tracks[i].ents_allocated = mov->tracks[i].entry = 0;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1481 }
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1482
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1483 put_flush_packet(pb);
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1484
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1485 return res;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1486 }
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1487
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1488 static AVOutputFormat mov_oformat = {
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1489 "mov",
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1490 "mov format",
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1491 NULL,
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1492 "mov",
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1493 sizeof(MOVContext),
365
4ae9fac22a5d AAC support in mov, correct aspect ratio support and user data support patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents: 342
diff changeset
1494 CODEC_ID_AAC,
239
48c3134e93c3 theres no SVQ1 encoder -> it cant be default
michaelni
parents: 238
diff changeset
1495 CODEC_ID_MPEG4,
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1496 mov_write_header,
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1497 mov_write_packet,
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1498 mov_write_trailer,
715
e214703e4b76 30_clean_up_global_header_flag.patch by (Calcium | calcium nurs or jp)
michael
parents: 711
diff changeset
1499 .flags = AVFMT_GLOBALHEADER,
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1500 };
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1501
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1502 static AVOutputFormat _3gp_oformat = {
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1503 "3gp",
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1504 "3gp format",
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1505 NULL,
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1506 "3gp",
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1507 sizeof(MOVContext),
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1508 CODEC_ID_AMR_NB,
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1509 CODEC_ID_H263,
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1510 mov_write_header,
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1511 mov_write_packet,
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1512 mov_write_trailer,
715
e214703e4b76 30_clean_up_global_header_flag.patch by (Calcium | calcium nurs or jp)
michael
parents: 711
diff changeset
1513 .flags = AVFMT_GLOBALHEADER,
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1514 };
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1515
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1516 static AVOutputFormat mp4_oformat = {
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1517 "mp4",
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1518 "mp4 format",
286
eccf0c3e3289 Using the extension m4a for audio only MPEG-4 files is increasingly
michael
parents: 259
diff changeset
1519 "application/mp4",
eccf0c3e3289 Using the extension m4a for audio only MPEG-4 files is increasingly
michael
parents: 259
diff changeset
1520 "mp4,m4a",
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1521 sizeof(MOVContext),
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1522 CODEC_ID_AAC,
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1523 CODEC_ID_MPEG4,
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1524 mov_write_header,
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1525 mov_write_packet,
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1526 mov_write_trailer,
715
e214703e4b76 30_clean_up_global_header_flag.patch by (Calcium | calcium nurs or jp)
michael
parents: 711
diff changeset
1527 .flags = AVFMT_GLOBALHEADER,
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1528 };
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1529
659
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1530 static AVOutputFormat psp_oformat = {
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1531 "psp",
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1532 "psp mp4 format",
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1533 NULL,
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1534 "mp4,psp",
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1535 sizeof(MOVContext),
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1536 CODEC_ID_AAC,
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1537 CODEC_ID_MPEG4,
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1538 mov_write_header,
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1539 mov_write_packet,
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1540 mov_write_trailer,
721
e7f1b5842878 fix psp muxing (probably this fix is wrong but its better then nothing)
michael
parents: 715
diff changeset
1541 // .flags = AVFMT_GLOBALHEADER,
659
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1542 };
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1543
677
6d6a11ba402a quick patch for adding 3g2 support to ffmpeg (muxer and demuxer). No movie fragment support yet patch by (tjraivio cc.hut fi)
michael
parents: 676
diff changeset
1544 static AVOutputFormat _3g2_oformat = {
6d6a11ba402a quick patch for adding 3g2 support to ffmpeg (muxer and demuxer). No movie fragment support yet patch by (tjraivio cc.hut fi)
michael
parents: 676
diff changeset
1545 "3g2",
6d6a11ba402a quick patch for adding 3g2 support to ffmpeg (muxer and demuxer). No movie fragment support yet patch by (tjraivio cc.hut fi)
michael
parents: 676
diff changeset
1546 "3gp2 format",
6d6a11ba402a quick patch for adding 3g2 support to ffmpeg (muxer and demuxer). No movie fragment support yet patch by (tjraivio cc.hut fi)
michael
parents: 676
diff changeset
1547 NULL,
6d6a11ba402a quick patch for adding 3g2 support to ffmpeg (muxer and demuxer). No movie fragment support yet patch by (tjraivio cc.hut fi)
michael
parents: 676
diff changeset
1548 "3g2",
6d6a11ba402a quick patch for adding 3g2 support to ffmpeg (muxer and demuxer). No movie fragment support yet patch by (tjraivio cc.hut fi)
michael
parents: 676
diff changeset
1549 sizeof(MOVContext),
6d6a11ba402a quick patch for adding 3g2 support to ffmpeg (muxer and demuxer). No movie fragment support yet patch by (tjraivio cc.hut fi)
michael
parents: 676
diff changeset
1550 CODEC_ID_AMR_NB,
6d6a11ba402a quick patch for adding 3g2 support to ffmpeg (muxer and demuxer). No movie fragment support yet patch by (tjraivio cc.hut fi)
michael
parents: 676
diff changeset
1551 CODEC_ID_H263,
6d6a11ba402a quick patch for adding 3g2 support to ffmpeg (muxer and demuxer). No movie fragment support yet patch by (tjraivio cc.hut fi)
michael
parents: 676
diff changeset
1552 mov_write_header,
6d6a11ba402a quick patch for adding 3g2 support to ffmpeg (muxer and demuxer). No movie fragment support yet patch by (tjraivio cc.hut fi)
michael
parents: 676
diff changeset
1553 mov_write_packet,
6d6a11ba402a quick patch for adding 3g2 support to ffmpeg (muxer and demuxer). No movie fragment support yet patch by (tjraivio cc.hut fi)
michael
parents: 676
diff changeset
1554 mov_write_trailer,
715
e214703e4b76 30_clean_up_global_header_flag.patch by (Calcium | calcium nurs or jp)
michael
parents: 711
diff changeset
1555 .flags = AVFMT_GLOBALHEADER,
677
6d6a11ba402a quick patch for adding 3g2 support to ffmpeg (muxer and demuxer). No movie fragment support yet patch by (tjraivio cc.hut fi)
michael
parents: 676
diff changeset
1556 };
6d6a11ba402a quick patch for adding 3g2 support to ffmpeg (muxer and demuxer). No movie fragment support yet patch by (tjraivio cc.hut fi)
michael
parents: 676
diff changeset
1557
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1558 int movenc_init(void)
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1559 {
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1560 av_register_output_format(&mov_oformat);
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1561 av_register_output_format(&_3gp_oformat);
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1562 av_register_output_format(&mp4_oformat);
659
6d7c0e6d929e Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents: 657
diff changeset
1563 av_register_output_format(&psp_oformat);
677
6d6a11ba402a quick patch for adding 3g2 support to ffmpeg (muxer and demuxer). No movie fragment support yet patch by (tjraivio cc.hut fi)
michael
parents: 676
diff changeset
1564 av_register_output_format(&_3g2_oformat);
201
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1565 return 0;
85def00971c3 mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff changeset
1566 }