Mercurial > libavformat.hg
annotate movenc.c @ 1236:a2cc205d79f1 libavformat
mp4, 3gp field is reserved and value is 2
author | bcoudurier |
---|---|
date | Mon, 07 Aug 2006 14:11:17 +0000 |
parents | d88550cf8afe |
children | fbe88f238d0d |
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 |
896
edbe5c3717f9
Update licensing information: The FSF changed postal address.
diego
parents:
890
diff
changeset
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
201
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" |
1172
6a5e58d2114b
move common stuff from avienc.c and wav.c to new file riff.c
mru
parents:
1169
diff
changeset
|
21 #include "riff.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" |
1216
fec0a3d5408f
move common code from mov.c and movenc.c to isom.c
bcoudurier
parents:
1172
diff
changeset
|
23 #include "isom.h" |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
24 |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
25 #undef NDEBUG |
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
26 #include <assert.h> |
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
27 |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
28 #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
|
29 #define globalTimescale 1000 |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
30 |
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
|
31 #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
|
32 #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
|
33 #define MODE_3GP 2 |
885 | 34 #define MODE_PSP 3 // example working PSP command line: |
659
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
35 // 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
|
36 #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
|
37 |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
38 typedef struct MOVIentry { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
39 unsigned int flags, size; |
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
40 uint64_t pos; |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
41 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
|
42 char key_frame; |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
43 unsigned int entries; |
971
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
44 int64_t cts; |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
45 } MOVIentry; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
46 |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
47 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
|
48 int mode; |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
49 int entry; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
50 long timescale; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
51 long time; |
1037 | 52 int64_t trackDuration; |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
53 long sampleCount; |
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
54 long sampleDuration; |
1147 | 55 long sampleSize; |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
56 int hasKeyframes; |
971
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
57 int hasBframes; |
890
1e49bfea0ffb
finally found what those >138 codes were... crappy compressed 5bit ascii. this gets them correctly, and adds setting track lang in movenc too.
mmu_man
parents:
887
diff
changeset
|
58 int language; |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
59 int trackID; |
1080 | 60 int tag; |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
61 AVCodecContext *enc; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
62 |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
63 int vosLen; |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
64 uint8_t *vosData; |
1129 | 65 MOVIentry *cluster; |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
66 } MOVTrack; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
67 |
659
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
68 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
|
69 int mode; |
1037 | 70 int64_t time; |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
71 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
|
72 offset_t mdat_pos; |
1080 | 73 uint64_t mdat_size; |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
74 long timescale; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
75 MOVTrack tracks[MAX_STREAMS]; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
76 } MOVContext; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
77 |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
78 //FIXME supprt 64bit varaint with wide placeholders |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
79 static offset_t updateSize (ByteIOContext *pb, offset_t pos) |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
80 { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
81 offset_t curpos = url_ftell(pb); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
82 url_fseek(pb, pos, SEEK_SET); |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
83 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
|
84 url_fseek(pb, curpos, SEEK_SET); |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
85 |
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
86 return curpos - pos; |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
87 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
88 |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
89 /* Chunk offset atom */ |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
90 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
|
91 { |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
92 int i; |
910 | 93 int mode64 = 0; // use 32 bit size variant if possible |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
94 offset_t pos = url_ftell(pb); |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
95 put_be32(pb, 0); /* size */ |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
96 if (pos > UINT32_MAX) { |
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
97 mode64 = 1; |
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
98 put_tag(pb, "co64"); |
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
99 } else |
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
100 put_tag(pb, "stco"); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
101 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
|
102 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
|
103 for (i=0; i<track->entry; i++) { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
104 if(mode64 == 1) |
1129 | 105 put_be64(pb, track->cluster[i].pos); |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
106 else |
1129 | 107 put_be32(pb, track->cluster[i].pos); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
108 } |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
109 return updateSize (pb, pos); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
110 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
111 |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
112 /* Sample size atom */ |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
113 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
|
114 { |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
115 int equalChunks = 1; |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
116 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
|
117 |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
118 offset_t pos = url_ftell(pb); |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
119 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
|
120 put_tag(pb, "stsz"); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
121 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
|
122 |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
123 for (i=0; i<track->entry; i++) { |
1129 | 124 tst = track->cluster[i].size/track->cluster[i].entries; |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
125 if(oldtst != -1 && tst != oldtst) { |
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
126 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
|
127 } |
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
128 oldtst = tst; |
1129 | 129 entries += track->cluster[i].entries; |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
130 } |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
131 if (equalChunks) { |
1129 | 132 int sSize = track->cluster[0].size/track->cluster[0].entries; |
885 | 133 put_be32(pb, sSize); // sample size |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
134 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
|
135 } |
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
136 else { |
885 | 137 put_be32(pb, 0); // sample size |
138 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
|
139 for (i=0; i<track->entry; i++) { |
1129 | 140 for ( j=0; j<track->cluster[i].entries; j++) { |
141 put_be32(pb, track->cluster[i].size / | |
142 track->cluster[i].entries); | |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
143 } |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
144 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
145 } |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
146 return updateSize (pb, pos); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
147 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
148 |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
149 /* Sample to chunk atom */ |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
150 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
|
151 { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
152 int index = 0, oldval = -1, i; |
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
153 offset_t entryPos, curpos; |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
154 |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
155 offset_t pos = url_ftell(pb); |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
156 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
|
157 put_tag(pb, "stsc"); |
885 | 158 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
|
159 entryPos = url_ftell(pb); |
885 | 160 put_be32(pb, track->entry); // 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
|
161 for (i=0; i<track->entry; i++) { |
1129 | 162 if(oldval != track->cluster[i].samplesInChunk) |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
163 { |
885 | 164 put_be32(pb, i+1); // first chunk |
1129 | 165 put_be32(pb, track->cluster[i].samplesInChunk); // samples per chunk |
885 | 166 put_be32(pb, 0x1); // sample description index |
1129 | 167 oldval = track->cluster[i].samplesInChunk; |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
168 index++; |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
169 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
170 } |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
171 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
|
172 url_fseek(pb, entryPos, SEEK_SET); |
885 | 173 put_be32(pb, index); // rewrite size |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
174 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
|
175 |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
176 return updateSize (pb, pos); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
177 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
178 |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
179 /* 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
|
180 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
|
181 { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
182 offset_t curpos, entryPos; |
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
183 int i, index = 0; |
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
184 offset_t pos = url_ftell(pb); |
885 | 185 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
|
186 put_tag(pb, "stss"); |
885 | 187 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
|
188 entryPos = url_ftell(pb); |
885 | 189 put_be32(pb, track->entry); // 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
|
190 for (i=0; i<track->entry; i++) { |
1129 | 191 if(track->cluster[i].key_frame == 1) { |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
192 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
|
193 index++; |
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
194 } |
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
195 } |
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
196 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
|
197 url_fseek(pb, entryPos, SEEK_SET); |
885 | 198 put_be32(pb, index); // rewrite size |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
199 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
|
200 return updateSize (pb, pos); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
201 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
202 |
1152
c7cf3d1f9bd7
simplify and write correct values conforming to specs
bcoudurier
parents:
1151
diff
changeset
|
203 static int mov_write_amr_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
|
204 { |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
205 put_be32(pb, 0x11); /* size */ |
1152
c7cf3d1f9bd7
simplify and write correct values conforming to specs
bcoudurier
parents:
1151
diff
changeset
|
206 if (track->mode == MODE_MOV) put_tag(pb, "samr"); |
c7cf3d1f9bd7
simplify and write correct values conforming to specs
bcoudurier
parents:
1151
diff
changeset
|
207 else put_tag(pb, "damr"); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
208 put_tag(pb, "FFMP"); |
1152
c7cf3d1f9bd7
simplify and write correct values conforming to specs
bcoudurier
parents:
1151
diff
changeset
|
209 put_byte(pb, 0); /* decoder version */ |
1083 | 210 |
1153 | 211 put_be16(pb, 0x81FF); /* Mode set (all modes for AMR_NB) */ |
1152
c7cf3d1f9bd7
simplify and write correct values conforming to specs
bcoudurier
parents:
1151
diff
changeset
|
212 put_byte(pb, 0x00); /* Mode change period (no restriction) */ |
c7cf3d1f9bd7
simplify and write correct values conforming to specs
bcoudurier
parents:
1151
diff
changeset
|
213 put_byte(pb, 0x01); /* Frames per sample */ |
1083 | 214 return 0x11; |
215 } | |
216 | |
1082 | 217 static int mov_write_enda_tag(ByteIOContext *pb) |
218 { | |
219 put_be32(pb, 10); | |
220 put_tag(pb, "enda"); | |
221 put_be16(pb, 1); /* little endian */ | |
222 return 10; | |
223 } | |
224 | |
1080 | 225 static unsigned int descrLength(unsigned int len) |
226 { | |
1081 | 227 int i; |
228 for(i=1; len>>(7*i); i++); | |
229 return len + 1 + i; | |
1080 | 230 } |
231 | |
1081 | 232 static void putDescr(ByteIOContext *pb, int tag, unsigned int size) |
1080 | 233 { |
1081 | 234 int i= descrLength(size) - size - 2; |
235 put_byte(pb, tag); | |
236 for(; i>0; i--) | |
237 put_byte(pb, (size>>(7*i)) | 0x80); | |
238 put_byte(pb, size & 0x7F); | |
1080 | 239 } |
240 | |
241 static int mov_write_esds_tag(ByteIOContext *pb, MOVTrack* track) // Basic | |
242 { | |
243 offset_t pos = url_ftell(pb); | |
1082 | 244 int decoderSpecificInfoLen = track->vosLen ? descrLength(track->vosLen):0; |
1080 | 245 |
246 put_be32(pb, 0); // size | |
247 put_tag(pb, "esds"); | |
248 put_be32(pb, 0); // Version | |
249 | |
250 // ES descriptor | |
251 putDescr(pb, 0x03, 3 + descrLength(13 + decoderSpecificInfoLen) + | |
252 descrLength(1)); | |
253 put_be16(pb, track->trackID); | |
254 put_byte(pb, 0x00); // flags (= no flags) | |
255 | |
256 // DecoderConfig descriptor | |
257 putDescr(pb, 0x04, 13 + decoderSpecificInfoLen); | |
258 | |
259 // Object type indication | |
260 put_byte(pb, codec_get_tag(ff_mov_obj_type, track->enc->codec_id)); | |
261 | |
262 // the following fields is made of 6 bits to identify the streamtype (4 for video, 5 for audio) | |
263 // plus 1 bit to indicate upstream and 1 bit set to 1 (reserved) | |
264 if(track->enc->codec_type == CODEC_TYPE_AUDIO) | |
265 put_byte(pb, 0x15); // flags (= Audiostream) | |
266 else | |
267 put_byte(pb, 0x11); // flags (= Visualstream) | |
268 | |
269 put_byte(pb, track->enc->rc_buffer_size>>(3+16)); // Buffersize DB (24 bits) | |
270 put_be16(pb, (track->enc->rc_buffer_size>>3)&0xFFFF); // Buffersize DB | |
271 | |
272 put_be32(pb, FFMAX(track->enc->bit_rate, track->enc->rc_max_rate)); // maxbitrate (FIXME should be max rate in any 1 sec window) | |
273 if(track->enc->rc_max_rate != track->enc->rc_min_rate || track->enc->rc_min_rate==0) | |
274 put_be32(pb, 0); // vbr | |
275 else | |
276 put_be32(pb, track->enc->rc_max_rate); // avg bitrate | |
277 | |
278 if (track->vosLen) | |
279 { | |
280 // DecoderSpecific info descriptor | |
281 putDescr(pb, 0x05, track->vosLen); | |
282 put_buffer(pb, track->vosData, track->vosLen); | |
283 } | |
284 | |
285 | |
286 // SL descriptor | |
287 putDescr(pb, 0x06, 1); | |
288 put_byte(pb, 0x02); | |
289 return updateSize (pb, pos); | |
290 } | |
291 | |
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
|
292 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
|
293 { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
294 offset_t pos = url_ftell(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
|
295 |
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
|
296 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
|
297 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
|
298 |
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 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
|
300 put_tag(pb, "frma"); |
1082 | 301 put_le32(pb, track->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
|
302 |
1082 | 303 if (track->enc->codec_id == CODEC_ID_AAC) { |
1125 | 304 /* useless atom needed by mplayer, ipod, not needed by quicktime */ |
305 put_be32(pb, 12); /* size */ | |
306 put_tag(pb, "mp4a"); | |
307 put_be32(pb, 0); | |
1082 | 308 mov_write_esds_tag(pb, track); |
309 } else if (track->enc->codec_id == CODEC_ID_PCM_S24LE || | |
310 track->enc->codec_id == CODEC_ID_PCM_S32LE) { | |
311 mov_write_enda_tag(pb); | |
1083 | 312 } else if (track->enc->codec_id == CODEC_ID_AMR_NB) { |
1152
c7cf3d1f9bd7
simplify and write correct values conforming to specs
bcoudurier
parents:
1151
diff
changeset
|
313 mov_write_amr_tag(pb, track); |
1082 | 314 } |
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
|
315 |
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
|
316 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
|
317 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
|
318 |
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
|
319 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
|
320 } |
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
|
321 |
791
f961db8ea65d
This trivial patch adds "avc1" as fourcc for h264 in mp4, which makes it
michael
parents:
779
diff
changeset
|
322 static const CodecTag codec_movaudio_tags[] = { |
422 | 323 { CODEC_ID_PCM_MULAW, MKTAG('u', 'l', 'a', 'w') }, |
324 { CODEC_ID_PCM_ALAW, MKTAG('a', 'l', 'a', 'w') }, | |
325 { CODEC_ID_ADPCM_IMA_QT, MKTAG('i', 'm', 'a', '4') }, | |
326 { CODEC_ID_MACE3, MKTAG('M', 'A', 'C', '3') }, | |
327 { CODEC_ID_MACE6, MKTAG('M', 'A', 'C', '6') }, | |
328 { CODEC_ID_AAC, MKTAG('m', 'p', '4', 'a') }, | |
329 { CODEC_ID_AMR_NB, MKTAG('s', 'a', 'm', 'r') }, | |
811
e446442b0851
AMR-WB for 3GPP patch by (Jan Kratochvil - kratochvil) / bugreport #1187101
michael
parents:
791
diff
changeset
|
330 { CODEC_ID_AMR_WB, MKTAG('s', 'a', 'w', 'b') }, |
422 | 331 { CODEC_ID_PCM_S16BE, MKTAG('t', 'w', 'o', 's') }, |
332 { CODEC_ID_PCM_S16LE, MKTAG('s', 'o', 'w', 't') }, | |
1082 | 333 { CODEC_ID_PCM_S24BE, MKTAG('i', 'n', '2', '4') }, |
334 { CODEC_ID_PCM_S24LE, MKTAG('i', 'n', '2', '4') }, | |
335 { CODEC_ID_PCM_S32BE, MKTAG('i', 'n', '3', '2') }, | |
336 { CODEC_ID_PCM_S32LE, MKTAG('i', 'n', '3', '2') }, | |
422 | 337 { CODEC_ID_MP3, MKTAG('.', 'm', 'p', '3') }, |
1000 | 338 { CODEC_ID_NONE, 0 }, |
422 | 339 }; |
340 | |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
341 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
|
342 { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
343 offset_t pos = url_ftell(pb); |
1234 | 344 int vbr= track->mode == MODE_MOV && |
345 (track->enc->codec_id == CODEC_ID_AAC || | |
346 track->enc->codec_id == CODEC_ID_MP3 || | |
347 track->enc->codec_id == CODEC_ID_AMR_NB); | |
348 int version = vbr || | |
349 track->enc->codec_id == CODEC_ID_PCM_S32LE || | |
350 track->enc->codec_id == CODEC_ID_PCM_S24LE; | |
885 | 351 |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
352 put_be32(pb, 0); /* size */ |
1080 | 353 put_le32(pb, track->tag); // store it byteswapped |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
354 put_be32(pb, 0); /* Reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
355 put_be16(pb, 0); /* Reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
356 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
|
357 |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
358 /* SoundDescription */ |
1082 | 359 put_be16(pb, version); /* Version */ |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
360 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
|
361 put_be32(pb, 0); /* Reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
362 |
1236 | 363 put_be16(pb, track->mode == MODE_MOV ? track->enc->channels : 2); /* Number of channels */ |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
364 /* 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
|
365 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
|
366 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
|
367 |
1235 | 368 put_be16(pb, vbr ? 0xfffe : 0); /* compression ID */ |
399
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
369 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
|
370 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
|
371 put_be16(pb, 0); /* Reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
372 |
1147 | 373 if(version == 1) { /* SoundDescription V1 extended info */ |
1150
c8edab114cc3
vbr requires version=1 and samplesize=0 per QT spec
michael
parents:
1147
diff
changeset
|
374 if (vbr) |
c8edab114cc3
vbr requires version=1 and samplesize=0 per QT spec
michael
parents:
1147
diff
changeset
|
375 track->sampleSize = 0; |
1147 | 376 put_be32(pb, track->enc->frame_size); /* Samples per packet */ |
1150
c8edab114cc3
vbr requires version=1 and samplesize=0 per QT spec
michael
parents:
1147
diff
changeset
|
377 put_be32(pb, track->sampleSize / track->enc->channels); /* Bytes per packet */ |
1147 | 378 put_be32(pb, track->sampleSize); /* Bytes per frame */ |
1125 | 379 put_be32(pb, 2); /* Bytes per sample */ |
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
|
380 } |
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
|
381 |
1084 | 382 if(track->mode == MODE_MOV && |
383 (track->enc->codec_id == CODEC_ID_AAC || | |
384 track->enc->codec_id == CODEC_ID_AMR_NB || | |
385 track->enc->codec_id == CODEC_ID_PCM_S24LE || | |
386 track->enc->codec_id == CODEC_ID_PCM_S32LE)) | |
1083 | 387 mov_write_wave_tag(pb, track); |
388 else if(track->enc->codec_id == CODEC_ID_AAC) | |
389 mov_write_esds_tag(pb, track); | |
390 else if(track->enc->codec_id == CODEC_ID_AMR_NB) | |
1152
c7cf3d1f9bd7
simplify and write correct values conforming to specs
bcoudurier
parents:
1151
diff
changeset
|
391 mov_write_amr_tag(pb, track); |
1083 | 392 |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
393 return updateSize (pb, pos); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
394 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
395 |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
396 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
|
397 { |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
398 put_be32(pb, 0xf); /* size */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
399 put_tag(pb, "d263"); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
400 put_tag(pb, "FFMP"); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
401 put_be16(pb, 0x0a); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
402 put_byte(pb, 0); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
403 return 0xf; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
404 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
405 |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
406 /* 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
|
407 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
|
408 { |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
409 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
|
410 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
|
411 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
|
412 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
|
413 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
|
414 put_be32(pb, 0xc0000000); |
885 | 415 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
|
416 return 0x15; |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
417 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
418 |
1006
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
419 static uint8_t *avc_find_startcode( uint8_t *p, uint8_t *end ) |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
420 { |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
421 uint8_t *a = p + 4 - ((int)p & 3); |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
422 |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
423 for( end -= 3; p < a && p < end; p++ ) { |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
424 if( p[0] == 0 && p[1] == 0 && p[2] == 1 ) |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
425 return p; |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
426 } |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
427 |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
428 for( end -= 3; p < end; p += 4 ) { |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
429 uint32_t x = *(uint32_t*)p; |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
430 // if( (x - 0x01000100) & (~x) & 0x80008000 ) // little endian |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
431 // if( (x - 0x00010001) & (~x) & 0x00800080 ) // big endian |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
432 if( (x - 0x01010101) & (~x) & 0x80808080 ) { // generic |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
433 if( p[1] == 0 ) { |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
434 if( p[0] == 0 && p[2] == 1 ) |
1088 | 435 return p-1; |
1006
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
436 if( p[2] == 0 && p[3] == 1 ) |
1088 | 437 return p; |
1006
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
438 } |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
439 if( p[3] == 0 ) { |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
440 if( p[2] == 0 && p[4] == 1 ) |
1088 | 441 return p+1; |
1006
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
442 if( p[4] == 0 && p[5] == 1 ) |
1088 | 443 return p+2; |
1006
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
444 } |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
445 } |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
446 } |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
447 |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
448 for( end += 3; p < end; p++ ) { |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
449 if( p[0] == 0 && p[1] == 0 && p[2] == 1 ) |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
450 return p; |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
451 } |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
452 |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
453 return end + 3; |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
454 } |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
455 |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
456 static void avc_parse_nal_units(uint8_t **buf, int *size) |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
457 { |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
458 ByteIOContext pb; |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
459 uint8_t *p = *buf; |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
460 uint8_t *end = p + *size; |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
461 uint8_t *nal_start, *nal_end; |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
462 |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
463 url_open_dyn_buf(&pb); |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
464 nal_start = avc_find_startcode(p, end); |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
465 while (nal_start < end) { |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
466 while(!*(nal_start++)); |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
467 nal_end = avc_find_startcode(nal_start, end); |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
468 put_be32(&pb, nal_end - nal_start); |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
469 put_buffer(&pb, nal_start, nal_end - nal_start); |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
470 nal_start = nal_end; |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
471 } |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
472 av_freep(buf); |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
473 *size = url_close_dyn_buf(&pb, buf); |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
474 } |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
475 |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
476 static int mov_write_avcc_tag(ByteIOContext *pb, MOVTrack *track) |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
477 { |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
478 offset_t pos = url_ftell(pb); |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
479 |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
480 put_be32(pb, 0); |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
481 put_tag(pb, "avcC"); |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
482 if (track->vosLen > 6) { |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
483 /* check for h264 start code */ |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
484 if (BE_32(track->vosData) == 0x00000001) { |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
485 uint8_t *buf, *end; |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
486 uint32_t sps_size=0, pps_size=0; |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
487 uint8_t *sps=0, *pps=0; |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
488 |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
489 avc_parse_nal_units(&track->vosData, &track->vosLen); |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
490 buf = track->vosData; |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
491 end = track->vosData + track->vosLen; |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
492 |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
493 /* look for sps and pps */ |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
494 while (buf < end) { |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
495 unsigned int size; |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
496 uint8_t nal_type; |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
497 size = BE_32(buf); |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
498 nal_type = buf[4] & 0x1f; |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
499 if (nal_type == 7) { /* SPS */ |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
500 sps = buf + 4; |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
501 sps_size = size; |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
502 } else if (nal_type == 8) { /* PPS */ |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
503 pps = buf + 4; |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
504 pps_size = size; |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
505 } |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
506 buf += size + 4; |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
507 } |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
508 assert(sps); |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
509 assert(pps); |
1056
4af4c74a4548
get avcC profile and level indication from sps (from handbrake)
bcoudurier
parents:
1055
diff
changeset
|
510 |
4af4c74a4548
get avcC profile and level indication from sps (from handbrake)
bcoudurier
parents:
1055
diff
changeset
|
511 put_byte(pb, 1); /* version */ |
4af4c74a4548
get avcC profile and level indication from sps (from handbrake)
bcoudurier
parents:
1055
diff
changeset
|
512 put_byte(pb, sps[1]); /* profile */ |
4af4c74a4548
get avcC profile and level indication from sps (from handbrake)
bcoudurier
parents:
1055
diff
changeset
|
513 put_byte(pb, sps[2]); /* profile compat */ |
4af4c74a4548
get avcC profile and level indication from sps (from handbrake)
bcoudurier
parents:
1055
diff
changeset
|
514 put_byte(pb, sps[3]); /* level */ |
4af4c74a4548
get avcC profile and level indication from sps (from handbrake)
bcoudurier
parents:
1055
diff
changeset
|
515 put_byte(pb, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */ |
4af4c74a4548
get avcC profile and level indication from sps (from handbrake)
bcoudurier
parents:
1055
diff
changeset
|
516 put_byte(pb, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */ |
4af4c74a4548
get avcC profile and level indication from sps (from handbrake)
bcoudurier
parents:
1055
diff
changeset
|
517 |
1006
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
518 put_be16(pb, sps_size); |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
519 put_buffer(pb, sps, sps_size); |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
520 put_byte(pb, 1); /* number of pps */ |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
521 put_be16(pb, pps_size); |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
522 put_buffer(pb, pps, pps_size); |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
523 } else { |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
524 put_buffer(pb, track->vosData, track->vosLen); |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
525 } |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
526 } |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
527 return updateSize(pb, pos); |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
528 } |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
529 |
791
f961db8ea65d
This trivial patch adds "avc1" as fourcc for h264 in mp4, which makes it
michael
parents:
779
diff
changeset
|
530 static const CodecTag codec_movvideo_tags[] = { |
422 | 531 { CODEC_ID_SVQ1, MKTAG('S', 'V', 'Q', '1') }, |
532 { CODEC_ID_SVQ3, MKTAG('S', 'V', 'Q', '3') }, | |
533 { CODEC_ID_MPEG4, MKTAG('m', 'p', '4', 'v') }, | |
534 { 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
|
535 { CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') }, |
1000 | 536 /* special handling in mov_find_video_codec_tag */ |
537 { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', ' ') }, /* DV NTSC */ | |
538 { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', 'p') }, /* DV PAL */ | |
539 { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'p', 'p') }, /* DVCPRO PAL */ | |
540 { CODEC_ID_DVVIDEO, MKTAG('d', 'v', '5', 'n') }, /* DVCPRO50 NTSC */ | |
541 { CODEC_ID_DVVIDEO, MKTAG('d', 'v', '5', 'p') }, /* DVCPRO50 PAL */ | |
542 { CODEC_ID_NONE, 0 }, | |
422 | 543 }; |
544 | |
1080 | 545 static int mov_find_video_codec_tag(AVFormatContext *s, MOVTrack *track) |
1000 | 546 { |
1080 | 547 int tag = track->enc->codec_tag; |
1000 | 548 if (!tag) { |
549 if (track->enc->codec_id == CODEC_ID_DVVIDEO) { | |
550 if (track->enc->height == 480) { /* NTSC */ | |
551 if (track->enc->pix_fmt == PIX_FMT_YUV422P) | |
552 tag = MKTAG('d', 'v', '5', 'n'); | |
553 else | |
554 tag = MKTAG('d', 'v', 'c', ' '); | |
555 } else { /* assume PAL */ | |
556 if (track->enc->pix_fmt == PIX_FMT_YUV422P) | |
557 tag = MKTAG('d', 'v', '5', 'p'); | |
558 else if (track->enc->pix_fmt == PIX_FMT_YUV420P) | |
1026 | 559 tag = MKTAG('d', 'v', 'c', 'p'); |
1000 | 560 else |
1026 | 561 tag = MKTAG('d', 'v', 'p', 'p'); |
1000 | 562 } |
563 } else { | |
564 tag = codec_get_tag(codec_movvideo_tags, track->enc->codec_id); | |
565 } | |
566 } | |
567 // if no mac fcc found, try with Microsoft tags | |
1080 | 568 if (!tag) { |
1000 | 569 tag = codec_get_tag(codec_bmp_tags, track->enc->codec_id); |
1080 | 570 if (tag) { |
571 av_log(s, AV_LOG_INFO, "Warning, using MS style video codec tag, the file may be unplayable!\n"); | |
572 } | |
573 } | |
574 assert(tag); | |
575 return tag; | |
576 } | |
577 | |
578 static int mov_find_audio_codec_tag(AVFormatContext *s, MOVTrack *track) | |
579 { | |
580 int tag = track->enc->codec_tag; | |
581 if (!tag) { | |
582 tag = codec_get_tag(codec_movaudio_tags, track->enc->codec_id); | |
583 } | |
584 // if no mac fcc found, try with Microsoft tags | |
585 if (!tag) { | |
586 int ms_tag = codec_get_tag(codec_wav_tags, track->enc->codec_id); | |
587 if (ms_tag) { | |
588 tag = MKTAG('m', 's', ((ms_tag >> 8) & 0xff), (ms_tag & 0xff)); | |
589 av_log(s, AV_LOG_INFO, "Warning, using MS style audio codec tag, the file may be unplayable!\n"); | |
590 } | |
591 } | |
1000 | 592 assert(tag); |
593 return tag; | |
594 } | |
595 | |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
596 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
|
597 { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
598 offset_t 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
|
599 char compressor_name[32]; |
422 | 600 |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
601 put_be32(pb, 0); /* size */ |
1080 | 602 put_le32(pb, track->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
|
603 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
|
604 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
|
605 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
|
606 |
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
|
607 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
|
608 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
|
609 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
|
610 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
|
611 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
|
612 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
|
613 } 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
|
614 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
|
615 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
|
616 } |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
617 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
|
618 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
|
619 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
|
620 put_be32(pb, 0x00480000); /* Vertical resolution 72dpi */ |
399
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
621 put_be32(pb, 0); /* Data size (= 0) */ |
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
622 put_be16(pb, 1); /* Frame count (= 1) */ |
885 | 623 |
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
|
624 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
|
625 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
|
626 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
|
627 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
|
628 put_buffer(pb, compressor_name, 31); |
885 | 629 |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
630 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
|
631 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
|
632 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
|
633 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
|
634 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
|
635 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
|
636 else if(track->enc->codec_id == CODEC_ID_SVQ3) |
885 | 637 mov_write_svq3_tag(pb); |
1006
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
638 else if(track->enc->codec_id == CODEC_ID_H264) |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
639 mov_write_avcc_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
|
640 |
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
641 return updateSize (pb, pos); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
642 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
643 |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
644 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
|
645 { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
646 offset_t pos = url_ftell(pb); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
647 put_be32(pb, 0); /* size */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
648 put_tag(pb, "stsd"); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
649 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
|
650 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
|
651 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
|
652 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
|
653 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
|
654 mov_write_audio_tag(pb, track); |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
655 return updateSize(pb, pos); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
656 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
657 |
971
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
658 static int mov_write_ctts_tag(ByteIOContext *pb, MOVTrack* track) |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
659 { |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
660 Time2Sample *ctts_entries; |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
661 uint32_t entries = 0; |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
662 uint32_t atom_size; |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
663 int i; |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
664 |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
665 ctts_entries = av_malloc((track->entry + 1) * sizeof(*ctts_entries)); /* worst case */ |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
666 ctts_entries[0].count = 1; |
1129 | 667 ctts_entries[0].duration = track->cluster[0].cts; |
971
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
668 for (i=1; i<track->entry; i++) { |
1129 | 669 if (track->cluster[i].cts == ctts_entries[entries].duration) { |
971
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
670 ctts_entries[entries].count++; /* compress */ |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
671 } else { |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
672 entries++; |
1129 | 673 ctts_entries[entries].duration = track->cluster[i].cts; |
971
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
674 ctts_entries[entries].count = 1; |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
675 } |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
676 } |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
677 entries++; /* last one */ |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
678 atom_size = 16 + (entries * 8); |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
679 put_be32(pb, atom_size); /* size */ |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
680 put_tag(pb, "ctts"); |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
681 put_be32(pb, 0); /* version & flags */ |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
682 put_be32(pb, entries); /* entry count */ |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
683 for (i=0; i<entries; i++) { |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
684 put_be32(pb, ctts_entries[i].count); |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
685 put_be32(pb, ctts_entries[i].duration); |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
686 } |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
687 av_free(ctts_entries); |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
688 return atom_size; |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
689 } |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
690 |
676 | 691 /* TODO: */ |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
692 /* Time to sample atom */ |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
693 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
|
694 { |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
695 put_be32(pb, 0x18); /* size */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
696 put_tag(pb, "stts"); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
697 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
|
698 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
|
699 |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
700 put_be32(pb, track->sampleCount); /* sample count */ |
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
701 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
|
702 return 0x18; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
703 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
704 |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
705 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
|
706 { |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
707 put_be32(pb, 28); /* size */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
708 put_tag(pb, "dref"); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
709 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
|
710 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
|
711 |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
712 put_be32(pb, 0xc); /* size */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
713 put_tag(pb, "url "); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
714 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
|
715 |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
716 return 28; |
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_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
|
720 { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
721 offset_t pos = url_ftell(pb); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
722 put_be32(pb, 0); /* size */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
723 put_tag(pb, "stbl"); |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
724 mov_write_stsd_tag(pb, track); |
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
725 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
|
726 if (track->enc->codec_type == CODEC_TYPE_VIDEO && |
1054 | 727 track->hasKeyframes < track->entry) |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
728 mov_write_stss_tag(pb, track); |
971
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
729 if (track->enc->codec_type == CODEC_TYPE_VIDEO && |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
730 track->hasBframes) |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
731 mov_write_ctts_tag(pb, track); |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
732 mov_write_stsc_tag(pb, track); |
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
733 mov_write_stsz_tag(pb, track); |
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
734 mov_write_stco_tag(pb, track); |
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
735 return updateSize(pb, pos); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
736 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
737 |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
738 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
|
739 { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
740 offset_t pos = url_ftell(pb); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
741 put_be32(pb, 0); /* size */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
742 put_tag(pb, "dinf"); |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
743 mov_write_dref_tag(pb); |
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
744 return updateSize(pb, pos); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
745 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
746 |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
747 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
|
748 { |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
749 put_be32(pb, 16); /* size */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
750 put_tag(pb, "smhd"); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
751 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
|
752 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
|
753 put_be16(pb, 0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
754 return 16; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
755 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
756 |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
757 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
|
758 { |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
759 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
|
760 put_tag(pb, "vmhd"); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
761 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
|
762 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
|
763 return 0x14; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
764 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
765 |
399
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
766 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
|
767 { |
1123
6992dd78ff68
Add (mostly) const to variable and parameter declaration, where a char* was
diego
parents:
1112
diff
changeset
|
768 const char *descr, *hdlr, *hdlr_type; |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
769 offset_t pos = url_ftell(pb); |
885 | 770 |
399
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
771 if (!track) { /* no media --> data handler */ |
887 | 772 hdlr = "dhlr"; |
773 hdlr_type = "url "; | |
774 descr = "DataHandler"; | |
399
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
775 } else { |
887 | 776 hdlr = (track->mode == MODE_MOV) ? "mhlr" : "\0\0\0\0"; |
777 if (track->enc->codec_type == CODEC_TYPE_VIDEO) { | |
778 hdlr_type = "vide"; | |
779 descr = "VideoHandler"; | |
780 } else { | |
781 hdlr_type = "soun"; | |
782 descr = "SoundHandler"; | |
783 } | |
399
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
784 } |
885 | 785 |
399
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
786 put_be32(pb, 0); /* size */ |
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
787 put_tag(pb, "hdlr"); |
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
788 put_be32(pb, 0); /* Version & flags */ |
400
62e4ea840c52
* fixing 10l in movenc.c + updating regression patterns.
romansh
parents:
399
diff
changeset
|
789 put_buffer(pb, hdlr, 4); /* handler */ |
399
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
790 put_tag(pb, hdlr_type); /* handler type */ |
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
791 put_be32(pb ,0); /* reserved */ |
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
792 put_be32(pb ,0); /* reserved */ |
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
793 put_be32(pb ,0); /* reserved */ |
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
794 put_byte(pb, strlen(descr)); /* string counter */ |
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
795 put_buffer(pb, descr, strlen(descr)); /* handler description */ |
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
796 return updateSize(pb, pos); |
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
797 } |
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
798 |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
799 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
|
800 { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
801 offset_t pos = url_ftell(pb); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
802 put_be32(pb, 0); /* size */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
803 put_tag(pb, "minf"); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
804 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
|
805 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
|
806 else |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
807 mov_write_smhd_tag(pb); |
399
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
808 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
|
809 mov_write_hdlr_tag(pb, NULL); |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
810 mov_write_dinf_tag(pb); |
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
811 mov_write_stbl_tag(pb, track); |
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 |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
815 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
|
816 { |
1037 | 817 int version = track->trackDuration < INT32_MAX ? 0 : 1; |
818 | |
819 (version == 1) ? put_be32(pb, 44) : put_be32(pb, 32); /* size */ | |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
820 put_tag(pb, "mdhd"); |
1037 | 821 put_byte(pb, version); |
822 put_be24(pb, 0); /* flags */ | |
823 if (version == 1) { | |
824 put_be64(pb, track->time); | |
825 put_be64(pb, track->time); | |
826 } else { | |
827 put_be32(pb, track->time); /* creation time */ | |
828 put_be32(pb, track->time); /* modification time */ | |
829 } | |
885 | 830 put_be32(pb, track->timescale); /* time scale (sample rate for audio) */ |
1037 | 831 (version == 1) ? put_be64(pb, track->trackDuration) : put_be32(pb, track->trackDuration); /* duration */ |
890
1e49bfea0ffb
finally found what those >138 codes were... crappy compressed 5bit ascii. this gets them correctly, and adds setting track lang in movenc too.
mmu_man
parents:
887
diff
changeset
|
832 put_be16(pb, track->language); /* language */ |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
833 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
|
834 return 32; |
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 |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
837 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
|
838 { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
839 offset_t pos = url_ftell(pb); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
840 put_be32(pb, 0); /* size */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
841 put_tag(pb, "mdia"); |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
842 mov_write_mdhd_tag(pb, track); |
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
843 mov_write_hdlr_tag(pb, track); |
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
844 mov_write_minf_tag(pb, track); |
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
845 return updateSize(pb, pos); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
846 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
847 |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
848 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
|
849 { |
1037 | 850 int64_t duration = av_rescale_rnd(track->trackDuration, globalTimescale, track->timescale, AV_ROUND_UP); |
851 int version = duration < INT32_MAX ? 0 : 1; | |
852 | |
853 (version == 1) ? put_be32(pb, 104) : put_be32(pb, 92); /* size */ | |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
854 put_tag(pb, "tkhd"); |
1037 | 855 put_byte(pb, version); |
856 put_be24(pb, 0xf); /* flags (track enabled) */ | |
857 if (version == 1) { | |
858 put_be64(pb, track->time); | |
859 put_be64(pb, track->time); | |
860 } else { | |
861 put_be32(pb, track->time); /* creation time */ | |
862 put_be32(pb, track->time); /* modification time */ | |
863 } | |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
864 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
|
865 put_be32(pb, 0); /* reserved */ |
1037 | 866 (version == 1) ? put_be64(pb, duration) : put_be32(pb, duration); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
867 |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
868 put_be32(pb, 0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
869 put_be32(pb, 0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
870 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
|
871 /* Volume, only for audio */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
872 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
|
873 put_be16(pb, 0x0100); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
874 else |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
875 put_be16(pb, 0); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
876 put_be16(pb, 0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
877 |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
878 /* Matrix structure */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
879 put_be32(pb, 0x00010000); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
880 put_be32(pb, 0x0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
881 put_be32(pb, 0x0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
882 put_be32(pb, 0x0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
883 put_be32(pb, 0x00010000); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
884 put_be32(pb, 0x0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
885 put_be32(pb, 0x0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
886 put_be32(pb, 0x0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
887 put_be32(pb, 0x40000000); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
888 |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
889 /* 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
|
890 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
|
891 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
|
892 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
|
893 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
|
894 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
|
895 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
896 else { |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
897 put_be32(pb, 0); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
898 put_be32(pb, 0); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
899 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
900 return 0x5c; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
901 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
902 |
659
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
903 // 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
|
904 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
|
905 { |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
906 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
|
907 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
|
908 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
|
909 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
|
910 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
|
911 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
|
912 |
761 | 913 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
|
914 |
1053 | 915 if (track->hasBframes) |
916 put_be32(pb, track->sampleDuration); /* first pts is 1 */ | |
917 else | |
918 put_be32(pb, 0); | |
659
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
919 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
|
920 return 0x24; |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
921 } |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
922 |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
923 // 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
|
924 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
|
925 { |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
926 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
|
927 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
|
928 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
|
929 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
|
930 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
|
931 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
|
932 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
|
933 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
|
934 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
|
935 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
|
936 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
|
937 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
|
938 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
|
939 return 0x34; |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
940 } |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
941 |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
942 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
|
943 { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
944 offset_t pos = url_ftell(pb); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
945 put_be32(pb, 0); /* size */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
946 put_tag(pb, "trak"); |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
947 mov_write_tkhd_tag(pb, track); |
1007
5fe94e61fdaa
create edts atom when muxing B frames, needed to compute cts
bcoudurier
parents:
1006
diff
changeset
|
948 if (track->mode == MODE_PSP || track->hasBframes) |
659
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
949 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
|
950 mov_write_mdia_tag(pb, track); |
885 | 951 if (track->mode == MODE_PSP) |
659
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
952 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
|
953 return updateSize(pb, pos); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
954 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
955 |
683
095009fc2f35
kill warnings patch by (M«©ns Rullg«©rd <mru inprovide com>)
michael
parents:
677
diff
changeset
|
956 #if 0 |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
957 /* 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
|
958 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
|
959 { |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
960 put_be32(pb, 0x15); /* size */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
961 put_tag(pb, "iods"); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
962 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
|
963 put_be16(pb, 0x1007); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
964 put_byte(pb, 0); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
965 put_be16(pb, 0x4fff); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
966 put_be16(pb, 0xfffe); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
967 put_be16(pb, 0x01ff); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
968 return 0x15; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
969 } |
683
095009fc2f35
kill warnings patch by (M«©ns Rullg«©rd <mru inprovide com>)
michael
parents:
677
diff
changeset
|
970 #endif |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
971 |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
972 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
|
973 { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
974 int maxTrackID = 1, i; |
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
975 int64_t maxTrackLenTemp, maxTrackLen = 0; |
1037 | 976 int version; |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
977 |
1131 | 978 for (i=0; i<mov->nb_streams; i++) { |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
979 if(mov->tracks[i].entry > 0) { |
761 | 980 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
|
981 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
|
982 maxTrackLen = maxTrackLenTemp; |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
983 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
|
984 maxTrackID = mov->tracks[i].trackID; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
985 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
986 } |
1037 | 987 |
988 version = maxTrackLen < UINT32_MAX ? 0 : 1; | |
989 (version == 1) ? put_be32(pb, 120) : put_be32(pb, 108); /* size */ | |
990 put_tag(pb, "mvhd"); | |
991 put_byte(pb, version); | |
992 put_be24(pb, 0); /* flags */ | |
993 if (version == 1) { | |
994 put_be64(pb, mov->time); | |
995 put_be64(pb, mov->time); | |
996 } else { | |
997 put_be32(pb, mov->time); /* creation time */ | |
998 put_be32(pb, mov->time); /* modification time */ | |
999 } | |
1000 put_be32(pb, mov->timescale); /* timescale */ | |
1001 (version == 1) ? put_be64(pb, maxTrackLen) : put_be32(pb, maxTrackLen); /* duration of longest track */ | |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1002 |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1003 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
|
1004 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
|
1005 put_be16(pb, 0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1006 put_be32(pb, 0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1007 put_be32(pb, 0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1008 |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1009 /* Matrix structure */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1010 put_be32(pb, 0x00010000); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1011 put_be32(pb, 0x0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1012 put_be32(pb, 0x0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1013 put_be32(pb, 0x0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1014 put_be32(pb, 0x00010000); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1015 put_be32(pb, 0x0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1016 put_be32(pb, 0x0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1017 put_be32(pb, 0x0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1018 put_be32(pb, 0x40000000); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1019 |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1020 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
|
1021 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
|
1022 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
|
1023 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
|
1024 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
|
1025 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
|
1026 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
|
1027 return 0x6c; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1028 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1029 |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1030 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
|
1031 AVFormatContext *s) |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1032 { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
1033 offset_t pos = url_ftell(pb); |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1034 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
|
1035 put_tag(pb, "hdlr"); |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1036 put_be32(pb, 0); |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1037 put_be32(pb, 0); |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1038 put_tag(pb, "mdir"); |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1039 put_tag(pb, "appl"); |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1040 put_be32(pb, 0); |
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); |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1042 put_be16(pb, 0); |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1043 return updateSize(pb, pos); |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1044 } |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1045 |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1046 /* helper function to write a data tag with the specified string as data */ |
1094 | 1047 static int mov_write_string_data_tag(ByteIOContext *pb, const char *data, int long_style) |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1048 { |
1094 | 1049 if(long_style){ |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
1050 offset_t pos = url_ftell(pb); |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1051 put_be32(pb, 0); /* size */ |
1094 | 1052 put_tag(pb, "data"); |
1053 put_be32(pb, 1); | |
1054 put_be32(pb, 0); | |
1055 put_buffer(pb, data, strlen(data)); | |
1056 return updateSize(pb, pos); | |
1057 }else{ | |
1058 put_be16(pb, strlen(data)); /* string length */ | |
1059 put_be16(pb, 0); | |
1060 put_buffer(pb, data, strlen(data)); | |
1061 return strlen(data) + 4; | |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1062 } |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1063 } |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1064 |
1123
6992dd78ff68
Add (mostly) const to variable and parameter declaration, where a char* was
diego
parents:
1112
diff
changeset
|
1065 static int mov_write_string_tag(ByteIOContext *pb, const char *name, const char *value, int long_style){ |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1066 int size = 0; |
1094 | 1067 if ( value && value[0] ) { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
1068 offset_t pos = url_ftell(pb); |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1069 put_be32(pb, 0); /* size */ |
1094 | 1070 put_tag(pb, name); |
1071 mov_write_string_data_tag(pb, value, long_style); | |
1072 size= updateSize(pb, pos); | |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1073 } |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1074 return size; |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1075 } |
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 /* iTunes year */ |
1094 | 1078 static int mov_write_day_tag(ByteIOContext *pb, int year, int long_style) |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1079 { |
1094 | 1080 if(year){ |
1081 char year_str[5]; | |
1082 snprintf(year_str, sizeof(year_str), "%04d", year); | |
1083 return mov_write_string_tag(pb, "\251day", year_str, long_style); | |
1084 }else | |
1085 return 0; | |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1086 } |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1087 |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1088 /* iTunes track number */ |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1089 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
|
1090 AVFormatContext *s) |
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 int size = 0; |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1093 if ( s->track ) { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
1094 offset_t pos = url_ftell(pb); |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1095 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
|
1096 put_tag(pb, "trkn"); |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1097 { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
1098 offset_t pos = url_ftell(pb); |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1099 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
|
1100 put_tag(pb, "data"); |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1101 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
|
1102 put_be32(pb, 0); |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1103 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
|
1104 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
|
1105 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
|
1106 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
|
1107 updateSize(pb, pos); |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1108 } |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1109 size = updateSize(pb, pos); |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1110 } |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1111 return size; |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1112 } |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1113 |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1114 /* iTunes meta data list */ |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1115 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
|
1116 AVFormatContext *s) |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1117 { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
1118 offset_t pos = url_ftell(pb); |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1119 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
|
1120 put_tag(pb, "ilst"); |
1094 | 1121 mov_write_string_tag(pb, "\251nam", s->title , 1); |
1122 mov_write_string_tag(pb, "\251ART", s->author , 1); | |
1123 mov_write_string_tag(pb, "\251wrt", s->author , 1); | |
1124 mov_write_string_tag(pb, "\251alb", s->album , 1); | |
1125 mov_write_day_tag(pb, s->year ,1); | |
1095
bf797dc4828e
dont write LAVF_ID if bitexact and any meta tag is set
michael
parents:
1094
diff
changeset
|
1126 if(mov->tracks[0].enc && !(mov->tracks[0].enc->flags & CODEC_FLAG_BITEXACT)) |
bf797dc4828e
dont write LAVF_ID if bitexact and any meta tag is set
michael
parents:
1094
diff
changeset
|
1127 mov_write_string_tag(pb, "\251too", LIBAVFORMAT_IDENT, 1); |
1094 | 1128 mov_write_string_tag(pb, "\251cmt", s->comment , 1); |
1129 mov_write_string_tag(pb, "\251gen", s->genre , 1); | |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1130 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
|
1131 return updateSize(pb, pos); |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1132 } |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1133 |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1134 /* iTunes meta data tag */ |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1135 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
|
1136 AVFormatContext *s) |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1137 { |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1138 int size = 0; |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1139 |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1140 // only save meta tag if required |
885 | 1141 if ( s->title[0] || s->author[0] || s->album[0] || s->year || |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1142 s->comment[0] || s->genre[0] || s->track ) { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
1143 offset_t pos = url_ftell(pb); |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1144 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
|
1145 put_tag(pb, "meta"); |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1146 put_be32(pb, 0); |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1147 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
|
1148 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
|
1149 size = updateSize(pb, pos); |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1150 } |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1151 return size; |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1152 } |
885 | 1153 |
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
|
1154 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
|
1155 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
|
1156 { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
1157 offset_t pos = url_ftell(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
|
1158 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
|
1159 |
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_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
|
1161 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
|
1162 |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1163 /* iTunes meta data */ |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1164 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
|
1165 |
1096
f5c75a06e2b4
dont store mov style meta tags in mp4 (fixes ffmpeg -title + gtkpod)
michael
parents:
1095
diff
changeset
|
1166 if(mov->mode == MODE_MOV){ // the title field breaks gtkpod with mp4 and my suspicion is that stuff isnt valid in mp4 |
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
|
1167 /* Requirements */ |
1131 | 1168 for (i=0; i<mov->nb_streams; i++) { |
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
|
1169 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
|
1170 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
|
1171 mov->tracks[i].enc->codec_id == CODEC_ID_MPEG4) { |
1094 | 1172 mov_write_string_tag(pb, "\251req", "QuickTime 6.0 or greater", 0); |
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
|
1173 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
|
1174 } |
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
|
1175 } |
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
|
1176 |
1094 | 1177 mov_write_string_tag(pb, "\251nam", s->title , 0); |
1178 mov_write_string_tag(pb, "\251aut", s->author , 0); | |
1179 mov_write_string_tag(pb, "\251alb", s->album , 0); | |
1180 mov_write_day_tag(pb, s->year, 0); | |
661
ff3b403d0498
movenc illegal access patch by Roine Gustafsson <roine AT users DOT sourceforge DOT net>
mmu_man
parents:
659
diff
changeset
|
1181 if(mov->tracks[0].enc && !(mov->tracks[0].enc->flags & CODEC_FLAG_BITEXACT)) |
1094 | 1182 mov_write_string_tag(pb, "\251enc", LIBAVFORMAT_IDENT, 0); |
1183 mov_write_string_tag(pb, "\251des", s->comment , 0); | |
1184 mov_write_string_tag(pb, "\251gen", s->genre , 0); | |
1096
f5c75a06e2b4
dont store mov style meta tags in mp4 (fixes ffmpeg -title + gtkpod)
michael
parents:
1095
diff
changeset
|
1185 } |
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
|
1186 |
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
|
1187 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
|
1188 } |
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
|
1189 |
911
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1190 |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1191 static size_t ascii_to_wc (ByteIOContext *pb, char *b, size_t n) |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1192 { |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1193 size_t i; |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1194 unsigned char c; |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1195 for (i = 0; i < n - 1; i++) { |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1196 c = b[i]; |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1197 if (! (0x20 <= c && c <= 0x7f )) |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1198 c = 0x3f; /* '?' */ |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1199 put_be16(pb, c); |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1200 } |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1201 put_be16(pb, 0x00); |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1202 return 2*n; |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1203 } |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1204 |
1123
6992dd78ff68
Add (mostly) const to variable and parameter declaration, where a char* was
diego
parents:
1112
diff
changeset
|
1205 static uint16_t language_code (const char *str) |
911
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1206 { |
1097
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1207 return ((((str[0]-0x60) & 0x1F)<<10) + (((str[1]-0x60) & 0x1F)<<5) + ((str[2]-0x60) & 0x1F)); |
911
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1208 } |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1209 |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1210 static int mov_write_uuidusmt_tag (ByteIOContext *pb, AVFormatContext *s) |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1211 { |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1212 size_t len, size; |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1213 offset_t pos, curpos; |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1214 |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1215 size = 0; |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1216 if (s->title[0]) { |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1217 pos = url_ftell(pb); |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1218 put_be32(pb, 0); /* size placeholder*/ |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1219 put_tag(pb, "uuid"); |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1220 put_tag(pb, "USMT"); |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1221 put_be32(pb, 0x21d24fce ); /* 96 bit UUID */ |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1222 put_be32(pb, 0xbb88695c ); |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1223 put_be32(pb, 0xfac9c740 ); |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1224 size += 24; |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1225 |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1226 put_be32(pb, 0); /* size placeholder*/ |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1227 put_tag(pb, "MTDT"); |
1097
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1228 put_be16(pb, 4); |
911
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1229 size += 10; |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1230 |
1097
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1231 // ? |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1232 put_be16(pb, 0x0C); /* size */ |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1233 put_be32(pb, 0x0B); /* type */ |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1234 put_be16(pb, language_code("und")); /* language */ |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1235 put_be16(pb, 0x0); /* ? */ |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1236 put_be16(pb, 0x021C); /* data */ |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1237 size += 12; |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1238 |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1239 // Encoder |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1240 len = strlen(LIBAVCODEC_IDENT)+1; |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1241 put_be16(pb, len*2+10); /* size */ |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1242 put_be32(pb, 0x04); /* type */ |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1243 put_be16(pb, language_code("eng")); /* language */ |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1244 put_be16(pb, 0x01); /* ? */ |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1245 ascii_to_wc(pb, LIBAVCODEC_IDENT, len); |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1246 size += len*2+10; |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1247 |
911
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1248 // Title |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1249 len = strlen(s->title)+1; |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1250 put_be16(pb, len*2+10); /* size */ |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1251 put_be32(pb, 0x01); /* type */ |
1097
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1252 put_be16(pb, language_code("eng")); /* language */ |
911
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1253 put_be16(pb, 0x01); /* ? */ |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1254 ascii_to_wc (pb, s->title, len); |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1255 size += len*2+10; |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1256 |
1097
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1257 // Date |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1258 // snprintf(dt,32,"%04d/%02d/%02d %02d:%02d:%02d",t_st->tm_year+1900,t_st->tm_mon+1,t_st->tm_mday,t_st->tm_hour,t_st->tm_min,t_st->tm_sec); |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1259 len = strlen("2006/04/01 11:11:11")+1; |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1260 put_be16(pb, len*2+10); /* size */ |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1261 put_be32(pb, 0x03); /* type */ |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1262 put_be16(pb, language_code("und")); /* language */ |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1263 put_be16(pb, 0x01); /* ? */ |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1264 ascii_to_wc (pb, "2006/04/01 11:11:11", len); |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1265 size += len*2+10; |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1266 |
911
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1267 // size |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1268 curpos = url_ftell(pb); |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1269 url_fseek(pb, pos, SEEK_SET); |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1270 put_be32(pb, size); |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1271 url_fseek(pb, pos+24, SEEK_SET); |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1272 put_be32(pb, size-24); |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1273 url_fseek(pb, curpos, SEEK_SET); |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1274 } |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1275 |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1276 return size; |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1277 } |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1278 |
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
|
1279 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
|
1280 AVFormatContext *s) |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1281 { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
1282 int i; |
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
1283 offset_t pos = url_ftell(pb); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1284 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
|
1285 put_tag(pb, "moov"); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1286 mov->timescale = globalTimescale; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1287 |
1131 | 1288 for (i=0; i<mov->nb_streams; i++) { |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1289 if(mov->tracks[i].entry <= 0) continue; |
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1290 |
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1291 if(mov->tracks[i].enc->codec_type == CODEC_TYPE_VIDEO) { |
743 | 1292 mov->tracks[i].timescale = mov->tracks[i].enc->time_base.den; |
1293 mov->tracks[i].sampleDuration = mov->tracks[i].enc->time_base.num; | |
1074
829b55eb168c
simplify, amr.c sets frame_size to 160, and sample size is always 8000
bcoudurier
parents:
1073
diff
changeset
|
1294 } else if(mov->tracks[i].enc->codec_type == CODEC_TYPE_AUDIO) { |
829b55eb168c
simplify, amr.c sets frame_size to 160, and sample size is always 8000
bcoudurier
parents:
1073
diff
changeset
|
1295 mov->tracks[i].timescale = mov->tracks[i].enc->sample_rate; |
829b55eb168c
simplify, amr.c sets frame_size to 160, and sample size is always 8000
bcoudurier
parents:
1073
diff
changeset
|
1296 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
|
1297 } |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1298 |
885 | 1299 mov->tracks[i].trackDuration = |
1037 | 1300 (int64_t)mov->tracks[i].sampleCount * mov->tracks[i].sampleDuration; |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1301 mov->tracks[i].time = mov->time; |
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1302 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
|
1303 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1304 |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
1305 mov_write_mvhd_tag(pb, mov); |
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
1306 //mov_write_iods_tag(pb, mov); |
1131 | 1307 for (i=0; i<mov->nb_streams; i++) { |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1308 if(mov->tracks[i].entry > 0) { |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
1309 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
|
1310 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1311 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1312 |
911
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1313 if (mov->mode == MODE_PSP) |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1314 mov_write_uuidusmt_tag(pb, s); |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1315 else |
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
|
1316 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
|
1317 |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
1318 return updateSize(pb, pos); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1319 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1320 |
1124
d3aff2c607f9
Add const to (mostly) char* and make some functions static, which aren't used
diego
parents:
1123
diff
changeset
|
1321 static 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
|
1322 { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
1323 put_be32(pb, 8); // placeholder for extended size field (64 bit) |
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
1324 put_tag(pb, "wide"); |
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
1325 |
885 | 1326 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
|
1327 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
|
1328 put_tag(pb, "mdat"); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1329 return 0; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1330 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1331 |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1332 /* TODO: This needs to be more general */ |
911
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1333 static void 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
|
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 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
|
1336 |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1337 put_be32(pb, 0x14 ); /* size */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1338 put_tag(pb, "ftyp"); |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1339 |
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
|
1340 if ( mov->mode == MODE_3GP ) |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1341 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
|
1342 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
|
1343 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
|
1344 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
|
1345 put_tag(pb, "MSNV"); |
990
f7394f02e95a
ftyp patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com)
michael
parents:
987
diff
changeset
|
1346 else if ( mov->mode == MODE_MP4 ) |
f7394f02e95a
ftyp patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com)
michael
parents:
987
diff
changeset
|
1347 put_tag(pb, "isom"); |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1348 else |
990
f7394f02e95a
ftyp patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com)
michael
parents:
987
diff
changeset
|
1349 put_tag(pb, "qt "); |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1350 |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1351 put_be32(pb, 0x200 ); |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1352 |
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
|
1353 if ( mov->mode == MODE_3GP ) |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1354 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
|
1355 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
|
1356 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
|
1357 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
|
1358 put_tag(pb, "MSNV"); |
990
f7394f02e95a
ftyp patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com)
michael
parents:
987
diff
changeset
|
1359 else if ( mov->mode == MODE_MP4 ) |
f7394f02e95a
ftyp patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com)
michael
parents:
987
diff
changeset
|
1360 put_tag(pb, "mp41"); |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1361 else |
990
f7394f02e95a
ftyp patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com)
michael
parents:
987
diff
changeset
|
1362 put_tag(pb, "qt "); |
201
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 |
665
47d5b20c9aba
fix segfault by matthieu castet <castet DOT matthieu AT free DOT fr>
mmu_man
parents:
664
diff
changeset
|
1365 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
|
1366 { |
911
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1367 AVCodecContext *VideoCodec = s->streams[0]->codec; |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1368 AVCodecContext *AudioCodec = s->streams[1]->codec; |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1369 int AudioRate = AudioCodec->sample_rate; |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1370 int FrameRate = ((VideoCodec->time_base.den) * (0x10000))/ (VideoCodec->time_base.num); |
1049
23d44137105f
the PSP rejects video with too high bitrates so lets claim they arent too high ...
michael
parents:
1037
diff
changeset
|
1371 int audio_kbitrate= AudioCodec->bit_rate / 1000; |
23d44137105f
the PSP rejects video with too high bitrates so lets claim they arent too high ...
michael
parents:
1037
diff
changeset
|
1372 int video_kbitrate= FFMIN(VideoCodec->bit_rate / 1000, 800 - audio_kbitrate); |
659
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1373 |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1374 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
|
1375 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
|
1376 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
|
1377 |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1378 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
|
1379 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
|
1380 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
|
1381 |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1382 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
|
1383 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
|
1384 |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1385 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
|
1386 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
|
1387 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
|
1388 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
|
1389 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
|
1390 |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1391 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
|
1392 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
|
1393 put_be32(pb, 0x0 ); |
911
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1394 put_be32(pb, 0x2 ); /* TrackID */ |
659
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1395 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
|
1396 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
|
1397 put_be32(pb, 0x0 ); |
1049
23d44137105f
the PSP rejects video with too high bitrates so lets claim they arent too high ...
michael
parents:
1037
diff
changeset
|
1398 put_be32(pb, audio_kbitrate); |
23d44137105f
the PSP rejects video with too high bitrates so lets claim they arent too high ...
michael
parents:
1037
diff
changeset
|
1399 put_be32(pb, audio_kbitrate); |
911
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1400 put_be32(pb, AudioRate ); |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1401 put_be32(pb, AudioCodec->channels ); |
659
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1402 |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1403 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
|
1404 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
|
1405 put_be32(pb, 0x0 ); |
911
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1406 put_be32(pb, 0x1 ); /* TrackID */ |
1050
ece3b7eecba2
little h.264 related hunk from diff between cvs and mobile hackerz
michael
parents:
1049
diff
changeset
|
1407 if (VideoCodec->codec_id == CODEC_ID_H264) { |
ece3b7eecba2
little h.264 related hunk from diff between cvs and mobile hackerz
michael
parents:
1049
diff
changeset
|
1408 put_tag(pb, "avc1"); |
ece3b7eecba2
little h.264 related hunk from diff between cvs and mobile hackerz
michael
parents:
1049
diff
changeset
|
1409 put_be16(pb, 0x014D ); |
ece3b7eecba2
little h.264 related hunk from diff between cvs and mobile hackerz
michael
parents:
1049
diff
changeset
|
1410 put_be16(pb, 0x0015 ); |
ece3b7eecba2
little h.264 related hunk from diff between cvs and mobile hackerz
michael
parents:
1049
diff
changeset
|
1411 } else { |
ece3b7eecba2
little h.264 related hunk from diff between cvs and mobile hackerz
michael
parents:
1049
diff
changeset
|
1412 put_tag(pb, "mp4v"); |
ece3b7eecba2
little h.264 related hunk from diff between cvs and mobile hackerz
michael
parents:
1049
diff
changeset
|
1413 put_be16(pb, 0x0000 ); |
ece3b7eecba2
little h.264 related hunk from diff between cvs and mobile hackerz
michael
parents:
1049
diff
changeset
|
1414 put_be16(pb, 0x0103 ); |
ece3b7eecba2
little h.264 related hunk from diff between cvs and mobile hackerz
michael
parents:
1049
diff
changeset
|
1415 } |
659
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1416 put_be32(pb, 0x0 ); |
1049
23d44137105f
the PSP rejects video with too high bitrates so lets claim they arent too high ...
michael
parents:
1037
diff
changeset
|
1417 put_be32(pb, video_kbitrate); |
23d44137105f
the PSP rejects video with too high bitrates so lets claim they arent too high ...
michael
parents:
1037
diff
changeset
|
1418 put_be32(pb, video_kbitrate); |
911
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1419 put_be32(pb, FrameRate); |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1420 put_be32(pb, FrameRate); |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1421 put_be16(pb, VideoCodec->width); |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1422 put_be16(pb, VideoCodec->height); |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1423 put_be32(pb, 0x010001); /* ? */ |
659
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1424 } |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1425 |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1426 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
|
1427 { |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1428 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
|
1429 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
|
1430 int i; |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1431 |
987
955d23ed733f
compute output format before setting language patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com)
michael
parents:
971
diff
changeset
|
1432 /* Default mode == MP4 */ |
955d23ed733f
compute output format before setting language patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com)
michael
parents:
971
diff
changeset
|
1433 mov->mode = MODE_MP4; |
955d23ed733f
compute output format before setting language patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com)
michael
parents:
971
diff
changeset
|
1434 |
955d23ed733f
compute output format before setting language patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com)
michael
parents:
971
diff
changeset
|
1435 if (s->oformat != NULL) { |
955d23ed733f
compute output format before setting language patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com)
michael
parents:
971
diff
changeset
|
1436 if (!strcmp("3gp", s->oformat->name)) mov->mode = MODE_3GP; |
955d23ed733f
compute output format before setting language patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com)
michael
parents:
971
diff
changeset
|
1437 else if (!strcmp("3g2", s->oformat->name)) mov->mode = MODE_3G2; |
955d23ed733f
compute output format before setting language patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com)
michael
parents:
971
diff
changeset
|
1438 else if (!strcmp("mov", s->oformat->name)) mov->mode = MODE_MOV; |
955d23ed733f
compute output format before setting language patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com)
michael
parents:
971
diff
changeset
|
1439 else if (!strcmp("psp", s->oformat->name)) mov->mode = MODE_PSP; |
955d23ed733f
compute output format before setting language patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com)
michael
parents:
971
diff
changeset
|
1440 |
990
f7394f02e95a
ftyp patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com)
michael
parents:
987
diff
changeset
|
1441 mov_write_ftyp_tag(pb,s); |
987
955d23ed733f
compute output format before setting language patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com)
michael
parents:
971
diff
changeset
|
1442 if ( mov->mode == MODE_PSP ) { |
955d23ed733f
compute output format before setting language patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com)
michael
parents:
971
diff
changeset
|
1443 if ( s->nb_streams != 2 ) { |
955d23ed733f
compute output format before setting language patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com)
michael
parents:
971
diff
changeset
|
1444 av_log(s, AV_LOG_ERROR, "PSP mode need one video and one audio stream\n"); |
955d23ed733f
compute output format before setting language patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com)
michael
parents:
971
diff
changeset
|
1445 return -1; |
955d23ed733f
compute output format before setting language patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com)
michael
parents:
971
diff
changeset
|
1446 } |
955d23ed733f
compute output format before setting language patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com)
michael
parents:
971
diff
changeset
|
1447 mov_write_uuidprof_tag(pb,s); |
955d23ed733f
compute output format before setting language patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com)
michael
parents:
971
diff
changeset
|
1448 } |
955d23ed733f
compute output format before setting language patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com)
michael
parents:
971
diff
changeset
|
1449 } |
955d23ed733f
compute output format before setting language patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com)
michael
parents:
971
diff
changeset
|
1450 |
494 | 1451 for(i=0; i<s->nb_streams; i++){ |
1080 | 1452 AVStream *st= s->streams[i]; |
1453 MOVTrack *track= &mov->tracks[i]; | |
494 | 1454 |
1080 | 1455 track->enc = st->codec; |
1456 if(st->codec->codec_type == CODEC_TYPE_VIDEO){ | |
1457 track->tag = mov_find_video_codec_tag(s, track); | |
1458 av_set_pts_info(st, 64, 1, st->codec->time_base.den); | |
1459 }else if(st->codec->codec_type == CODEC_TYPE_AUDIO){ | |
1460 track->tag = mov_find_audio_codec_tag(s, track); | |
1461 av_set_pts_info(st, 64, 1, st->codec->sample_rate); | |
1158 | 1462 track->sampleSize = (av_get_bits_per_sample(st->codec->codec_id) >> 3) * st->codec->channels; |
494 | 1463 } |
1080 | 1464 track->language = ff_mov_iso639_to_lang(st->language, mov->mode != MODE_MOV); |
1465 track->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
|
1466 } |
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
1467 |
1055
faa09c43a3d6
write mdat in write_header avoid check in write_packet
bcoudurier
parents:
1054
diff
changeset
|
1468 mov_write_mdat_tag(pb, mov); |
faa09c43a3d6
write mdat in write_header avoid check in write_packet
bcoudurier
parents:
1054
diff
changeset
|
1469 mov->time = s->timestamp + 0x7C25B080; //1970 based -> 1904 based |
1131 | 1470 mov->nb_streams = s->nb_streams; |
1055
faa09c43a3d6
write mdat in write_header avoid check in write_packet
bcoudurier
parents:
1054
diff
changeset
|
1471 |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1472 put_flush_packet(pb); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1473 |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1474 return 0; |
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 |
468 | 1477 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
|
1478 { |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1479 MOVContext *mov = s->priv_data; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1480 ByteIOContext *pb = &s->pb; |
1080 | 1481 MOVTrack *trk = &mov->tracks[pkt->stream_index]; |
1482 AVCodecContext *enc = trk->enc; | |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1483 unsigned int samplesInChunk = 0; |
468 | 1484 int size= pkt->size; |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1485 |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1486 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
|
1487 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
|
1488 |
1154 | 1489 if (enc->codec_id == CODEC_ID_AMR_NB) { |
1147 | 1490 /* We must find out how many AMR blocks there are in one packet */ |
1491 static uint16_t packed_size[16] = | |
1492 {13, 14, 16, 18, 20, 21, 27, 32, 6, 0, 0, 0, 0, 0, 0, 0}; | |
1493 int len = 0; | |
1057 | 1494 |
1147 | 1495 while (len < size && samplesInChunk < 100) { |
1496 len += packed_size[(pkt->data[len] >> 3) & 0x0F]; | |
1497 samplesInChunk++; | |
1057 | 1498 } |
1151 | 1499 if(samplesInChunk > 1){ |
1500 av_log(s, AV_LOG_ERROR, "fatal error, input is not a single packet, inplement a AVParser for it\n"); | |
1501 return -1; | |
1502 } | |
1147 | 1503 } else if (trk->sampleSize) |
1504 samplesInChunk = size/trk->sampleSize; | |
1505 else | |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1506 samplesInChunk = 1; |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1507 |
1057 | 1508 /* copy extradata if it exists */ |
1509 if (trk->vosLen == 0 && enc->extradata_size > 0) { | |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1510 trk->vosLen = enc->extradata_size; |
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1511 trk->vosData = av_malloc(trk->vosLen); |
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1512 memcpy(trk->vosData, enc->extradata, trk->vosLen); |
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1513 } |
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1514 |
1057 | 1515 if (enc->codec_id == CODEC_ID_H264 && trk->vosLen > 0 && *(uint8_t *)trk->vosData != 1) { |
1516 /* from x264 or from bytestream h264 */ | |
1517 /* nal reformating needed */ | |
1518 avc_parse_nal_units(&pkt->data, &pkt->size); | |
1519 assert(pkt->size); | |
1520 size = pkt->size; | |
1006
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
1521 } |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
1522 |
1129 | 1523 if (!(trk->entry % MOV_INDEX_CLUSTER_SIZE)) { |
1524 trk->cluster = av_realloc(trk->cluster, (trk->entry + MOV_INDEX_CLUSTER_SIZE) * sizeof(*trk->cluster)); | |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1525 if (!trk->cluster) |
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1526 return -1; |
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1527 } |
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1528 |
1129 | 1529 trk->cluster[trk->entry].pos = url_ftell(pb); |
1530 trk->cluster[trk->entry].samplesInChunk = samplesInChunk; | |
1531 trk->cluster[trk->entry].size = size; | |
1532 trk->cluster[trk->entry].entries = samplesInChunk; | |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1533 if(enc->codec_type == CODEC_TYPE_VIDEO) { |
971
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
1534 if (pkt->dts != pkt->pts) |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
1535 trk->hasBframes = 1; |
1129 | 1536 trk->cluster[trk->entry].cts = pkt->pts - pkt->dts; |
1537 trk->cluster[trk->entry].key_frame = !!(pkt->flags & PKT_FLAG_KEY); | |
1538 if(trk->cluster[trk->entry].key_frame) | |
1054 | 1539 trk->hasKeyframes++; |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1540 } |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1541 trk->entry++; |
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1542 trk->sampleCount += samplesInChunk; |
1080 | 1543 mov->mdat_size += size; |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1544 |
468 | 1545 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
|
1546 |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1547 put_flush_packet(pb); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1548 return 0; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1549 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1550 |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1551 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
|
1552 { |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1553 MOVContext *mov = s->priv_data; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1554 ByteIOContext *pb = &s->pb; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1555 int res = 0; |
1129 | 1556 int i; |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1557 |
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
|
1558 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
|
1559 |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1560 /* Write size of mdat tag */ |
1080 | 1561 if (mov->mdat_size+8 <= UINT32_MAX) { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
1562 url_fseek(pb, mov->mdat_pos, SEEK_SET); |
1080 | 1563 put_be32(pb, mov->mdat_size+8); |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
1564 } else { |
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
1565 /* overwrite 'wide' placeholder atom */ |
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
1566 url_fseek(pb, mov->mdat_pos - 8, SEEK_SET); |
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
1567 put_be32(pb, 1); /* special value: real atom size will be 64 bit value after tag field */ |
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
1568 put_tag(pb, "mdat"); |
1080 | 1569 put_be64(pb, mov->mdat_size+16); |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
1570 } |
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
|
1571 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
|
1572 |
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
|
1573 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
|
1574 |
1131 | 1575 for (i=0; i<mov->nb_streams; i++) { |
1129 | 1576 av_freep(&mov->tracks[i].cluster); |
1577 | |
342
0c1b489c96bf
memleak patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
299
diff
changeset
|
1578 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
|
1579 |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1580 } |
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
|
1581 |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1582 put_flush_packet(pb); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1583 |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1584 return res; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1585 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1586 |
1169 | 1587 #ifdef CONFIG_MOV_MUXER |
1588 AVOutputFormat mov_muxer = { | |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1589 "mov", |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1590 "mov format", |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1591 NULL, |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1592 "mov", |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1593 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
|
1594 CODEC_ID_AAC, |
239 | 1595 CODEC_ID_MPEG4, |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1596 mov_write_header, |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1597 mov_write_packet, |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1598 mov_write_trailer, |
715
e214703e4b76
30_clean_up_global_header_flag.patch by (Calcium | calcium nurs or jp)
michael
parents:
711
diff
changeset
|
1599 .flags = AVFMT_GLOBALHEADER, |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1600 }; |
1169 | 1601 #endif |
1602 #ifdef CONFIG_TGP_MUXER | |
1603 AVOutputFormat tgp_muxer = { | |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1604 "3gp", |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1605 "3gp format", |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1606 NULL, |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1607 "3gp", |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1608 sizeof(MOVContext), |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1609 CODEC_ID_AMR_NB, |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1610 CODEC_ID_H263, |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1611 mov_write_header, |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1612 mov_write_packet, |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1613 mov_write_trailer, |
715
e214703e4b76
30_clean_up_global_header_flag.patch by (Calcium | calcium nurs or jp)
michael
parents:
711
diff
changeset
|
1614 .flags = AVFMT_GLOBALHEADER, |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1615 }; |
1169 | 1616 #endif |
1617 #ifdef CONFIG_MP4_MUXER | |
1618 AVOutputFormat mp4_muxer = { | |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1619 "mp4", |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1620 "mp4 format", |
286
eccf0c3e3289
Using the extension m4a for audio only MPEG-4 files is increasingly
michael
parents:
259
diff
changeset
|
1621 "application/mp4", |
eccf0c3e3289
Using the extension m4a for audio only MPEG-4 files is increasingly
michael
parents:
259
diff
changeset
|
1622 "mp4,m4a", |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1623 sizeof(MOVContext), |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1624 CODEC_ID_AAC, |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1625 CODEC_ID_MPEG4, |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1626 mov_write_header, |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1627 mov_write_packet, |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1628 mov_write_trailer, |
715
e214703e4b76
30_clean_up_global_header_flag.patch by (Calcium | calcium nurs or jp)
michael
parents:
711
diff
changeset
|
1629 .flags = AVFMT_GLOBALHEADER, |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1630 }; |
1169 | 1631 #endif |
1632 #ifdef CONFIG_PSP_MUXER | |
1633 AVOutputFormat psp_muxer = { | |
659
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1634 "psp", |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1635 "psp mp4 format", |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1636 NULL, |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1637 "mp4,psp", |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1638 sizeof(MOVContext), |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1639 CODEC_ID_AAC, |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1640 CODEC_ID_MPEG4, |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1641 mov_write_header, |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1642 mov_write_packet, |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1643 mov_write_trailer, |
911
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1644 .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
|
1645 }; |
1169 | 1646 #endif |
1647 #ifdef CONFIG_TG2_MUXER | |
1648 AVOutputFormat tg2_muxer = { | |
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
|
1649 "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
|
1650 "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
|
1651 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
|
1652 "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
|
1653 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
|
1654 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
|
1655 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
|
1656 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
|
1657 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
|
1658 mov_write_trailer, |
715
e214703e4b76
30_clean_up_global_header_flag.patch by (Calcium | calcium nurs or jp)
michael
parents:
711
diff
changeset
|
1659 .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
|
1660 }; |
1169 | 1661 #endif |