Mercurial > libavformat.hg
annotate movenc.c @ 6012:8298cc054242 libavformat
Make mov_write_packet non-static, add ff_ prefix
author | mstorsjo |
---|---|
date | Tue, 18 May 2010 19:40:17 +0000 |
parents | 97fdefab56cd |
children | 332ad5f30c0e |
rev | line source |
---|---|
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1 /* |
1415
3b00fb8ef8e4
replace coder/decoder file description in libavformat by muxer/demuxer
aurel
parents:
1358
diff
changeset
|
2 * MOV, 3GP, MP4 muxer |
4251
77e0c7511d41
cosmetics: Remove pointless period after copyright statement non-sentences.
diego
parents:
4225
diff
changeset
|
3 * Copyright (c) 2003 Thomas Raivio |
77e0c7511d41
cosmetics: Remove pointless period after copyright statement non-sentences.
diego
parents:
4225
diff
changeset
|
4 * Copyright (c) 2004 Gildas Bazin <gbazin at videolan dot org> |
4722
639c428c8b23
typo in the mail, the 4am commit is always the worst
bcoudurier
parents:
4721
diff
changeset
|
5 * Copyright (c) 2009 Baptiste Coudurier <baptiste dot coudurier at gmail dot com> |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
6 * |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1292
diff
changeset
|
7 * This file is part of FFmpeg. |
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1292
diff
changeset
|
8 * |
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1292
diff
changeset
|
9 * FFmpeg is free software; you can redistribute it and/or |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
10 * 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
|
11 * License as published by the Free Software Foundation; either |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1292
diff
changeset
|
12 * version 2.1 of the License, or (at your option) any later version. |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
13 * |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1292
diff
changeset
|
14 * FFmpeg is distributed in the hope that it will be useful, |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
15 * 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
|
16 * 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
|
17 * 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
|
18 * |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
19 * You should have received a copy of the GNU Lesser General Public |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1292
diff
changeset
|
20 * License along with FFmpeg; if not, write to the Free Software |
896
edbe5c3717f9
Update licensing information: The FSF changed postal address.
diego
parents:
890
diff
changeset
|
21 * 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
|
22 */ |
4721 | 23 |
6011
97fdefab56cd
Move the mov muxer structures to a separate header
mstorsjo
parents:
5993
diff
changeset
|
24 #include "movenc.h" |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
25 #include "avformat.h" |
1172
6a5e58d2114b
move common stuff from avienc.c and wav.c to new file riff.c
mru
parents:
1169
diff
changeset
|
26 #include "riff.h" |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
27 #include "avio.h" |
1216
fec0a3d5408f
move common code from mov.c and movenc.c to isom.c
bcoudurier
parents:
1172
diff
changeset
|
28 #include "isom.h" |
2922
dcd599833abc
Move isom_write_avcc() and related functions into a separate file.
aurel
parents:
2921
diff
changeset
|
29 #include "avc.h" |
4872 | 30 #include "libavcodec/get_bits.h" |
4864
7aa7c5853bb6
Split bitstream.h, put the bitstream writer stuff in the new file
stefano
parents:
4832
diff
changeset
|
31 #include "libavcodec/put_bits.h" |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
32 |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
33 #undef NDEBUG |
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
34 #include <assert.h> |
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
35 |
2165 | 36 //FIXME support 64 bit variant with wide placeholders |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3909
diff
changeset
|
37 static int64_t updateSize(ByteIOContext *pb, int64_t pos) |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
38 { |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3909
diff
changeset
|
39 int64_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
|
40 url_fseek(pb, pos, SEEK_SET); |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
41 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
|
42 url_fseek(pb, curpos, SEEK_SET); |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
43 |
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
44 return curpos - pos; |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
45 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
46 |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
47 /* Chunk offset atom */ |
3446 | 48 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
|
49 { |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
50 int i; |
910 | 51 int mode64 = 0; // use 32 bit size variant if possible |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3909
diff
changeset
|
52 int64_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
|
53 put_be32(pb, 0); /* size */ |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
54 if (pos > UINT32_MAX) { |
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
55 mode64 = 1; |
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
56 put_tag(pb, "co64"); |
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
57 } else |
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
58 put_tag(pb, "stco"); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
59 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
|
60 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
|
61 for (i=0; i<track->entry; i++) { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
62 if(mode64 == 1) |
1129 | 63 put_be64(pb, track->cluster[i].pos); |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
64 else |
1129 | 65 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
|
66 } |
3455 | 67 return updateSize(pb, pos); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
68 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
69 |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
70 /* Sample size atom */ |
3446 | 71 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
|
72 { |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
73 int equalChunks = 1; |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
74 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
|
75 |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3909
diff
changeset
|
76 int64_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
|
77 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
|
78 put_tag(pb, "stsz"); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
79 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
|
80 |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
81 for (i=0; i<track->entry; i++) { |
1129 | 82 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
|
83 if(oldtst != -1 && tst != oldtst) { |
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
84 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
|
85 } |
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
86 oldtst = tst; |
1129 | 87 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
|
88 } |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
89 if (equalChunks) { |
1129 | 90 int sSize = track->cluster[0].size/track->cluster[0].entries; |
885 | 91 put_be32(pb, sSize); // sample size |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
92 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
|
93 } |
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
94 else { |
885 | 95 put_be32(pb, 0); // sample size |
96 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
|
97 for (i=0; i<track->entry; i++) { |
3024
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
98 for (j=0; j<track->cluster[i].entries; j++) { |
1129 | 99 put_be32(pb, track->cluster[i].size / |
100 track->cluster[i].entries); | |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
101 } |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
102 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
103 } |
3455 | 104 return updateSize(pb, pos); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
105 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
106 |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
107 /* Sample to chunk atom */ |
3446 | 108 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
|
109 { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
110 int index = 0, oldval = -1, i; |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3909
diff
changeset
|
111 int64_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
|
112 |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3909
diff
changeset
|
113 int64_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
|
114 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
|
115 put_tag(pb, "stsc"); |
885 | 116 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
|
117 entryPos = url_ftell(pb); |
885 | 118 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
|
119 for (i=0; i<track->entry; i++) { |
1129 | 120 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
|
121 { |
885 | 122 put_be32(pb, i+1); // first chunk |
1129 | 123 put_be32(pb, track->cluster[i].samplesInChunk); // samples per chunk |
885 | 124 put_be32(pb, 0x1); // sample description index |
1129 | 125 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
|
126 index++; |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
127 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
128 } |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
129 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
|
130 url_fseek(pb, entryPos, SEEK_SET); |
885 | 131 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
|
132 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
|
133 |
3455 | 134 return updateSize(pb, pos); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
135 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
136 |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
137 /* Sync sample atom */ |
4941 | 138 static int mov_write_stss_tag(ByteIOContext *pb, MOVTrack *track, uint32_t flag) |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
139 { |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3909
diff
changeset
|
140 int64_t curpos, entryPos; |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
141 int i, index = 0; |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3909
diff
changeset
|
142 int64_t pos = url_ftell(pb); |
885 | 143 put_be32(pb, 0); // size |
4941 | 144 put_tag(pb, flag == MOV_SYNC_SAMPLE ? "stss" : "stps"); |
885 | 145 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
|
146 entryPos = url_ftell(pb); |
885 | 147 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
|
148 for (i=0; i<track->entry; i++) { |
4941 | 149 if (track->cluster[i].flags & flag) { |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
150 put_be32(pb, i+1); |
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
151 index++; |
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
152 } |
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
153 } |
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
154 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
|
155 url_fseek(pb, entryPos, SEEK_SET); |
885 | 156 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
|
157 url_fseek(pb, curpos, SEEK_SET); |
3455 | 158 return updateSize(pb, pos); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
159 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
160 |
1152
c7cf3d1f9bd7
simplify and write correct values conforming to specs
bcoudurier
parents:
1151
diff
changeset
|
161 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
|
162 { |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
163 put_be32(pb, 0x11); /* size */ |
1152
c7cf3d1f9bd7
simplify and write correct values conforming to specs
bcoudurier
parents:
1151
diff
changeset
|
164 if (track->mode == MODE_MOV) put_tag(pb, "samr"); |
c7cf3d1f9bd7
simplify and write correct values conforming to specs
bcoudurier
parents:
1151
diff
changeset
|
165 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
|
166 put_tag(pb, "FFMP"); |
1152
c7cf3d1f9bd7
simplify and write correct values conforming to specs
bcoudurier
parents:
1151
diff
changeset
|
167 put_byte(pb, 0); /* decoder version */ |
1083 | 168 |
1153 | 169 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
|
170 put_byte(pb, 0x00); /* Mode change period (no restriction) */ |
c7cf3d1f9bd7
simplify and write correct values conforming to specs
bcoudurier
parents:
1151
diff
changeset
|
171 put_byte(pb, 0x01); /* Frames per sample */ |
1083 | 172 return 0x11; |
173 } | |
174 | |
3881 | 175 static int mov_write_ac3_tag(ByteIOContext *pb, MOVTrack *track) |
176 { | |
177 GetBitContext gbc; | |
178 PutBitContext pbc; | |
179 uint8_t buf[3]; | |
180 int fscod, bsid, bsmod, acmod, lfeon, frmsizecod; | |
181 | |
182 if (track->vosLen < 7) | |
183 return -1; | |
184 | |
185 put_be32(pb, 11); | |
186 put_tag(pb, "dac3"); | |
187 | |
3888
0244f7383b70
skip 2 bytes more when parsing ac3 frame, syncword 16bits + crc 16bits,
bcoudurier
parents:
3887
diff
changeset
|
188 init_get_bits(&gbc, track->vosData+4, track->vosLen-4); |
3881 | 189 fscod = get_bits(&gbc, 2); |
190 frmsizecod = get_bits(&gbc, 6); | |
191 bsid = get_bits(&gbc, 5); | |
192 bsmod = get_bits(&gbc, 3); | |
193 acmod = get_bits(&gbc, 3); | |
194 if (acmod == 2) { | |
195 skip_bits(&gbc, 2); // dsurmod | |
196 } else { | |
197 if ((acmod & 1) && acmod != 1) | |
198 skip_bits(&gbc, 2); // cmixlev | |
199 if (acmod & 4) | |
200 skip_bits(&gbc, 2); // surmixlev | |
201 } | |
202 lfeon = get_bits1(&gbc); | |
203 | |
204 init_put_bits(&pbc, buf, sizeof(buf)); | |
205 put_bits(&pbc, 2, fscod); | |
206 put_bits(&pbc, 5, bsid); | |
207 put_bits(&pbc, 3, bsmod); | |
208 put_bits(&pbc, 3, acmod); | |
209 put_bits(&pbc, 1, lfeon); | |
210 put_bits(&pbc, 5, frmsizecod>>1); // bit_rate_code | |
211 put_bits(&pbc, 5, 0); // reserved | |
212 | |
213 flush_put_bits(&pbc); | |
214 put_buffer(pb, buf, sizeof(buf)); | |
215 | |
216 return 11; | |
217 } | |
218 | |
3243 | 219 /** |
220 * This function writes extradata "as is". | |
221 * Extradata must be formated like a valid atom (with size and tag) | |
222 */ | |
223 static int mov_write_extradata_tag(ByteIOContext *pb, MOVTrack *track) | |
224 { | |
225 put_buffer(pb, track->enc->extradata, track->enc->extradata_size); | |
226 return track->enc->extradata_size; | |
227 } | |
228 | |
1082 | 229 static int mov_write_enda_tag(ByteIOContext *pb) |
230 { | |
231 put_be32(pb, 10); | |
232 put_tag(pb, "enda"); | |
233 put_be16(pb, 1); /* little endian */ | |
234 return 10; | |
235 } | |
236 | |
1080 | 237 static unsigned int descrLength(unsigned int len) |
238 { | |
1081 | 239 int i; |
240 for(i=1; len>>(7*i); i++); | |
241 return len + 1 + i; | |
1080 | 242 } |
243 | |
1081 | 244 static void putDescr(ByteIOContext *pb, int tag, unsigned int size) |
1080 | 245 { |
1081 | 246 int i= descrLength(size) - size - 2; |
247 put_byte(pb, tag); | |
248 for(; i>0; i--) | |
249 put_byte(pb, (size>>(7*i)) | 0x80); | |
250 put_byte(pb, size & 0x7F); | |
1080 | 251 } |
252 | |
3446 | 253 static int mov_write_esds_tag(ByteIOContext *pb, MOVTrack *track) // Basic |
1080 | 254 { |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3909
diff
changeset
|
255 int64_t pos = url_ftell(pb); |
1082 | 256 int decoderSpecificInfoLen = track->vosLen ? descrLength(track->vosLen):0; |
1080 | 257 |
3246
a6a78c1cbf33
cosmetics: remove useless whitespaces and put braces correctly
bcoudurier
parents:
3243
diff
changeset
|
258 put_be32(pb, 0); // size |
1080 | 259 put_tag(pb, "esds"); |
3246
a6a78c1cbf33
cosmetics: remove useless whitespaces and put braces correctly
bcoudurier
parents:
3243
diff
changeset
|
260 put_be32(pb, 0); // Version |
1080 | 261 |
262 // ES descriptor | |
263 putDescr(pb, 0x03, 3 + descrLength(13 + decoderSpecificInfoLen) + | |
264 descrLength(1)); | |
265 put_be16(pb, track->trackID); | |
3246
a6a78c1cbf33
cosmetics: remove useless whitespaces and put braces correctly
bcoudurier
parents:
3243
diff
changeset
|
266 put_byte(pb, 0x00); // flags (= no flags) |
1080 | 267 |
268 // DecoderConfig descriptor | |
269 putDescr(pb, 0x04, 13 + decoderSpecificInfoLen); | |
270 | |
271 // Object type indication | |
3869 | 272 if ((track->enc->codec_id == CODEC_ID_MP2 || |
273 track->enc->codec_id == CODEC_ID_MP3) && | |
3887
c8ab0676bba6
change the logic to mux 13818-3 and 11172-3 in mp4, less code
bcoudurier
parents:
3886
diff
changeset
|
274 track->enc->sample_rate > 24000) |
c8ab0676bba6
change the logic to mux 13818-3 and 11172-3 in mp4, less code
bcoudurier
parents:
3886
diff
changeset
|
275 put_byte(pb, 0x6B); // 11172-3 |
3869 | 276 else |
5058
33a244b7ca65
Add ff_ prefixes to exported symbols in libavformat/riff.h.
diego
parents:
4996
diff
changeset
|
277 put_byte(pb, ff_codec_get_tag(ff_mp4_obj_type, track->enc->codec_id)); |
1080 | 278 |
279 // the following fields is made of 6 bits to identify the streamtype (4 for video, 5 for audio) | |
280 // plus 1 bit to indicate upstream and 1 bit set to 1 (reserved) | |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5792
diff
changeset
|
281 if(track->enc->codec_type == AVMEDIA_TYPE_AUDIO) |
3246
a6a78c1cbf33
cosmetics: remove useless whitespaces and put braces correctly
bcoudurier
parents:
3243
diff
changeset
|
282 put_byte(pb, 0x15); // flags (= Audiostream) |
1080 | 283 else |
3246
a6a78c1cbf33
cosmetics: remove useless whitespaces and put braces correctly
bcoudurier
parents:
3243
diff
changeset
|
284 put_byte(pb, 0x11); // flags (= Visualstream) |
1080 | 285 |
3246
a6a78c1cbf33
cosmetics: remove useless whitespaces and put braces correctly
bcoudurier
parents:
3243
diff
changeset
|
286 put_byte(pb, track->enc->rc_buffer_size>>(3+16)); // Buffersize DB (24 bits) |
a6a78c1cbf33
cosmetics: remove useless whitespaces and put braces correctly
bcoudurier
parents:
3243
diff
changeset
|
287 put_be16(pb, (track->enc->rc_buffer_size>>3)&0xFFFF); // Buffersize DB |
1080 | 288 |
3246
a6a78c1cbf33
cosmetics: remove useless whitespaces and put braces correctly
bcoudurier
parents:
3243
diff
changeset
|
289 put_be32(pb, FFMAX(track->enc->bit_rate, track->enc->rc_max_rate)); // maxbitrate (FIXME should be max rate in any 1 sec window) |
1080 | 290 if(track->enc->rc_max_rate != track->enc->rc_min_rate || track->enc->rc_min_rate==0) |
3246
a6a78c1cbf33
cosmetics: remove useless whitespaces and put braces correctly
bcoudurier
parents:
3243
diff
changeset
|
291 put_be32(pb, 0); // vbr |
1080 | 292 else |
3246
a6a78c1cbf33
cosmetics: remove useless whitespaces and put braces correctly
bcoudurier
parents:
3243
diff
changeset
|
293 put_be32(pb, track->enc->rc_max_rate); // avg bitrate |
1080 | 294 |
3246
a6a78c1cbf33
cosmetics: remove useless whitespaces and put braces correctly
bcoudurier
parents:
3243
diff
changeset
|
295 if (track->vosLen) { |
1080 | 296 // DecoderSpecific info descriptor |
297 putDescr(pb, 0x05, track->vosLen); | |
298 put_buffer(pb, track->vosData, track->vosLen); | |
299 } | |
300 | |
301 // SL descriptor | |
302 putDescr(pb, 0x06, 1); | |
303 put_byte(pb, 0x02); | |
3455 | 304 return updateSize(pb, pos); |
1080 | 305 } |
306 | |
5390 | 307 static int mov_pcm_le_gt16(enum CodecID codec_id) |
308 { | |
309 return codec_id == CODEC_ID_PCM_S24LE || | |
310 codec_id == CODEC_ID_PCM_S32LE || | |
311 codec_id == CODEC_ID_PCM_F32LE || | |
312 codec_id == CODEC_ID_PCM_F64LE; | |
313 } | |
314 | |
3446 | 315 static int mov_write_wave_tag(ByteIOContext *pb, MOVTrack *track) |
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
|
316 { |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3909
diff
changeset
|
317 int64_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
|
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 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
|
320 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
|
321 |
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
|
322 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
|
323 put_tag(pb, "frma"); |
1082 | 324 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
|
325 |
1082 | 326 if (track->enc->codec_id == CODEC_ID_AAC) { |
1125 | 327 /* useless atom needed by mplayer, ipod, not needed by quicktime */ |
328 put_be32(pb, 12); /* size */ | |
329 put_tag(pb, "mp4a"); | |
330 put_be32(pb, 0); | |
1082 | 331 mov_write_esds_tag(pb, track); |
5390 | 332 } else if (mov_pcm_le_gt16(track->enc->codec_id)) { |
1082 | 333 mov_write_enda_tag(pb); |
1083 | 334 } 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
|
335 mov_write_amr_tag(pb, track); |
3881 | 336 } else if (track->enc->codec_id == CODEC_ID_AC3) { |
337 mov_write_ac3_tag(pb, track); | |
3243 | 338 } else if (track->enc->codec_id == CODEC_ID_ALAC) { |
339 mov_write_extradata_tag(pb, track); | |
1082 | 340 } |
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
|
341 |
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
|
342 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
|
343 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
|
344 |
3455 | 345 return updateSize(pb, pos); |
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
|
346 } |
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
|
347 |
3446 | 348 static int mov_write_glbl_tag(ByteIOContext *pb, MOVTrack *track) |
2838
6bea49ef18b1
use generic 'glbl' atom if extradata is present but no specific method is known
bcoudurier
parents:
2802
diff
changeset
|
349 { |
6bea49ef18b1
use generic 'glbl' atom if extradata is present but no specific method is known
bcoudurier
parents:
2802
diff
changeset
|
350 put_be32(pb, track->vosLen+8); |
6bea49ef18b1
use generic 'glbl' atom if extradata is present but no specific method is known
bcoudurier
parents:
2802
diff
changeset
|
351 put_tag(pb, "glbl"); |
6bea49ef18b1
use generic 'glbl' atom if extradata is present but no specific method is known
bcoudurier
parents:
2802
diff
changeset
|
352 put_buffer(pb, track->vosData, track->vosLen); |
6bea49ef18b1
use generic 'glbl' atom if extradata is present but no specific method is known
bcoudurier
parents:
2802
diff
changeset
|
353 return 8+track->vosLen; |
6bea49ef18b1
use generic 'glbl' atom if extradata is present but no specific method is known
bcoudurier
parents:
2802
diff
changeset
|
354 } |
6bea49ef18b1
use generic 'glbl' atom if extradata is present but no specific method is known
bcoudurier
parents:
2802
diff
changeset
|
355 |
5388
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
356 /** |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
357 * Compute flags for 'lpcm' tag. |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
358 * See CoreAudioTypes and AudioStreamBasicDescription at Apple. |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
359 */ |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
360 static int mov_get_lpcm_flags(enum CodecID codec_id) |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
361 { |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
362 switch (codec_id) { |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
363 case CODEC_ID_PCM_F32BE: |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
364 case CODEC_ID_PCM_F64BE: |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
365 return 11; |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
366 case CODEC_ID_PCM_F32LE: |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
367 case CODEC_ID_PCM_F64LE: |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
368 return 9; |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
369 case CODEC_ID_PCM_U8: |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
370 return 10; |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
371 case CODEC_ID_PCM_S16BE: |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
372 case CODEC_ID_PCM_S24BE: |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
373 case CODEC_ID_PCM_S32BE: |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
374 return 14; |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
375 case CODEC_ID_PCM_S8: |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
376 case CODEC_ID_PCM_S16LE: |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
377 case CODEC_ID_PCM_S24LE: |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
378 case CODEC_ID_PCM_S32LE: |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
379 return 12; |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
380 default: |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
381 return 0; |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
382 } |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
383 } |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
384 |
3446 | 385 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
|
386 { |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3909
diff
changeset
|
387 int64_t pos = url_ftell(pb); |
5388
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
388 int version = 0; |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
389 uint32_t tag = track->tag; |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
390 |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
391 if (track->mode == MODE_MOV) { |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
392 if (track->timescale > UINT16_MAX) { |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
393 if (mov_get_lpcm_flags(track->enc->codec_id)) |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
394 tag = AV_RL32("lpcm"); |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
395 version = 2; |
5390 | 396 } else if (track->audio_vbr || mov_pcm_le_gt16(track->enc->codec_id)) { |
5388
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
397 version = 1; |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
398 } |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
399 } |
885 | 400 |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
401 put_be32(pb, 0); /* size */ |
5388
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
402 put_le32(pb, tag); // store it byteswapped |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
403 put_be32(pb, 0); /* Reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
404 put_be16(pb, 0); /* Reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
405 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
|
406 |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
407 /* SoundDescription */ |
1082 | 408 put_be16(pb, version); /* Version */ |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
409 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
|
410 put_be32(pb, 0); /* Reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
411 |
5388
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
412 if (version == 2) { |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
413 put_be16(pb, 3); |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
414 put_be16(pb, 16); |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
415 put_be16(pb, 0xfffe); |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
416 put_be16(pb, 0); |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
417 put_be32(pb, 0x00010000); |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
418 put_be32(pb, 72); |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
419 put_be64(pb, av_dbl2int(track->timescale)); |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
420 put_be32(pb, track->enc->channels); |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
421 put_be32(pb, 0x7F000000); |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
422 put_be32(pb, av_get_bits_per_sample(track->enc->codec_id)); |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
423 put_be32(pb, mov_get_lpcm_flags(track->enc->codec_id)); |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
424 put_be32(pb, track->sampleSize); |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
425 put_be32(pb, track->enc->frame_size); |
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
426 } else { |
5389 | 427 if (track->mode == MODE_MOV) { |
428 put_be16(pb, track->enc->channels); | |
429 if (track->enc->codec_id == CODEC_ID_PCM_U8 || | |
430 track->enc->codec_id == CODEC_ID_PCM_S8) | |
431 put_be16(pb, 8); /* bits per sample */ | |
432 else | |
433 put_be16(pb, 16); | |
434 put_be16(pb, track->audio_vbr ? -2 : 0); /* compression ID */ | |
435 } else { /* reserved for mp4/3gp */ | |
436 put_be16(pb, 2); | |
1850 | 437 put_be16(pb, 16); |
5389 | 438 put_be16(pb, 0); |
439 } | |
505
e996e7da971c
AAC in mov/mp4 patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
494
diff
changeset
|
440 |
5389 | 441 put_be16(pb, 0); /* packet size (= 0) */ |
442 put_be16(pb, track->timescale); /* Time scale */ | |
443 put_be16(pb, 0); /* Reserved */ | |
5388
5d5c1dc09223
support sample rates > INT16_MAX in mov using stsd v2
bcoudurier
parents:
5382
diff
changeset
|
444 } |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
445 |
1147 | 446 if(version == 1) { /* SoundDescription V1 extended info */ |
447 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
|
448 put_be32(pb, track->sampleSize / track->enc->channels); /* Bytes per packet */ |
1147 | 449 put_be32(pb, track->sampleSize); /* Bytes per frame */ |
1125 | 450 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
|
451 } |
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
|
452 |
1084 | 453 if(track->mode == MODE_MOV && |
454 (track->enc->codec_id == CODEC_ID_AAC || | |
3889
94ba4a17d03f
actually write dac3 atom, patch by Kurtnoise, kurtnoise at free dot fr
bcoudurier
parents:
3888
diff
changeset
|
455 track->enc->codec_id == CODEC_ID_AC3 || |
1084 | 456 track->enc->codec_id == CODEC_ID_AMR_NB || |
5390 | 457 track->enc->codec_id == CODEC_ID_ALAC || |
458 mov_pcm_le_gt16(track->enc->codec_id))) | |
1083 | 459 mov_write_wave_tag(pb, track); |
2977
b5ad3169a579
write esds atom when mpeg-4 systems tags are used
bcoudurier
parents:
2975
diff
changeset
|
460 else if(track->tag == MKTAG('m','p','4','a')) |
1083 | 461 mov_write_esds_tag(pb, track); |
462 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
|
463 mov_write_amr_tag(pb, track); |
3889
94ba4a17d03f
actually write dac3 atom, patch by Kurtnoise, kurtnoise at free dot fr
bcoudurier
parents:
3888
diff
changeset
|
464 else if(track->enc->codec_id == CODEC_ID_AC3) |
94ba4a17d03f
actually write dac3 atom, patch by Kurtnoise, kurtnoise at free dot fr
bcoudurier
parents:
3888
diff
changeset
|
465 mov_write_ac3_tag(pb, track); |
3890 | 466 else if(track->enc->codec_id == CODEC_ID_ALAC) |
3453
3046c8e6ba4f
support alac in ipod m4a format, tested on quicktime
bcoudurier
parents:
3452
diff
changeset
|
467 mov_write_extradata_tag(pb, track); |
2838
6bea49ef18b1
use generic 'glbl' atom if extradata is present but no specific method is known
bcoudurier
parents:
2802
diff
changeset
|
468 else if(track->vosLen > 0) |
6bea49ef18b1
use generic 'glbl' atom if extradata is present but no specific method is known
bcoudurier
parents:
2802
diff
changeset
|
469 mov_write_glbl_tag(pb, track); |
1083 | 470 |
3455 | 471 return updateSize(pb, pos); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
472 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
473 |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
474 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
|
475 { |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
476 put_be32(pb, 0xf); /* size */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
477 put_tag(pb, "d263"); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
478 put_tag(pb, "FFMP"); |
1240 | 479 put_byte(pb, 0); /* decoder version */ |
480 /* FIXME use AVCodecContext level/profile, when encoder will set values */ | |
481 put_byte(pb, 0xa); /* level */ | |
482 put_byte(pb, 0); /* profile */ | |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
483 return 0xf; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
484 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
485 |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
486 /* 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
|
487 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
|
488 { |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
489 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
|
490 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
|
491 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
|
492 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
|
493 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
|
494 put_be32(pb, 0xc0000000); |
885 | 495 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
|
496 return 0x15; |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
497 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
498 |
2921 | 499 static int mov_write_avcc_tag(ByteIOContext *pb, MOVTrack *track) |
500 { | |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3909
diff
changeset
|
501 int64_t pos = url_ftell(pb); |
2921 | 502 |
503 put_be32(pb, 0); | |
504 put_tag(pb, "avcC"); | |
2927
b75a49790f31
add a ff_ prefix to newly exported functions from avc.c
aurel
parents:
2922
diff
changeset
|
505 ff_isom_write_avcc(pb, track->vosData, track->vosLen); |
1006
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
506 return updateSize(pb, pos); |
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 |
2588 | 509 /* also used by all avid codecs (dv, imx, meridien) and their variants */ |
510 static int mov_write_avid_tag(ByteIOContext *pb, MOVTrack *track) | |
511 { | |
512 int i; | |
513 put_be32(pb, 24); /* size */ | |
514 put_tag(pb, "ACLR"); | |
515 put_tag(pb, "ACLR"); | |
516 put_tag(pb, "0001"); | |
517 put_be32(pb, 1); /* yuv 1 / rgb 2 ? */ | |
518 put_be32(pb, 0); /* unknown */ | |
519 | |
520 put_be32(pb, 24); /* size */ | |
521 put_tag(pb, "APRG"); | |
522 put_tag(pb, "APRG"); | |
523 put_tag(pb, "0001"); | |
524 put_be32(pb, 1); /* unknown */ | |
525 put_be32(pb, 0); /* unknown */ | |
526 | |
527 put_be32(pb, 120); /* size */ | |
528 put_tag(pb, "ARES"); | |
529 put_tag(pb, "ARES"); | |
530 put_tag(pb, "0001"); | |
531 put_be32(pb, AV_RB32(track->vosData + 0x28)); /* dnxhd cid, some id ? */ | |
532 put_be32(pb, track->enc->width); | |
533 /* values below are based on samples created with quicktime and avid codecs */ | |
534 if (track->vosData[5] & 2) { // interlaced | |
535 put_be32(pb, track->enc->height/2); | |
536 put_be32(pb, 2); /* unknown */ | |
537 put_be32(pb, 0); /* unknown */ | |
538 put_be32(pb, 4); /* unknown */ | |
539 } else { | |
540 put_be32(pb, track->enc->height); | |
541 put_be32(pb, 1); /* unknown */ | |
542 put_be32(pb, 0); /* unknown */ | |
2802 | 543 if (track->enc->height == 1080) |
544 put_be32(pb, 5); /* unknown */ | |
545 else | |
546 put_be32(pb, 6); /* unknown */ | |
2588 | 547 } |
548 /* padding */ | |
549 for (i = 0; i < 10; i++) | |
550 put_be64(pb, 0); | |
551 | |
552 /* extra padding for stsd needed */ | |
553 put_be32(pb, 0); | |
554 return 0; | |
555 } | |
556 | |
4824
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
557 static int mp4_get_codec_tag(AVFormatContext *s, MOVTrack *track) |
1000 | 558 { |
1080 | 559 int tag = track->enc->codec_tag; |
4825 | 560 |
5058
33a244b7ca65
Add ff_ prefixes to exported symbols in libavformat/riff.h.
diego
parents:
4996
diff
changeset
|
561 if (!ff_codec_get_tag(ff_mp4_obj_type, track->enc->codec_id)) |
4825 | 562 return 0; |
563 | |
564 if (track->enc->codec_id == CODEC_ID_H264) tag = MKTAG('a','v','c','1'); | |
565 else if (track->enc->codec_id == CODEC_ID_AC3) tag = MKTAG('a','c','-','3'); | |
566 else if (track->enc->codec_id == CODEC_ID_DIRAC) tag = MKTAG('d','r','a','c'); | |
567 else if (track->enc->codec_id == CODEC_ID_MOV_TEXT) tag = MKTAG('t','x','3','g'); | |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5792
diff
changeset
|
568 else if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO) tag = MKTAG('m','p','4','v'); |
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5792
diff
changeset
|
569 else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO) tag = MKTAG('m','p','4','a'); |
4824
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
570 |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
571 return tag; |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
572 } |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
573 |
4832 | 574 static const AVCodecTag codec_ipod_tags[] = { |
575 { CODEC_ID_H264, MKTAG('a','v','c','1') }, | |
576 { CODEC_ID_MPEG4, MKTAG('m','p','4','v') }, | |
577 { CODEC_ID_AAC, MKTAG('m','p','4','a') }, | |
578 { CODEC_ID_ALAC, MKTAG('a','l','a','c') }, | |
579 { CODEC_ID_AC3, MKTAG('a','c','-','3') }, | |
580 { CODEC_ID_MOV_TEXT, MKTAG('t','x','3','g') }, | |
581 { CODEC_ID_MOV_TEXT, MKTAG('t','e','x','t') }, | |
582 { CODEC_ID_NONE, 0 }, | |
583 }; | |
584 | |
4824
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
585 static int ipod_get_codec_tag(AVFormatContext *s, MOVTrack *track) |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
586 { |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
587 int tag = track->enc->codec_tag; |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
588 |
4828 | 589 // keep original tag for subs, ipod supports both formats |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5792
diff
changeset
|
590 if (!(track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE && |
4825 | 591 (tag == MKTAG('t','x','3','g') || |
4829 | 592 tag == MKTAG('t','e','x','t')))) |
5058
33a244b7ca65
Add ff_ prefixes to exported symbols in libavformat/riff.h.
diego
parents:
4996
diff
changeset
|
593 tag = ff_codec_get_tag(codec_ipod_tags, track->enc->codec_id); |
4830
8fcb2c0d6362
cosmetics, add empty line and remove useless braces
bcoudurier
parents:
4829
diff
changeset
|
594 |
5556
c35e1d2373c7
Use av_match_ext() rather than the deprecated match_ext(), fix
stefano
parents:
5492
diff
changeset
|
595 if (!av_match_ext(s->filename, "m4a") && !av_match_ext(s->filename, "m4v")) |
4825 | 596 av_log(s, AV_LOG_WARNING, "Warning, extension is not .m4a nor .m4v " |
597 "Quicktime/Ipod might not play the file\n"); | |
4824
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
598 |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
599 return tag; |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
600 } |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
601 |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
602 static int mov_get_dv_codec_tag(AVFormatContext *s, MOVTrack *track) |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
603 { |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
604 int tag; |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
605 |
4825 | 606 if (track->enc->height == 480) /* NTSC */ |
607 if (track->enc->pix_fmt == PIX_FMT_YUV422P) tag = MKTAG('d','v','5','n'); | |
608 else tag = MKTAG('d','v','c',' '); | |
609 else if (track->enc->pix_fmt == PIX_FMT_YUV422P) tag = MKTAG('d','v','5','p'); | |
610 else if (track->enc->pix_fmt == PIX_FMT_YUV420P) tag = MKTAG('d','v','c','p'); | |
611 else tag = MKTAG('d','v','p','p'); | |
4824
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
612 |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
613 return tag; |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
614 } |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
615 |
4832 | 616 static const struct { |
617 enum PixelFormat pix_fmt; | |
618 uint32_t tag; | |
619 unsigned bps; | |
620 } mov_pix_fmt_tags[] = { | |
621 { PIX_FMT_YUYV422, MKTAG('y','u','v','s'), 0 }, | |
622 { PIX_FMT_UYVY422, MKTAG('2','v','u','y'), 0 }, | |
623 { PIX_FMT_BGR555, MKTAG('r','a','w',' '), 16 }, | |
4920
7d8344d28ab9
rgb555le, rgb565le, rgb565be, bgr24 in .mov muxing
bcoudurier
parents:
4919
diff
changeset
|
624 { PIX_FMT_RGB555LE,MKTAG('L','5','5','5'), 16 }, |
7d8344d28ab9
rgb555le, rgb565le, rgb565be, bgr24 in .mov muxing
bcoudurier
parents:
4919
diff
changeset
|
625 { PIX_FMT_RGB565LE,MKTAG('L','5','6','5'), 16 }, |
7d8344d28ab9
rgb555le, rgb565le, rgb565be, bgr24 in .mov muxing
bcoudurier
parents:
4919
diff
changeset
|
626 { PIX_FMT_RGB565BE,MKTAG('B','5','6','5'), 16 }, |
4832 | 627 { PIX_FMT_RGB24, MKTAG('r','a','w',' '), 24 }, |
4920
7d8344d28ab9
rgb555le, rgb565le, rgb565be, bgr24 in .mov muxing
bcoudurier
parents:
4919
diff
changeset
|
628 { PIX_FMT_BGR24, MKTAG('2','4','B','G'), 24 }, |
4918 | 629 { PIX_FMT_ARGB, MKTAG('r','a','w',' '), 32 }, |
4919 | 630 { PIX_FMT_BGRA, MKTAG('B','G','R','A'), 32 }, |
4917 | 631 { PIX_FMT_RGBA, MKTAG('R','G','B','A'), 32 }, |
4832 | 632 }; |
633 | |
4824
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
634 static int mov_get_rawvideo_codec_tag(AVFormatContext *s, MOVTrack *track) |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
635 { |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
636 int tag = track->enc->codec_tag; |
4825 | 637 int i; |
638 | |
639 for (i = 0; i < FF_ARRAY_ELEMS(mov_pix_fmt_tags); i++) { | |
640 if (track->enc->pix_fmt == mov_pix_fmt_tags[i].pix_fmt) { | |
641 tag = mov_pix_fmt_tags[i].tag; | |
642 track->enc->bits_per_coded_sample = mov_pix_fmt_tags[i].bps; | |
643 break; | |
644 } | |
645 } | |
4824
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
646 |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
647 return tag; |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
648 } |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
649 |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
650 static int mov_get_codec_tag(AVFormatContext *s, MOVTrack *track) |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
651 { |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
652 int tag = track->enc->codec_tag; |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
653 |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
654 if (!tag || (track->enc->strict_std_compliance >= FF_COMPLIANCE_NORMAL && |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
655 (tag == MKTAG('d','v','c','p') || |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
656 track->enc->codec_id == CODEC_ID_RAWVIDEO || |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
657 av_get_bits_per_sample(track->enc->codec_id)))) { // pcm audio |
4830
8fcb2c0d6362
cosmetics, add empty line and remove useless braces
bcoudurier
parents:
4829
diff
changeset
|
658 if (track->enc->codec_id == CODEC_ID_DVVIDEO) |
4824
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
659 tag = mov_get_dv_codec_tag(s, track); |
4830
8fcb2c0d6362
cosmetics, add empty line and remove useless braces
bcoudurier
parents:
4829
diff
changeset
|
660 else if (track->enc->codec_id == CODEC_ID_RAWVIDEO) |
4824
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
661 tag = mov_get_rawvideo_codec_tag(s, track); |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5792
diff
changeset
|
662 else if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO) { |
5058
33a244b7ca65
Add ff_ prefixes to exported symbols in libavformat/riff.h.
diego
parents:
4996
diff
changeset
|
663 tag = ff_codec_get_tag(codec_movvideo_tags, track->enc->codec_id); |
4831 | 664 if (!tag) { // if no mac fcc found, try with Microsoft tags |
5058
33a244b7ca65
Add ff_ prefixes to exported symbols in libavformat/riff.h.
diego
parents:
4996
diff
changeset
|
665 tag = ff_codec_get_tag(ff_codec_bmp_tags, track->enc->codec_id); |
4831 | 666 if (tag) |
667 av_log(s, AV_LOG_INFO, "Warning, using MS style video codec tag, " | |
668 "the file may be unplayable!\n"); | |
669 } | |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5792
diff
changeset
|
670 } else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO) { |
5058
33a244b7ca65
Add ff_ prefixes to exported symbols in libavformat/riff.h.
diego
parents:
4996
diff
changeset
|
671 tag = ff_codec_get_tag(codec_movaudio_tags, track->enc->codec_id); |
4831 | 672 if (!tag) { // if no mac fcc found, try with Microsoft tags |
5058
33a244b7ca65
Add ff_ prefixes to exported symbols in libavformat/riff.h.
diego
parents:
4996
diff
changeset
|
673 int ms_tag = ff_codec_get_tag(ff_codec_wav_tags, track->enc->codec_id); |
4831 | 674 if (ms_tag) { |
675 tag = MKTAG('m', 's', ((ms_tag >> 8) & 0xff), (ms_tag & 0xff)); | |
676 av_log(s, AV_LOG_INFO, "Warning, using MS style audio codec tag, " | |
677 "the file may be unplayable!\n"); | |
2979 | 678 } |
4831 | 679 } |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5792
diff
changeset
|
680 } else if (track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE) |
5058
33a244b7ca65
Add ff_ prefixes to exported symbols in libavformat/riff.h.
diego
parents:
4996
diff
changeset
|
681 tag = ff_codec_get_tag(ff_codec_movsubtitle_tags, track->enc->codec_id); |
2978
8dcdecbbf7e6
correctly and only set standard stsd fourcc for mp4/3gp
bcoudurier
parents:
2977
diff
changeset
|
682 } |
4825 | 683 |
1000 | 684 return tag; |
685 } | |
686 | |
4832 | 687 static const AVCodecTag codec_3gp_tags[] = { |
688 { CODEC_ID_H263, MKTAG('s','2','6','3') }, | |
689 { CODEC_ID_H264, MKTAG('a','v','c','1') }, | |
690 { CODEC_ID_MPEG4, MKTAG('m','p','4','v') }, | |
691 { CODEC_ID_AAC, MKTAG('m','p','4','a') }, | |
692 { CODEC_ID_AMR_NB, MKTAG('s','a','m','r') }, | |
693 { CODEC_ID_AMR_WB, MKTAG('s','a','w','b') }, | |
694 { CODEC_ID_MOV_TEXT, MKTAG('t','x','3','g') }, | |
695 { CODEC_ID_NONE, 0 }, | |
696 }; | |
697 | |
4824
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
698 static int mov_find_codec_tag(AVFormatContext *s, MOVTrack *track) |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
699 { |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
700 int tag = track->enc->codec_tag; |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
701 |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
702 if (track->mode == MODE_MP4 || track->mode == MODE_PSP) |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
703 tag = mp4_get_codec_tag(s, track); |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
704 else if (track->mode == MODE_IPOD) |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
705 tag = ipod_get_codec_tag(s, track); |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
706 else if (track->mode & MODE_3GP) |
5058
33a244b7ca65
Add ff_ prefixes to exported symbols in libavformat/riff.h.
diego
parents:
4996
diff
changeset
|
707 tag = ff_codec_get_tag(codec_3gp_tags, track->enc->codec_id); |
4824
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
708 else |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
709 tag = mov_get_codec_tag(s, track); |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
710 |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
711 return tag; |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
712 } |
ef55a8830c20
split mov_find_codec_tag in separate per format functions
bcoudurier
parents:
4819
diff
changeset
|
713 |
3143 | 714 /** Write uuid atom. |
715 * Needed to make file play in iPods running newest firmware | |
716 * goes after avcC atom in moov.trak.mdia.minf.stbl.stsd.avc1 | |
717 */ | |
718 static int mov_write_uuid_tag_ipod(ByteIOContext *pb) | |
719 { | |
720 put_be32(pb, 28); | |
721 put_tag(pb, "uuid"); | |
722 put_be32(pb, 0x6b6840f2); | |
723 put_be32(pb, 0x5f244fc5); | |
724 put_be32(pb, 0xba39a51b); | |
725 put_be32(pb, 0xcf0323f3); | |
726 put_be32(pb, 0x0); | |
727 return 28; | |
728 } | |
729 | |
4193
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
730 static int mov_write_subtitle_tag(ByteIOContext *pb, MOVTrack *track) |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
731 { |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
732 int64_t pos = url_ftell(pb); |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
733 put_be32(pb, 0); /* size */ |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
734 put_le32(pb, track->tag); // store it byteswapped |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
735 put_be32(pb, 0); /* Reserved */ |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
736 put_be16(pb, 0); /* Reserved */ |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
737 put_be16(pb, 1); /* Data-reference index */ |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
738 |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
739 if (track->enc->extradata_size) |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
740 put_buffer(pb, track->enc->extradata, track->enc->extradata_size); |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
741 |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
742 return updateSize(pb, pos); |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
743 } |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
744 |
3446 | 745 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
|
746 { |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3909
diff
changeset
|
747 int64_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
|
748 char compressor_name[32]; |
422 | 749 |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
750 put_be32(pb, 0); /* size */ |
1080 | 751 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
|
752 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
|
753 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
|
754 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
|
755 |
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
|
756 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
|
757 put_be16(pb, 0); /* Codec stream revision (=0) */ |
1238 | 758 if (track->mode == MODE_MOV) { |
1239 | 759 put_tag(pb, "FFMP"); /* Vendor */ |
760 if(track->enc->codec_id == CODEC_ID_RAWVIDEO) { | |
761 put_be32(pb, 0); /* Temporal Quality */ | |
762 put_be32(pb, 0x400); /* Spatial Quality = lossless*/ | |
763 } else { | |
764 put_be32(pb, 0x200); /* Temporal Quality = normal */ | |
765 put_be32(pb, 0x200); /* Spatial Quality = normal */ | |
766 } | |
1238 | 767 } else { |
768 put_be32(pb, 0); /* Reserved */ | |
769 put_be32(pb, 0); /* Reserved */ | |
770 put_be32(pb, 0); /* Reserved */ | |
771 } | |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
772 put_be16(pb, track->enc->width); /* Video width */ |
4463
0cd7acf426f3
write active picture height for d-10/imx in mov
bcoudurier
parents:
4251
diff
changeset
|
773 put_be16(pb, track->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
|
774 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
|
775 put_be32(pb, 0x00480000); /* Vertical resolution 72dpi */ |
399
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
776 put_be32(pb, 0); /* Data size (= 0) */ |
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
777 put_be16(pb, 1); /* Frame count (= 1) */ |
885 | 778 |
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
|
779 memset(compressor_name,0,32); |
1238 | 780 /* FIXME not sure, ISO 14496-1 draft where it shall be set to 0 */ |
781 if (track->mode == MODE_MOV && 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
|
782 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
|
783 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
|
784 put_buffer(pb, compressor_name, 31); |
885 | 785 |
3908
1d3d17de20ba
Bump Major version, this commit is almost just renaming bits_per_sample to
michael
parents:
3907
diff
changeset
|
786 if (track->mode == MODE_MOV && track->enc->bits_per_coded_sample) |
1d3d17de20ba
Bump Major version, this commit is almost just renaming bits_per_sample to
michael
parents:
3907
diff
changeset
|
787 put_be16(pb, track->enc->bits_per_coded_sample); |
2992 | 788 else |
789 put_be16(pb, 0x18); /* Reserved */ | |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
790 put_be16(pb, 0xffff); /* Reserved */ |
2977
b5ad3169a579
write esds atom when mpeg-4 systems tags are used
bcoudurier
parents:
2975
diff
changeset
|
791 if(track->tag == MKTAG('m','p','4','v')) |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
792 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
|
793 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
|
794 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
|
795 else if(track->enc->codec_id == CODEC_ID_SVQ3) |
885 | 796 mov_write_svq3_tag(pb); |
3158 | 797 else if(track->enc->codec_id == CODEC_ID_DNXHD) |
798 mov_write_avid_tag(pb, track); | |
3143 | 799 else if(track->enc->codec_id == CODEC_ID_H264) { |
1006
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
800 mov_write_avcc_tag(pb, track); |
3143 | 801 if(track->mode == MODE_IPOD) |
802 mov_write_uuid_tag_ipod(pb); | |
3203 | 803 } else if(track->vosLen > 0) |
2838
6bea49ef18b1
use generic 'glbl' atom if extradata is present but no specific method is known
bcoudurier
parents:
2802
diff
changeset
|
804 mov_write_glbl_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
|
805 |
3455 | 806 return updateSize(pb, pos); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
807 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
808 |
3446 | 809 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
|
810 { |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3909
diff
changeset
|
811 int64_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
|
812 put_be32(pb, 0); /* size */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
813 put_tag(pb, "stsd"); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
814 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
|
815 put_be32(pb, 1); /* entry count */ |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5792
diff
changeset
|
816 if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO) |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
817 mov_write_video_tag(pb, track); |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5792
diff
changeset
|
818 else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO) |
259
e091218eccd2
mov/mp4/3gp muxer improvements patch by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
241
diff
changeset
|
819 mov_write_audio_tag(pb, track); |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5792
diff
changeset
|
820 else if (track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE) |
4193
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
821 mov_write_subtitle_tag(pb, track); |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
822 return updateSize(pb, pos); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
823 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
824 |
3446 | 825 static int mov_write_ctts_tag(ByteIOContext *pb, MOVTrack *track) |
971
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
826 { |
4079 | 827 MOVStts *ctts_entries; |
971
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
828 uint32_t entries = 0; |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
829 uint32_t atom_size; |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
830 int i; |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
831 |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
832 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
|
833 ctts_entries[0].count = 1; |
1129 | 834 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
|
835 for (i=1; i<track->entry; i++) { |
1129 | 836 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
|
837 ctts_entries[entries].count++; /* compress */ |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
838 } else { |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
839 entries++; |
1129 | 840 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
|
841 ctts_entries[entries].count = 1; |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
842 } |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
843 } |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
844 entries++; /* last one */ |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
845 atom_size = 16 + (entries * 8); |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
846 put_be32(pb, atom_size); /* size */ |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
847 put_tag(pb, "ctts"); |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
848 put_be32(pb, 0); /* version & flags */ |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
849 put_be32(pb, entries); /* entry count */ |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
850 for (i=0; i<entries; i++) { |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
851 put_be32(pb, ctts_entries[i].count); |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
852 put_be32(pb, ctts_entries[i].duration); |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
853 } |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
854 av_free(ctts_entries); |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
855 return atom_size; |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
856 } |
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
857 |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
858 /* Time to sample atom */ |
3446 | 859 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
|
860 { |
4079 | 861 MOVStts *stts_entries; |
1437 | 862 uint32_t entries = -1; |
863 uint32_t atom_size; | |
864 int i; | |
865 | |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5792
diff
changeset
|
866 if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO && !track->audio_vbr) { |
1437 | 867 stts_entries = av_malloc(sizeof(*stts_entries)); /* one entry */ |
868 stts_entries[0].count = track->sampleCount; | |
869 stts_entries[0].duration = 1; | |
870 entries = 1; | |
871 } else { | |
872 stts_entries = av_malloc(track->entry * sizeof(*stts_entries)); /* worst case */ | |
873 for (i=0; i<track->entry; i++) { | |
874 int64_t duration = i + 1 == track->entry ? | |
875 track->trackDuration - track->cluster[i].dts + track->cluster[0].dts : /* readjusting */ | |
876 track->cluster[i+1].dts - track->cluster[i].dts; | |
877 if (i && duration == stts_entries[entries].duration) { | |
878 stts_entries[entries].count++; /* compress */ | |
879 } else { | |
880 entries++; | |
881 stts_entries[entries].duration = duration; | |
882 stts_entries[entries].count = 1; | |
883 } | |
884 } | |
885 entries++; /* last one */ | |
886 } | |
887 atom_size = 16 + (entries * 8); | |
888 put_be32(pb, atom_size); /* size */ | |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
889 put_tag(pb, "stts"); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
890 put_be32(pb, 0); /* version & flags */ |
1437 | 891 put_be32(pb, entries); /* entry count */ |
892 for (i=0; i<entries; i++) { | |
893 put_be32(pb, stts_entries[i].count); | |
894 put_be32(pb, stts_entries[i].duration); | |
895 } | |
896 av_free(stts_entries); | |
897 return atom_size; | |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
898 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
899 |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
900 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
|
901 { |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
902 put_be32(pb, 28); /* size */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
903 put_tag(pb, "dref"); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
904 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
|
905 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
|
906 |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
907 put_be32(pb, 0xc); /* size */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
908 put_tag(pb, "url "); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
909 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
|
910 |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
911 return 28; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
912 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
913 |
3446 | 914 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
|
915 { |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3909
diff
changeset
|
916 int64_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
|
917 put_be32(pb, 0); /* size */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
918 put_tag(pb, "stbl"); |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
919 mov_write_stsd_tag(pb, track); |
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
920 mov_write_stts_tag(pb, track); |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5792
diff
changeset
|
921 if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO && |
3192 | 922 track->hasKeyframes && track->hasKeyframes < track->entry) |
4941 | 923 mov_write_stss_tag(pb, track, MOV_SYNC_SAMPLE); |
924 if (track->mode == MODE_MOV && track->flags & MOV_TRACK_STPS) | |
925 mov_write_stss_tag(pb, track, MOV_PARTIAL_SYNC_SAMPLE); | |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5792
diff
changeset
|
926 if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO && |
4941 | 927 track->flags & MOV_TRACK_CTTS) |
971
43f85eba04c4
CTTS support patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com>)
michael
parents:
943
diff
changeset
|
928 mov_write_ctts_tag(pb, track); |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
929 mov_write_stsc_tag(pb, track); |
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
930 mov_write_stsz_tag(pb, track); |
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
931 mov_write_stco_tag(pb, track); |
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
932 return updateSize(pb, pos); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
933 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
934 |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
935 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
|
936 { |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3909
diff
changeset
|
937 int64_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
|
938 put_be32(pb, 0); /* size */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
939 put_tag(pb, "dinf"); |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
940 mov_write_dref_tag(pb); |
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
941 return updateSize(pb, pos); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
942 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
943 |
4193
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
944 static int mov_write_nmhd_tag(ByteIOContext *pb) |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
945 { |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
946 put_be32(pb, 12); |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
947 put_tag(pb, "nmhd"); |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
948 put_be32(pb, 0); |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
949 return 12; |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
950 } |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
951 |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
952 static int mov_write_gmhd_tag(ByteIOContext *pb) |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
953 { |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
954 put_be32(pb, 0x20); /* size */ |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
955 put_tag(pb, "gmhd"); |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
956 put_be32(pb, 0x18); /* gmin size */ |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
957 put_tag(pb, "gmin"); /* generic media info */ |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
958 put_be32(pb, 0); /* version & flags */ |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
959 put_be16(pb, 0x40); /* graphics mode = */ |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
960 put_be16(pb, 0x8000); /* opColor (r?) */ |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
961 put_be16(pb, 0x8000); /* opColor (g?) */ |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
962 put_be16(pb, 0x8000); /* opColor (b?) */ |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
963 put_be16(pb, 0); /* balance */ |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
964 put_be16(pb, 0); /* reserved */ |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
965 return 0x20; |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
966 } |
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
967 |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
968 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
|
969 { |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
970 put_be32(pb, 16); /* size */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
971 put_tag(pb, "smhd"); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
972 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
|
973 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
|
974 put_be16(pb, 0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
975 return 16; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
976 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
977 |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
978 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
|
979 { |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
980 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
|
981 put_tag(pb, "vmhd"); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
982 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
|
983 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
|
984 return 0x14; |
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 |
3446 | 987 static int mov_write_hdlr_tag(ByteIOContext *pb, MOVTrack *track) |
399
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
988 { |
4195 | 989 const char *hdlr, *descr = NULL, *hdlr_type = NULL; |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3909
diff
changeset
|
990 int64_t pos = url_ftell(pb); |
885 | 991 |
399
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
992 if (!track) { /* no media --> data handler */ |
887 | 993 hdlr = "dhlr"; |
994 hdlr_type = "url "; | |
995 descr = "DataHandler"; | |
399
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
996 } else { |
887 | 997 hdlr = (track->mode == MODE_MOV) ? "mhlr" : "\0\0\0\0"; |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5792
diff
changeset
|
998 if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO) { |
887 | 999 hdlr_type = "vide"; |
1000 descr = "VideoHandler"; | |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5792
diff
changeset
|
1001 } else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO) { |
887 | 1002 hdlr_type = "soun"; |
1003 descr = "SoundHandler"; | |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5792
diff
changeset
|
1004 } else if (track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE) { |
4699
59ee17ee14fa
write correct atoms based on tag and not format, fixes subs stream copy
bcoudurier
parents:
4698
diff
changeset
|
1005 if (track->tag == MKTAG('t','x','3','g')) hdlr_type = "sbtl"; |
4700 | 1006 else hdlr_type = "text"; |
4193
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
1007 descr = "SubtitleHandler"; |
887 | 1008 } |
399
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
1009 } |
885 | 1010 |
399
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
1011 put_be32(pb, 0); /* size */ |
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
1012 put_tag(pb, "hdlr"); |
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
1013 put_be32(pb, 0); /* Version & flags */ |
400
62e4ea840c52
* fixing 10l in movenc.c + updating regression patterns.
romansh
parents:
399
diff
changeset
|
1014 put_buffer(pb, hdlr, 4); /* handler */ |
399
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
1015 put_tag(pb, hdlr_type); /* handler type */ |
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
1016 put_be32(pb ,0); /* reserved */ |
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
1017 put_be32(pb ,0); /* reserved */ |
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
1018 put_be32(pb ,0); /* reserved */ |
4953
1b3487b81ac7
fix hdlr descr in mp4 which use c string, patch by Larbi Joubala, larbi dot joubala at resonate-mp4 dot com
bcoudurier
parents:
4941
diff
changeset
|
1019 if (!track || track->mode == MODE_MOV) |
1b3487b81ac7
fix hdlr descr in mp4 which use c string, patch by Larbi Joubala, larbi dot joubala at resonate-mp4 dot com
bcoudurier
parents:
4941
diff
changeset
|
1020 put_byte(pb, strlen(descr)); /* pascal string */ |
399
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
1021 put_buffer(pb, descr, strlen(descr)); /* handler description */ |
4953
1b3487b81ac7
fix hdlr descr in mp4 which use c string, patch by Larbi Joubala, larbi dot joubala at resonate-mp4 dot com
bcoudurier
parents:
4941
diff
changeset
|
1022 if (track && track->mode != MODE_MOV) |
1b3487b81ac7
fix hdlr descr in mp4 which use c string, patch by Larbi Joubala, larbi dot joubala at resonate-mp4 dot com
bcoudurier
parents:
4941
diff
changeset
|
1023 put_byte(pb, 0); /* c string */ |
399
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
1024 return updateSize(pb, pos); |
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
1025 } |
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
1026 |
3446 | 1027 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
|
1028 { |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3909
diff
changeset
|
1029 int64_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
|
1030 put_be32(pb, 0); /* size */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1031 put_tag(pb, "minf"); |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5792
diff
changeset
|
1032 if(track->enc->codec_type == AVMEDIA_TYPE_VIDEO) |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
1033 mov_write_vmhd_tag(pb); |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5792
diff
changeset
|
1034 else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO) |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
1035 mov_write_smhd_tag(pb); |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5792
diff
changeset
|
1036 else if (track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE) { |
4699
59ee17ee14fa
write correct atoms based on tag and not format, fixes subs stream copy
bcoudurier
parents:
4698
diff
changeset
|
1037 if (track->tag == MKTAG('t','e','x','t')) mov_write_gmhd_tag(pb); |
4700 | 1038 else mov_write_nmhd_tag(pb); |
4193
2d3be324c648
Add support for muxing mov/mp4/3gp timed text streams
conrad
parents:
4079
diff
changeset
|
1039 } |
399
6ab5454567b6
* making .mov files generated by ffmpeg compatible with Apple software.
romansh
parents:
397
diff
changeset
|
1040 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
|
1041 mov_write_hdlr_tag(pb, NULL); |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
1042 mov_write_dinf_tag(pb); |
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
1043 mov_write_stbl_tag(pb, track); |
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
1044 return updateSize(pb, pos); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1045 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1046 |
3446 | 1047 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
|
1048 { |
1037 | 1049 int version = track->trackDuration < INT32_MAX ? 0 : 1; |
1050 | |
1051 (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
|
1052 put_tag(pb, "mdhd"); |
1037 | 1053 put_byte(pb, version); |
1054 put_be24(pb, 0); /* flags */ | |
1055 if (version == 1) { | |
1056 put_be64(pb, track->time); | |
1057 put_be64(pb, track->time); | |
1058 } else { | |
1059 put_be32(pb, track->time); /* creation time */ | |
1060 put_be32(pb, track->time); /* modification time */ | |
1061 } | |
885 | 1062 put_be32(pb, track->timescale); /* time scale (sample rate for audio) */ |
1037 | 1063 (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
|
1064 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
|
1065 put_be16(pb, 0); /* reserved (quality) */ |
2102 | 1066 |
1067 if(version!=0 && track->mode == MODE_MOV){ | |
1068 av_log(NULL, AV_LOG_ERROR, | |
1069 "FATAL error, file duration too long for timebase, this file will not be\n" | |
2106 | 1070 "playable with quicktime. Choose a different timebase or a different\n" |
2102 | 1071 "container format\n"); |
1072 } | |
1073 | |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1074 return 32; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1075 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1076 |
3446 | 1077 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
|
1078 { |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3909
diff
changeset
|
1079 int64_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
|
1080 put_be32(pb, 0); /* size */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1081 put_tag(pb, "mdia"); |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
1082 mov_write_mdhd_tag(pb, track); |
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
1083 mov_write_hdlr_tag(pb, track); |
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
1084 mov_write_minf_tag(pb, track); |
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
1085 return updateSize(pb, pos); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1086 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1087 |
3759
27537074f2a9
convert every muxer/demuxer to write/read sample_aspect_ratio from/to
aurel
parents:
3526
diff
changeset
|
1088 static int mov_write_tkhd_tag(ByteIOContext *pb, MOVTrack *track, AVStream *st) |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1089 { |
5393 | 1090 int64_t duration = av_rescale_rnd(track->trackDuration, MOV_TIMESCALE, |
1091 track->timescale, AV_ROUND_UP); | |
1037 | 1092 int version = duration < INT32_MAX ? 0 : 1; |
1093 | |
1094 (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
|
1095 put_tag(pb, "tkhd"); |
1037 | 1096 put_byte(pb, version); |
1097 put_be24(pb, 0xf); /* flags (track enabled) */ | |
1098 if (version == 1) { | |
1099 put_be64(pb, track->time); | |
1100 put_be64(pb, track->time); | |
1101 } else { | |
1102 put_be32(pb, track->time); /* creation time */ | |
1103 put_be32(pb, track->time); /* modification time */ | |
1104 } | |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1105 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
|
1106 put_be32(pb, 0); /* reserved */ |
1037 | 1107 (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
|
1108 |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1109 put_be32(pb, 0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1110 put_be32(pb, 0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1111 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
|
1112 /* Volume, only for audio */ |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5792
diff
changeset
|
1113 if(track->enc->codec_type == AVMEDIA_TYPE_AUDIO) |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1114 put_be16(pb, 0x0100); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1115 else |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1116 put_be16(pb, 0); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1117 put_be16(pb, 0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1118 |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1119 /* Matrix structure */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1120 put_be32(pb, 0x00010000); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1121 put_be32(pb, 0x0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1122 put_be32(pb, 0x0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1123 put_be32(pb, 0x0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1124 put_be32(pb, 0x00010000); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1125 put_be32(pb, 0x0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1126 put_be32(pb, 0x0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1127 put_be32(pb, 0x0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1128 put_be32(pb, 0x40000000); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1129 |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1130 /* Track width and height, for visual only */ |
5993 | 1131 if(st && (track->enc->codec_type == AVMEDIA_TYPE_VIDEO || |
1132 track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE)) { | |
3759
27537074f2a9
convert every muxer/demuxer to write/read sample_aspect_ratio from/to
aurel
parents:
3526
diff
changeset
|
1133 double sample_aspect_ratio = av_q2d(st->sample_aspect_ratio); |
4463
0cd7acf426f3
write active picture height for d-10/imx in mov
bcoudurier
parents:
4251
diff
changeset
|
1134 if(!sample_aspect_ratio || track->height != track->enc->height) |
0cd7acf426f3
write active picture height for d-10/imx in mov
bcoudurier
parents:
4251
diff
changeset
|
1135 sample_aspect_ratio = 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
|
1136 put_be32(pb, sample_aspect_ratio * track->enc->width*0x10000); |
4463
0cd7acf426f3
write active picture height for d-10/imx in mov
bcoudurier
parents:
4251
diff
changeset
|
1137 put_be32(pb, track->height*0x10000); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1138 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1139 else { |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1140 put_be32(pb, 0); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1141 put_be32(pb, 0); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1142 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1143 return 0x5c; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1144 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1145 |
659
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1146 // 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
|
1147 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
|
1148 { |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1149 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
|
1150 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
|
1151 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
|
1152 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
|
1153 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
|
1154 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
|
1155 |
5393 | 1156 /* duration ... doesn't seem to effect psp */ |
1157 put_be32(pb, av_rescale_rnd(track->trackDuration, MOV_TIMESCALE, | |
1158 track->timescale, AV_ROUND_UP)); | |
659
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1159 |
1250 | 1160 put_be32(pb, track->cluster[0].cts); /* first pts is cts since dts is 0 */ |
659
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1161 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
|
1162 return 0x24; |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1163 } |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1164 |
5993 | 1165 static int mov_write_tref_tag(ByteIOContext *pb, MOVTrack *track) |
1166 { | |
1167 put_be32(pb, 20); // size | |
1168 put_tag(pb, "tref"); | |
1169 put_be32(pb, 12); // size (subatom) | |
1170 put_le32(pb, track->tref_tag); | |
1171 put_be32(pb, track->tref_id); | |
1172 return 20; | |
1173 } | |
1174 | |
659
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1175 // 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
|
1176 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
|
1177 { |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1178 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
|
1179 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
|
1180 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
|
1181 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
|
1182 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
|
1183 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
|
1184 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
|
1185 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
|
1186 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
|
1187 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
|
1188 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
|
1189 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
|
1190 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
|
1191 return 0x34; |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1192 } |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1193 |
3759
27537074f2a9
convert every muxer/demuxer to write/read sample_aspect_ratio from/to
aurel
parents:
3526
diff
changeset
|
1194 static int mov_write_trak_tag(ByteIOContext *pb, MOVTrack *track, AVStream *st) |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1195 { |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3909
diff
changeset
|
1196 int64_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
|
1197 put_be32(pb, 0); /* size */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1198 put_tag(pb, "trak"); |
3759
27537074f2a9
convert every muxer/demuxer to write/read sample_aspect_ratio from/to
aurel
parents:
3526
diff
changeset
|
1199 mov_write_tkhd_tag(pb, track, st); |
4941 | 1200 if (track->mode == MODE_PSP || track->flags & MOV_TRACK_CTTS) |
659
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1201 mov_write_edts_tag(pb, track); // PSP Movies require edts box |
5993 | 1202 if (track->tref_tag) |
1203 mov_write_tref_tag(pb, track); | |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
1204 mov_write_mdia_tag(pb, track); |
885 | 1205 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
|
1206 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
|
1207 return updateSize(pb, pos); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1208 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1209 |
683
095009fc2f35
kill warnings patch by (M«©ns Rullg«©rd <mru inprovide com>)
michael
parents:
677
diff
changeset
|
1210 #if 0 |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1211 /* TODO: Not sorted out, but not necessary either */ |
4609
065557d6fffb
Rename movenc.c MOVContext to MOVMuxContext, since MOVContext is already used
rbultje
parents:
4587
diff
changeset
|
1212 static int mov_write_iods_tag(ByteIOContext *pb, MOVMuxContext *mov) |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1213 { |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1214 put_be32(pb, 0x15); /* size */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1215 put_tag(pb, "iods"); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1216 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
|
1217 put_be16(pb, 0x1007); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1218 put_byte(pb, 0); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1219 put_be16(pb, 0x4fff); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1220 put_be16(pb, 0xfffe); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1221 put_be16(pb, 0x01ff); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1222 return 0x15; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1223 } |
683
095009fc2f35
kill warnings patch by (M«©ns Rullg«©rd <mru inprovide com>)
michael
parents:
677
diff
changeset
|
1224 #endif |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1225 |
4609
065557d6fffb
Rename movenc.c MOVContext to MOVMuxContext, since MOVContext is already used
rbultje
parents:
4587
diff
changeset
|
1226 static int mov_write_mvhd_tag(ByteIOContext *pb, MOVMuxContext *mov) |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1227 { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
1228 int maxTrackID = 1, i; |
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
1229 int64_t maxTrackLenTemp, maxTrackLen = 0; |
1037 | 1230 int version; |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1231 |
1131 | 1232 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
|
1233 if(mov->tracks[i].entry > 0) { |
5393 | 1234 maxTrackLenTemp = av_rescale_rnd(mov->tracks[i].trackDuration, |
1235 MOV_TIMESCALE, | |
1236 mov->tracks[i].timescale, | |
1237 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
|
1238 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
|
1239 maxTrackLen = maxTrackLenTemp; |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1240 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
|
1241 maxTrackID = mov->tracks[i].trackID; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1242 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1243 } |
1037 | 1244 |
1245 version = maxTrackLen < UINT32_MAX ? 0 : 1; | |
1246 (version == 1) ? put_be32(pb, 120) : put_be32(pb, 108); /* size */ | |
1247 put_tag(pb, "mvhd"); | |
1248 put_byte(pb, version); | |
1249 put_be24(pb, 0); /* flags */ | |
1250 if (version == 1) { | |
1251 put_be64(pb, mov->time); | |
1252 put_be64(pb, mov->time); | |
1253 } else { | |
1254 put_be32(pb, mov->time); /* creation time */ | |
1255 put_be32(pb, mov->time); /* modification time */ | |
1256 } | |
5393 | 1257 put_be32(pb, MOV_TIMESCALE); |
1037 | 1258 (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
|
1259 |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1260 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
|
1261 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
|
1262 put_be16(pb, 0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1263 put_be32(pb, 0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1264 put_be32(pb, 0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1265 |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1266 /* Matrix structure */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1267 put_be32(pb, 0x00010000); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1268 put_be32(pb, 0x0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1269 put_be32(pb, 0x0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1270 put_be32(pb, 0x0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1271 put_be32(pb, 0x00010000); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1272 put_be32(pb, 0x0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1273 put_be32(pb, 0x0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1274 put_be32(pb, 0x0); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1275 put_be32(pb, 0x40000000); /* reserved */ |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1276 |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1277 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
|
1278 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
|
1279 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
|
1280 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
|
1281 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
|
1282 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
|
1283 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
|
1284 return 0x6c; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1285 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1286 |
4609
065557d6fffb
Rename movenc.c MOVContext to MOVMuxContext, since MOVContext is already used
rbultje
parents:
4587
diff
changeset
|
1287 static int mov_write_itunes_hdlr_tag(ByteIOContext *pb, MOVMuxContext *mov, |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1288 AVFormatContext *s) |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1289 { |
5947
8b59caee931c
Predicting the size of the hdlr, string data and trkn tags in the MOV muxer
thardin
parents:
5913
diff
changeset
|
1290 put_be32(pb, 33); /* size */ |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1291 put_tag(pb, "hdlr"); |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1292 put_be32(pb, 0); |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1293 put_be32(pb, 0); |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1294 put_tag(pb, "mdir"); |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1295 put_tag(pb, "appl"); |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1296 put_be32(pb, 0); |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1297 put_be32(pb, 0); |
5375
222bbba5fd35
Do not write an extra byte in the iTunes 'hdlr' tag. The files on iTMS have an
jbr
parents:
5058
diff
changeset
|
1298 put_byte(pb, 0); |
5947
8b59caee931c
Predicting the size of the hdlr, string data and trkn tags in the MOV muxer
thardin
parents:
5913
diff
changeset
|
1299 return 33; |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1300 } |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1301 |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1302 /* helper function to write a data tag with the specified string as data */ |
4587
b41ab5937218
movenc: add muxing of language along with metadata tags when available
aurel
parents:
4586
diff
changeset
|
1303 static int mov_write_string_data_tag(ByteIOContext *pb, const char *data, int lang, int long_style) |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1304 { |
1094 | 1305 if(long_style){ |
5947
8b59caee931c
Predicting the size of the hdlr, string data and trkn tags in the MOV muxer
thardin
parents:
5913
diff
changeset
|
1306 int size = 16 + strlen(data); |
8b59caee931c
Predicting the size of the hdlr, string data and trkn tags in the MOV muxer
thardin
parents:
5913
diff
changeset
|
1307 put_be32(pb, size); /* size */ |
1094 | 1308 put_tag(pb, "data"); |
1309 put_be32(pb, 1); | |
1310 put_be32(pb, 0); | |
1311 put_buffer(pb, data, strlen(data)); | |
5947
8b59caee931c
Predicting the size of the hdlr, string data and trkn tags in the MOV muxer
thardin
parents:
5913
diff
changeset
|
1312 return size; |
1094 | 1313 }else{ |
5792
2fb291f12e5f
Fix encoder metadata string langcode in mov muxer
bcoudurier
parents:
5791
diff
changeset
|
1314 if (!lang) |
2fb291f12e5f
Fix encoder metadata string langcode in mov muxer
bcoudurier
parents:
5791
diff
changeset
|
1315 lang = ff_mov_iso639_to_lang("und", 1); |
1094 | 1316 put_be16(pb, strlen(data)); /* string length */ |
4587
b41ab5937218
movenc: add muxing of language along with metadata tags when available
aurel
parents:
4586
diff
changeset
|
1317 put_be16(pb, lang); |
1094 | 1318 put_buffer(pb, data, strlen(data)); |
1319 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
|
1320 } |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1321 } |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1322 |
4587
b41ab5937218
movenc: add muxing of language along with metadata tags when available
aurel
parents:
4586
diff
changeset
|
1323 static int mov_write_string_tag(ByteIOContext *pb, const char *name, const char *value, int lang, int long_style){ |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1324 int size = 0; |
3024
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1325 if (value && value[0]) { |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3909
diff
changeset
|
1326 int64_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
|
1327 put_be32(pb, 0); /* size */ |
1094 | 1328 put_tag(pb, name); |
4587
b41ab5937218
movenc: add muxing of language along with metadata tags when available
aurel
parents:
4586
diff
changeset
|
1329 mov_write_string_data_tag(pb, value, lang, long_style); |
1094 | 1330 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
|
1331 } |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1332 return size; |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1333 } |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1334 |
4584 | 1335 static int mov_write_string_metadata(AVFormatContext *s, ByteIOContext *pb, |
1336 const char *name, const char *tag, | |
1337 int long_style) | |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1338 { |
4587
b41ab5937218
movenc: add muxing of language along with metadata tags when available
aurel
parents:
4586
diff
changeset
|
1339 int l, lang = 0, len, len2; |
b41ab5937218
movenc: add muxing of language along with metadata tags when available
aurel
parents:
4586
diff
changeset
|
1340 AVMetadataTag *t, *t2 = NULL; |
b41ab5937218
movenc: add muxing of language along with metadata tags when available
aurel
parents:
4586
diff
changeset
|
1341 char tag2[16]; |
4584 | 1342 |
1343 if (!(t = av_metadata_get(s->metadata, tag, NULL, 0))) | |
1094 | 1344 return 0; |
4584 | 1345 |
4587
b41ab5937218
movenc: add muxing of language along with metadata tags when available
aurel
parents:
4586
diff
changeset
|
1346 len = strlen(t->key); |
b41ab5937218
movenc: add muxing of language along with metadata tags when available
aurel
parents:
4586
diff
changeset
|
1347 snprintf(tag2, sizeof(tag2), "%s-", tag); |
b41ab5937218
movenc: add muxing of language along with metadata tags when available
aurel
parents:
4586
diff
changeset
|
1348 while ((t2 = av_metadata_get(s->metadata, tag2, t2, AV_METADATA_IGNORE_SUFFIX))) { |
b41ab5937218
movenc: add muxing of language along with metadata tags when available
aurel
parents:
4586
diff
changeset
|
1349 len2 = strlen(t2->key); |
b41ab5937218
movenc: add muxing of language along with metadata tags when available
aurel
parents:
4586
diff
changeset
|
1350 if (len2 == len+4 && !strcmp(t->value, t2->value) |
5791
9cde0ca98839
Correctly mark mov metadata as utf-8, using iso language code
bcoudurier
parents:
5618
diff
changeset
|
1351 && (l=ff_mov_iso639_to_lang(&t2->key[len2-3], 1)) >= 0) { |
4587
b41ab5937218
movenc: add muxing of language along with metadata tags when available
aurel
parents:
4586
diff
changeset
|
1352 lang = l; |
b41ab5937218
movenc: add muxing of language along with metadata tags when available
aurel
parents:
4586
diff
changeset
|
1353 break; |
b41ab5937218
movenc: add muxing of language along with metadata tags when available
aurel
parents:
4586
diff
changeset
|
1354 } |
b41ab5937218
movenc: add muxing of language along with metadata tags when available
aurel
parents:
4586
diff
changeset
|
1355 } |
b41ab5937218
movenc: add muxing of language along with metadata tags when available
aurel
parents:
4586
diff
changeset
|
1356 return mov_write_string_tag(pb, name, t->value, lang, long_style); |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1357 } |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1358 |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1359 /* iTunes track number */ |
4609
065557d6fffb
Rename movenc.c MOVContext to MOVMuxContext, since MOVContext is already used
rbultje
parents:
4587
diff
changeset
|
1360 static int mov_write_trkn_tag(ByteIOContext *pb, MOVMuxContext *mov, |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1361 AVFormatContext *s) |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1362 { |
4584 | 1363 AVMetadataTag *t = av_metadata_get(s->metadata, "track", NULL, 0); |
1364 int size = 0, track = t ? atoi(t->value) : 0; | |
1365 if (track) { | |
5947
8b59caee931c
Predicting the size of the hdlr, string data and trkn tags in the MOV muxer
thardin
parents:
5913
diff
changeset
|
1366 put_be32(pb, 32); /* size */ |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1367 put_tag(pb, "trkn"); |
5947
8b59caee931c
Predicting the size of the hdlr, string data and trkn tags in the MOV muxer
thardin
parents:
5913
diff
changeset
|
1368 put_be32(pb, 24); /* size */ |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1369 put_tag(pb, "data"); |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1370 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
|
1371 put_be32(pb, 0); |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1372 put_be16(pb, 0); // empty |
4584 | 1373 put_be16(pb, track); // track number |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1374 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
|
1375 put_be16(pb, 0); // empty |
5947
8b59caee931c
Predicting the size of the hdlr, string data and trkn tags in the MOV muxer
thardin
parents:
5913
diff
changeset
|
1376 size = 32; |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1377 } |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1378 return size; |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1379 } |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1380 |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1381 /* iTunes meta data list */ |
4609
065557d6fffb
Rename movenc.c MOVContext to MOVMuxContext, since MOVContext is already used
rbultje
parents:
4587
diff
changeset
|
1382 static int mov_write_ilst_tag(ByteIOContext *pb, MOVMuxContext *mov, |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1383 AVFormatContext *s) |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1384 { |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3909
diff
changeset
|
1385 int64_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
|
1386 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
|
1387 put_tag(pb, "ilst"); |
4584 | 1388 mov_write_string_metadata(s, pb, "\251nam", "title" , 1); |
1389 mov_write_string_metadata(s, pb, "\251ART", "author" , 1); | |
5492
2aecc666c976
Add support for these widely-used iTunes metadata fields: Album Artist,
melanson
parents:
5394
diff
changeset
|
1390 mov_write_string_metadata(s, pb, "aART", "album_artist", 1); |
5381
b54fa3ff2f61
MOV: Fix writing \251wrt metadata (r20453 only fixed the demuxer)
conrad
parents:
5375
diff
changeset
|
1391 mov_write_string_metadata(s, pb, "\251wrt", "composer" , 1); |
4584 | 1392 mov_write_string_metadata(s, pb, "\251alb", "album" , 1); |
5618
27fd77f20a89
Add a list of generic tags and change demuxers to follow it.
pross
parents:
5556
diff
changeset
|
1393 mov_write_string_metadata(s, pb, "\251day", "date" , 1); |
4587
b41ab5937218
movenc: add muxing of language along with metadata tags when available
aurel
parents:
4586
diff
changeset
|
1394 mov_write_string_tag(pb, "\251too", LIBAVFORMAT_IDENT, 0, 1); |
4584 | 1395 mov_write_string_metadata(s, pb, "\251cmt", "comment" , 1); |
1396 mov_write_string_metadata(s, pb, "\251gen", "genre" , 1); | |
1397 mov_write_string_metadata(s, pb, "\251cpy", "copyright", 1); | |
5492
2aecc666c976
Add support for these widely-used iTunes metadata fields: Album Artist,
melanson
parents:
5394
diff
changeset
|
1398 mov_write_string_metadata(s, pb, "\251grp", "grouping" , 1); |
2aecc666c976
Add support for these widely-used iTunes metadata fields: Album Artist,
melanson
parents:
5394
diff
changeset
|
1399 mov_write_string_metadata(s, pb, "\251lyr", "lyrics" , 1); |
5382 | 1400 mov_write_string_metadata(s, pb, "desc", "description",1); |
1401 mov_write_string_metadata(s, pb, "ldes", "synopsis" , 1); | |
1402 mov_write_string_metadata(s, pb, "tvsh", "show" , 1); | |
1403 mov_write_string_metadata(s, pb, "tven", "episode_id",1); | |
1404 mov_write_string_metadata(s, pb, "tvnn", "network" , 1); | |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1405 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
|
1406 return updateSize(pb, pos); |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1407 } |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1408 |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1409 /* iTunes meta data tag */ |
4609
065557d6fffb
Rename movenc.c MOVContext to MOVMuxContext, since MOVContext is already used
rbultje
parents:
4587
diff
changeset
|
1410 static int mov_write_meta_tag(ByteIOContext *pb, MOVMuxContext *mov, |
513
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1411 AVFormatContext *s) |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1412 { |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1413 int size = 0; |
4585 | 1414 int64_t pos = url_ftell(pb); |
1415 put_be32(pb, 0); /* size */ | |
1416 put_tag(pb, "meta"); | |
1417 put_be32(pb, 0); | |
1418 mov_write_itunes_hdlr_tag(pb, mov, s); | |
1419 mov_write_ilst_tag(pb, mov, s); | |
1420 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
|
1421 return size; |
2b4edca40885
iTunes metadata encoding support patch by (Patrice Bensoussan <patrice.bensoussan at free dot fr>)
michael
parents:
505
diff
changeset
|
1422 } |
885 | 1423 |
3459
a79f6237c3d2
move utf8 code before udta func, will be used by 3gp tags
bcoudurier
parents:
3458
diff
changeset
|
1424 static int utf8len(const uint8_t *b) |
a79f6237c3d2
move utf8 code before udta func, will be used by 3gp tags
bcoudurier
parents:
3458
diff
changeset
|
1425 { |
a79f6237c3d2
move utf8 code before udta func, will be used by 3gp tags
bcoudurier
parents:
3458
diff
changeset
|
1426 int len=0; |
a79f6237c3d2
move utf8 code before udta func, will be used by 3gp tags
bcoudurier
parents:
3458
diff
changeset
|
1427 int val; |
a79f6237c3d2
move utf8 code before udta func, will be used by 3gp tags
bcoudurier
parents:
3458
diff
changeset
|
1428 while(*b){ |
a79f6237c3d2
move utf8 code before udta func, will be used by 3gp tags
bcoudurier
parents:
3458
diff
changeset
|
1429 GET_UTF8(val, *b++, return -1;) |
a79f6237c3d2
move utf8 code before udta func, will be used by 3gp tags
bcoudurier
parents:
3458
diff
changeset
|
1430 len++; |
a79f6237c3d2
move utf8 code before udta func, will be used by 3gp tags
bcoudurier
parents:
3458
diff
changeset
|
1431 } |
a79f6237c3d2
move utf8 code before udta func, will be used by 3gp tags
bcoudurier
parents:
3458
diff
changeset
|
1432 return len; |
a79f6237c3d2
move utf8 code before udta func, will be used by 3gp tags
bcoudurier
parents:
3458
diff
changeset
|
1433 } |
a79f6237c3d2
move utf8 code before udta func, will be used by 3gp tags
bcoudurier
parents:
3458
diff
changeset
|
1434 |
a79f6237c3d2
move utf8 code before udta func, will be used by 3gp tags
bcoudurier
parents:
3458
diff
changeset
|
1435 static int ascii_to_wc(ByteIOContext *pb, const uint8_t *b) |
a79f6237c3d2
move utf8 code before udta func, will be used by 3gp tags
bcoudurier
parents:
3458
diff
changeset
|
1436 { |
a79f6237c3d2
move utf8 code before udta func, will be used by 3gp tags
bcoudurier
parents:
3458
diff
changeset
|
1437 int val; |
a79f6237c3d2
move utf8 code before udta func, will be used by 3gp tags
bcoudurier
parents:
3458
diff
changeset
|
1438 while(*b){ |
a79f6237c3d2
move utf8 code before udta func, will be used by 3gp tags
bcoudurier
parents:
3458
diff
changeset
|
1439 GET_UTF8(val, *b++, return -1;) |
a79f6237c3d2
move utf8 code before udta func, will be used by 3gp tags
bcoudurier
parents:
3458
diff
changeset
|
1440 put_be16(pb, val); |
a79f6237c3d2
move utf8 code before udta func, will be used by 3gp tags
bcoudurier
parents:
3458
diff
changeset
|
1441 } |
a79f6237c3d2
move utf8 code before udta func, will be used by 3gp tags
bcoudurier
parents:
3458
diff
changeset
|
1442 put_be16(pb, 0x00); |
a79f6237c3d2
move utf8 code before udta func, will be used by 3gp tags
bcoudurier
parents:
3458
diff
changeset
|
1443 return 0; |
a79f6237c3d2
move utf8 code before udta func, will be used by 3gp tags
bcoudurier
parents:
3458
diff
changeset
|
1444 } |
a79f6237c3d2
move utf8 code before udta func, will be used by 3gp tags
bcoudurier
parents:
3458
diff
changeset
|
1445 |
a79f6237c3d2
move utf8 code before udta func, will be used by 3gp tags
bcoudurier
parents:
3458
diff
changeset
|
1446 static uint16_t language_code(const char *str) |
a79f6237c3d2
move utf8 code before udta func, will be used by 3gp tags
bcoudurier
parents:
3458
diff
changeset
|
1447 { |
a79f6237c3d2
move utf8 code before udta func, will be used by 3gp tags
bcoudurier
parents:
3458
diff
changeset
|
1448 return (((str[0]-0x60) & 0x1F) << 10) + (((str[1]-0x60) & 0x1F) << 5) + ((str[2]-0x60) & 0x1F); |
a79f6237c3d2
move utf8 code before udta func, will be used by 3gp tags
bcoudurier
parents:
3458
diff
changeset
|
1449 } |
a79f6237c3d2
move utf8 code before udta func, will be used by 3gp tags
bcoudurier
parents:
3458
diff
changeset
|
1450 |
3460 | 1451 static int mov_write_3gp_udta_tag(ByteIOContext *pb, AVFormatContext *s, |
1452 const char *tag, const char *str) | |
1453 { | |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3909
diff
changeset
|
1454 int64_t pos = url_ftell(pb); |
4584 | 1455 AVMetadataTag *t = av_metadata_get(s->metadata, str, NULL, 0); |
1456 if (!t || !utf8len(t->value)) | |
3460 | 1457 return 0; |
1458 put_be32(pb, 0); /* size */ | |
1459 put_tag (pb, tag); /* type */ | |
1460 put_be32(pb, 0); /* version + flags */ | |
1461 if (!strcmp(tag, "yrrc")) | |
4584 | 1462 put_be16(pb, atoi(t->value)); |
3460 | 1463 else { |
1464 put_be16(pb, language_code("eng")); /* language */ | |
4996
9d88db925e05
fix 3gp metadata, write strings in UTF8, patch by Larbi Joubala, larbi dot joubala at resonate-mp4 dot com
bcoudurier
parents:
4953
diff
changeset
|
1465 put_buffer(pb, t->value, strlen(t->value)+1); /* UTF8 string value */ |
4584 | 1466 if (!strcmp(tag, "albm") && |
5618
27fd77f20a89
Add a list of generic tags and change demuxers to follow it.
pross
parents:
5556
diff
changeset
|
1467 (t = av_metadata_get(s->metadata, "date", NULL, 0))) |
4584 | 1468 put_byte(pb, atoi(t->value)); |
3460 | 1469 } |
1470 return updateSize(pb, pos); | |
1471 } | |
1472 | |
5974 | 1473 static int mov_write_chpl_tag(ByteIOContext *pb, AVFormatContext *s) |
1474 { | |
1475 int64_t pos = url_ftell(pb); | |
1476 int i, nb_chapters = FFMIN(s->nb_chapters, 255); | |
1477 | |
1478 put_be32(pb, 0); // size | |
1479 put_tag (pb, "chpl"); | |
1480 put_be32(pb, 0x01000000); // version + flags | |
1481 put_be32(pb, 0); // unknown | |
1482 put_byte(pb, nb_chapters); | |
1483 | |
1484 for (i = 0; i < nb_chapters; i++) { | |
1485 AVChapter *c = s->chapters[i]; | |
1486 AVMetadataTag *t; | |
1487 put_be64(pb, av_rescale_q(c->start, c->time_base, (AVRational){1,10000000})); | |
1488 | |
1489 if ((t = av_metadata_get(c->metadata, "title", NULL, 0))) { | |
1490 int len = FFMIN(strlen(t->value), 255); | |
1491 put_byte(pb, len); | |
1492 put_buffer(pb, t->value, len); | |
1493 } else | |
1494 put_byte(pb, 0); | |
1495 } | |
1496 return updateSize(pb, pos); | |
1497 } | |
1498 | |
4609
065557d6fffb
Rename movenc.c MOVContext to MOVMuxContext, since MOVContext is already used
rbultje
parents:
4587
diff
changeset
|
1499 static int mov_write_udta_tag(ByteIOContext *pb, MOVMuxContext *mov, |
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
|
1500 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
|
1501 { |
4584 | 1502 ByteIOContext *pb_buf; |
1503 int i, ret, size; | |
1504 uint8_t *buf; | |
2668 | 1505 |
3450
0e53bfbd3a1c
rework udta handling, if any track set bitexact, don't write any metadata
bcoudurier
parents:
3449
diff
changeset
|
1506 for (i = 0; i < s->nb_streams; i++) |
0e53bfbd3a1c
rework udta handling, if any track set bitexact, don't write any metadata
bcoudurier
parents:
3449
diff
changeset
|
1507 if (mov->tracks[i].enc->flags & CODEC_FLAG_BITEXACT) { |
4584 | 1508 return 0; |
3450
0e53bfbd3a1c
rework udta handling, if any track set bitexact, don't write any metadata
bcoudurier
parents:
3449
diff
changeset
|
1509 } |
0e53bfbd3a1c
rework udta handling, if any track set bitexact, don't write any metadata
bcoudurier
parents:
3449
diff
changeset
|
1510 |
4584 | 1511 ret = url_open_dyn_buf(&pb_buf); |
1512 if(ret < 0) | |
1513 return ret; | |
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
|
1514 |
3466 | 1515 if (mov->mode & MODE_3GP) { |
4584 | 1516 mov_write_3gp_udta_tag(pb_buf, s, "titl", "title"); |
1517 mov_write_3gp_udta_tag(pb_buf, s, "auth", "author"); | |
1518 mov_write_3gp_udta_tag(pb_buf, s, "gnre", "genre"); | |
1519 mov_write_3gp_udta_tag(pb_buf, s, "dscp", "comment"); | |
1520 mov_write_3gp_udta_tag(pb_buf, s, "albm", "album"); | |
1521 mov_write_3gp_udta_tag(pb_buf, s, "cprt", "copyright"); | |
5618
27fd77f20a89
Add a list of generic tags and change demuxers to follow it.
pross
parents:
5556
diff
changeset
|
1522 mov_write_3gp_udta_tag(pb_buf, s, "yrrc", "date"); |
3464 | 1523 } else if (mov->mode == MODE_MOV) { // the title field breaks gtkpod with mp4 and my suspicion is that stuff is not valid in mp4 |
4584 | 1524 mov_write_string_metadata(s, pb_buf, "\251nam", "title" , 0); |
1525 mov_write_string_metadata(s, pb_buf, "\251aut", "author" , 0); | |
1526 mov_write_string_metadata(s, pb_buf, "\251alb", "album" , 0); | |
5618
27fd77f20a89
Add a list of generic tags and change demuxers to follow it.
pross
parents:
5556
diff
changeset
|
1527 mov_write_string_metadata(s, pb_buf, "\251day", "date" , 0); |
4587
b41ab5937218
movenc: add muxing of language along with metadata tags when available
aurel
parents:
4586
diff
changeset
|
1528 mov_write_string_tag(pb_buf, "\251enc", LIBAVFORMAT_IDENT, 0, 0); |
4584 | 1529 mov_write_string_metadata(s, pb_buf, "\251des", "comment" , 0); |
1530 mov_write_string_metadata(s, pb_buf, "\251gen", "genre" , 0); | |
1531 mov_write_string_metadata(s, pb_buf, "\251cpy", "copyright" , 0); | |
3460 | 1532 } else { |
3463
91a688e89d31
don't write double sets of metadata in mov, only write usual ones
bcoudurier
parents:
3461
diff
changeset
|
1533 /* iTunes meta data */ |
4584 | 1534 mov_write_meta_tag(pb_buf, mov, s); |
3460 | 1535 } |
4584 | 1536 |
5974 | 1537 if (s->nb_chapters) |
1538 mov_write_chpl_tag(pb_buf, s); | |
1539 | |
4584 | 1540 if ((size = url_close_dyn_buf(pb_buf, &buf)) > 0) { |
1541 put_be32(pb, size+8); | |
1542 put_tag(pb, "udta"); | |
1543 put_buffer(pb, buf, size); | |
1544 av_free(buf); | |
2668 | 1545 } |
1546 | |
1547 return 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
|
1548 } |
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
|
1549 |
3457 | 1550 static void mov_write_psp_udta_tag(ByteIOContext *pb, |
3456 | 1551 const char *str, const char *lang, int type) |
1552 { | |
1553 int len = utf8len(str)+1; | |
1554 if(len<=0) | |
3457 | 1555 return; |
3456 | 1556 put_be16(pb, len*2+10); /* size */ |
1557 put_be32(pb, type); /* type */ | |
1558 put_be16(pb, language_code(lang)); /* language */ | |
1559 put_be16(pb, 0x01); /* ? */ | |
1560 ascii_to_wc(pb, str); | |
1561 } | |
1562 | |
3446 | 1563 static int mov_write_uuidusmt_tag(ByteIOContext *pb, AVFormatContext *s) |
911
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1564 { |
4584 | 1565 AVMetadataTag *title = av_metadata_get(s->metadata, "title", NULL, 0); |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3909
diff
changeset
|
1566 int64_t pos, pos2; |
911
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1567 |
4584 | 1568 if (title) { |
911
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1569 pos = url_ftell(pb); |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1570 put_be32(pb, 0); /* size placeholder*/ |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1571 put_tag(pb, "uuid"); |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1572 put_tag(pb, "USMT"); |
3024
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1573 put_be32(pb, 0x21d24fce); /* 96 bit UUID */ |
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1574 put_be32(pb, 0xbb88695c); |
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1575 put_be32(pb, 0xfac9c740); |
911
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1576 |
3457 | 1577 pos2 = url_ftell(pb); |
911
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1578 put_be32(pb, 0); /* size placeholder*/ |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1579 put_tag(pb, "MTDT"); |
1097
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1580 put_be16(pb, 4); |
911
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1581 |
1097
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1582 // ? |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1583 put_be16(pb, 0x0C); /* size */ |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1584 put_be32(pb, 0x0B); /* type */ |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1585 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
|
1586 put_be16(pb, 0x0); /* ? */ |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1587 put_be16(pb, 0x021C); /* data */ |
acabd3a4b903
fixing title on PSP (0x60 != 'a') someone needs a 10x10km ascii table ...
michael
parents:
1096
diff
changeset
|
1588 |
3457 | 1589 mov_write_psp_udta_tag(pb, LIBAVCODEC_IDENT, "eng", 0x04); |
4584 | 1590 mov_write_psp_udta_tag(pb, title->value, "eng", 0x01); |
3457 | 1591 // 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); |
1592 mov_write_psp_udta_tag(pb, "2006/04/01 11:11:11", "und", 0x03); | |
1593 | |
1594 updateSize(pb, pos2); | |
1595 return updateSize(pb, pos); | |
911
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1596 } |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1597 |
3457 | 1598 return 0; |
911
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1599 } |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1600 |
4609
065557d6fffb
Rename movenc.c MOVContext to MOVMuxContext, since MOVContext is already used
rbultje
parents:
4587
diff
changeset
|
1601 static int mov_write_moov_tag(ByteIOContext *pb, MOVMuxContext *mov, |
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
|
1602 AVFormatContext *s) |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1603 { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
1604 int i; |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3909
diff
changeset
|
1605 int64_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
|
1606 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
|
1607 put_tag(pb, "moov"); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1608 |
1131 | 1609 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
|
1610 if(mov->tracks[i].entry <= 0) continue; |
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1611 |
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1612 mov->tracks[i].time = mov->time; |
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1613 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
|
1614 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1615 |
5993 | 1616 if (mov->chapter_track) |
1617 for (i=0; i<s->nb_streams; i++) { | |
1618 mov->tracks[i].tref_tag = MKTAG('c','h','a','p'); | |
1619 mov->tracks[i].tref_id = mov->tracks[mov->chapter_track].trackID; | |
1620 } | |
1621 | |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
1622 mov_write_mvhd_tag(pb, mov); |
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
1623 //mov_write_iods_tag(pb, mov); |
1131 | 1624 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
|
1625 if(mov->tracks[i].entry > 0) { |
5993 | 1626 mov_write_trak_tag(pb, &(mov->tracks[i]), i < s->nb_streams ? s->streams[i] : NULL); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1627 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1628 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1629 |
911
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1630 if (mov->mode == MODE_PSP) |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1631 mov_write_uuidusmt_tag(pb, s); |
3460 | 1632 else |
1441
ad3b03b7b142
reindentation, patch by From: Steve Lhomme, slhomme divxcorp com
diego
parents:
1438
diff
changeset
|
1633 mov_write_udta_tag(pb, mov, s); |
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
|
1634 |
238
3519903c6c2a
mov/mp4 muxer cleanup (mostly cosmetics/simplifications & global header fix)
michaelni
parents:
202
diff
changeset
|
1635 return updateSize(pb, pos); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1636 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1637 |
4609
065557d6fffb
Rename movenc.c MOVContext to MOVMuxContext, since MOVContext is already used
rbultje
parents:
4587
diff
changeset
|
1638 static int mov_write_mdat_tag(ByteIOContext *pb, MOVMuxContext *mov) |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1639 { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
1640 put_be32(pb, 8); // placeholder for extended size field (64 bit) |
1273
07137c477f09
wide atom is only defined in mov, use free for mp4/3gp
bcoudurier
parents:
1250
diff
changeset
|
1641 put_tag(pb, mov->mode == MODE_MOV ? "wide" : "free"); |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
1642 |
885 | 1643 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
|
1644 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
|
1645 put_tag(pb, "mdat"); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1646 return 0; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1647 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1648 |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1649 /* TODO: This needs to be more general */ |
3471 | 1650 static int mov_write_ftyp_tag(ByteIOContext *pb, AVFormatContext *s) |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1651 { |
4609
065557d6fffb
Rename movenc.c MOVContext to MOVMuxContext, since MOVContext is already used
rbultje
parents:
4587
diff
changeset
|
1652 MOVMuxContext *mov = s->priv_data; |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3909
diff
changeset
|
1653 int64_t pos = url_ftell(pb); |
3472 | 1654 int has_h264 = 0, has_video = 0; |
3476 | 1655 int minor = 0x200; |
3458 | 1656 int 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
|
1657 |
3470
d8bbf9265f03
put avc1 brand in compat list when h264 is present
bcoudurier
parents:
3469
diff
changeset
|
1658 for (i = 0; i < s->nb_streams; i++) { |
d8bbf9265f03
put avc1 brand in compat list when h264 is present
bcoudurier
parents:
3469
diff
changeset
|
1659 AVStream *st = s->streams[i]; |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5792
diff
changeset
|
1660 if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) |
3472 | 1661 has_video = 1; |
3470
d8bbf9265f03
put avc1 brand in compat list when h264 is present
bcoudurier
parents:
3469
diff
changeset
|
1662 if (st->codec->codec_id == CODEC_ID_H264) |
d8bbf9265f03
put avc1 brand in compat list when h264 is present
bcoudurier
parents:
3469
diff
changeset
|
1663 has_h264 = 1; |
d8bbf9265f03
put avc1 brand in compat list when h264 is present
bcoudurier
parents:
3469
diff
changeset
|
1664 } |
d8bbf9265f03
put avc1 brand in compat list when h264 is present
bcoudurier
parents:
3469
diff
changeset
|
1665 |
3467 | 1666 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
|
1667 put_tag(pb, "ftyp"); |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1668 |
3476 | 1669 if (mov->mode == MODE_3GP) { |
1670 put_tag(pb, has_h264 ? "3gp6" : "3gp4"); | |
1671 minor = has_h264 ? 0x100 : 0x200; | |
1672 } else if (mov->mode & MODE_3G2) { | |
1673 put_tag(pb, has_h264 ? "3g2b" : "3g2a"); | |
1674 minor = has_h264 ? 0x20000 : 0x10000; | |
1675 }else if (mov->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
|
1676 put_tag(pb, "MSNV"); |
3458 | 1677 else if (mov->mode == MODE_MP4) |
990
f7394f02e95a
ftyp patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com)
michael
parents:
987
diff
changeset
|
1678 put_tag(pb, "isom"); |
3472 | 1679 else if (mov->mode == MODE_IPOD) |
1680 put_tag(pb, has_video ? "M4V ":"M4A "); | |
1681 else | |
990
f7394f02e95a
ftyp patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com)
michael
parents:
987
diff
changeset
|
1682 put_tag(pb, "qt "); |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1683 |
3476 | 1684 put_be32(pb, minor); |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1685 |
3475 | 1686 if(mov->mode == MODE_MOV) |
1687 put_tag(pb, "qt "); | |
1688 else{ | |
3468 | 1689 put_tag(pb, "isom"); |
3469 | 1690 put_tag(pb, "iso2"); |
3470
d8bbf9265f03
put avc1 brand in compat list when h264 is present
bcoudurier
parents:
3469
diff
changeset
|
1691 if(has_h264) |
d8bbf9265f03
put avc1 brand in compat list when h264 is present
bcoudurier
parents:
3469
diff
changeset
|
1692 put_tag(pb, "avc1"); |
3475 | 1693 } |
3468 | 1694 |
3024
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1695 if (mov->mode == MODE_3GP) |
3473 | 1696 put_tag(pb, has_h264 ? "3gp6":"3gp4"); |
3466 | 1697 else if (mov->mode & MODE_3G2) |
3473 | 1698 put_tag(pb, has_h264 ? "3g2b":"3g2a"); |
3024
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1699 else if (mov->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
|
1700 put_tag(pb, "MSNV"); |
3458 | 1701 else if (mov->mode == MODE_MP4) |
990
f7394f02e95a
ftyp patch by (Baptiste COUDURIER <baptiste.coudurier smartjog com)
michael
parents:
987
diff
changeset
|
1702 put_tag(pb, "mp41"); |
3467 | 1703 return updateSize(pb, pos); |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1704 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1705 |
665
47d5b20c9aba
fix segfault by matthieu castet <castet DOT matthieu AT free DOT fr>
mmu_man
parents:
664
diff
changeset
|
1706 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
|
1707 { |
911
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1708 AVCodecContext *VideoCodec = s->streams[0]->codec; |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1709 AVCodecContext *AudioCodec = s->streams[1]->codec; |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1710 int AudioRate = AudioCodec->sample_rate; |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1711 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
|
1712 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
|
1713 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
|
1714 |
3024
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1715 put_be32(pb, 0x94); /* size */ |
659
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1716 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
|
1717 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
|
1718 |
3024
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1719 put_be32(pb, 0x21d24fce); /* 96 bit UUID */ |
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1720 put_be32(pb, 0xbb88695c); |
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1721 put_be32(pb, 0xfac9c740); |
659
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1722 |
3024
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1723 put_be32(pb, 0x0); /* ? */ |
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1724 put_be32(pb, 0x3); /* 3 sections ? */ |
659
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1725 |
3024
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1726 put_be32(pb, 0x14); /* size */ |
659
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1727 put_tag(pb, "FPRF"); |
3024
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1728 put_be32(pb, 0x0); /* ? */ |
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1729 put_be32(pb, 0x0); /* ? */ |
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1730 put_be32(pb, 0x0); /* ? */ |
659
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1731 |
3024
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1732 put_be32(pb, 0x2c); /* size */ |
659
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1733 put_tag(pb, "APRF"); /* audio */ |
3024
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1734 put_be32(pb, 0x0); |
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1735 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
|
1736 put_tag(pb, "mp4a"); |
3024
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1737 put_be32(pb, 0x20f); |
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1738 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
|
1739 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
|
1740 put_be32(pb, audio_kbitrate); |
3024
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1741 put_be32(pb, AudioRate); |
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1742 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
|
1743 |
3024
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1744 put_be32(pb, 0x34); /* size */ |
659
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1745 put_tag(pb, "VPRF"); /* video */ |
3024
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1746 put_be32(pb, 0x0); |
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1747 put_be32(pb, 0x1); /* TrackID */ |
1050
ece3b7eecba2
little h.264 related hunk from diff between cvs and mobile hackerz
michael
parents:
1049
diff
changeset
|
1748 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
|
1749 put_tag(pb, "avc1"); |
3024
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1750 put_be16(pb, 0x014D); |
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1751 put_be16(pb, 0x0015); |
1050
ece3b7eecba2
little h.264 related hunk from diff between cvs and mobile hackerz
michael
parents:
1049
diff
changeset
|
1752 } else { |
ece3b7eecba2
little h.264 related hunk from diff between cvs and mobile hackerz
michael
parents:
1049
diff
changeset
|
1753 put_tag(pb, "mp4v"); |
3024
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1754 put_be16(pb, 0x0000); |
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1755 put_be16(pb, 0x0103); |
1050
ece3b7eecba2
little h.264 related hunk from diff between cvs and mobile hackerz
michael
parents:
1049
diff
changeset
|
1756 } |
3024
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
1757 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
|
1758 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
|
1759 put_be32(pb, video_kbitrate); |
911
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1760 put_be32(pb, FrameRate); |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1761 put_be32(pb, FrameRate); |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1762 put_be16(pb, VideoCodec->width); |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1763 put_be16(pb, VideoCodec->height); |
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
1764 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
|
1765 } |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
1766 |
4941 | 1767 static int mov_parse_mpeg2_frame(AVPacket *pkt, uint32_t *flags) |
1768 { | |
1769 uint32_t c = -1; | |
1770 int i, closed_gop = 0; | |
1771 | |
1772 for (i = 0; i < pkt->size - 4; i++) { | |
1773 c = (c<<8) + pkt->data[i]; | |
1774 if (c == 0x1b8) { // gop | |
1775 closed_gop = pkt->data[i+4]>>6 & 0x01; | |
1776 } else if (c == 0x100) { // pic | |
1777 int temp_ref = (pkt->data[i+1]<<2) | (pkt->data[i+2]>>6); | |
1778 if (!temp_ref || closed_gop) // I picture is not reordered | |
1779 *flags = MOV_SYNC_SAMPLE; | |
1780 else | |
1781 *flags = MOV_PARTIAL_SYNC_SAMPLE; | |
1782 break; | |
1783 } | |
1784 } | |
1785 return 0; | |
1786 } | |
1787 | |
6012 | 1788 int ff_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
|
1789 { |
4609
065557d6fffb
Rename movenc.c MOVContext to MOVMuxContext, since MOVContext is already used
rbultje
parents:
4587
diff
changeset
|
1790 MOVMuxContext *mov = s->priv_data; |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2669
diff
changeset
|
1791 ByteIOContext *pb = s->pb; |
1080 | 1792 MOVTrack *trk = &mov->tracks[pkt->stream_index]; |
1793 AVCodecContext *enc = trk->enc; | |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1794 unsigned int samplesInChunk = 0; |
468 | 1795 int size= pkt->size; |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1796 |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2669
diff
changeset
|
1797 if (url_is_streamed(s->pb)) return 0; /* Can't handle that */ |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1798 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
|
1799 |
1154 | 1800 if (enc->codec_id == CODEC_ID_AMR_NB) { |
1147 | 1801 /* We must find out how many AMR blocks there are in one packet */ |
1802 static uint16_t packed_size[16] = | |
1803 {13, 14, 16, 18, 20, 21, 27, 32, 6, 0, 0, 0, 0, 0, 0, 0}; | |
1804 int len = 0; | |
1057 | 1805 |
1147 | 1806 while (len < size && samplesInChunk < 100) { |
1807 len += packed_size[(pkt->data[len] >> 3) & 0x0F]; | |
1808 samplesInChunk++; | |
1057 | 1809 } |
1151 | 1810 if(samplesInChunk > 1){ |
2546 | 1811 av_log(s, AV_LOG_ERROR, "fatal error, input is not a single packet, implement a AVParser for it\n"); |
1151 | 1812 return -1; |
1813 } | |
1147 | 1814 } else if (trk->sampleSize) |
1815 samplesInChunk = size/trk->sampleSize; | |
1816 else | |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1817 samplesInChunk = 1; |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1818 |
1057 | 1819 /* copy extradata if it exists */ |
1820 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
|
1821 trk->vosLen = enc->extradata_size; |
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1822 trk->vosData = av_malloc(trk->vosLen); |
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1823 memcpy(trk->vosData, enc->extradata, trk->vosLen); |
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1824 } |
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1825 |
4225
0231b1d5cd15
move actual writing before so new size can be taken into account
bcoudurier
parents:
4223
diff
changeset
|
1826 if (enc->codec_id == CODEC_ID_H264 && trk->vosLen > 0 && *(uint8_t *)trk->vosData != 1) { |
0231b1d5cd15
move actual writing before so new size can be taken into account
bcoudurier
parents:
4223
diff
changeset
|
1827 /* from x264 or from bytestream h264 */ |
0231b1d5cd15
move actual writing before so new size can be taken into account
bcoudurier
parents:
4223
diff
changeset
|
1828 /* nal reformating needed */ |
0231b1d5cd15
move actual writing before so new size can be taken into account
bcoudurier
parents:
4223
diff
changeset
|
1829 size = ff_avc_parse_nal_units(pb, pkt->data, pkt->size); |
0231b1d5cd15
move actual writing before so new size can be taken into account
bcoudurier
parents:
4223
diff
changeset
|
1830 } else { |
0231b1d5cd15
move actual writing before so new size can be taken into account
bcoudurier
parents:
4223
diff
changeset
|
1831 put_buffer(pb, pkt->data, size); |
0231b1d5cd15
move actual writing before so new size can be taken into account
bcoudurier
parents:
4223
diff
changeset
|
1832 } |
0231b1d5cd15
move actual writing before so new size can be taken into account
bcoudurier
parents:
4223
diff
changeset
|
1833 |
4222
0267c4299992
Do not reallocate AVPacket's data when muxing a packet
lucabe
parents:
4206
diff
changeset
|
1834 if ((enc->codec_id == CODEC_ID_DNXHD || |
4928 | 1835 enc->codec_id == CODEC_ID_AC3) && !trk->vosLen) { |
3857
50bb82abb278
copy whole frame in vosData for dnxhd, this code will be used for other codecs too
bcoudurier
parents:
3766
diff
changeset
|
1836 /* copy frame to create needed atoms */ |
50bb82abb278
copy whole frame in vosData for dnxhd, this code will be used for other codecs too
bcoudurier
parents:
3766
diff
changeset
|
1837 trk->vosLen = size; |
50bb82abb278
copy whole frame in vosData for dnxhd, this code will be used for other codecs too
bcoudurier
parents:
3766
diff
changeset
|
1838 trk->vosData = av_malloc(size); |
3858 | 1839 if (!trk->vosData) |
1840 return AVERROR(ENOMEM); | |
3857
50bb82abb278
copy whole frame in vosData for dnxhd, this code will be used for other codecs too
bcoudurier
parents:
3766
diff
changeset
|
1841 memcpy(trk->vosData, pkt->data, size); |
1006
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
1842 } |
15bfc3c063dc
do nal reformating when muxing H264, create avcc atom
bcoudurier
parents:
1000
diff
changeset
|
1843 |
1129 | 1844 if (!(trk->entry % MOV_INDEX_CLUSTER_SIZE)) { |
1845 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
|
1846 if (!trk->cluster) |
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1847 return -1; |
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1848 } |
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1849 |
4225
0231b1d5cd15
move actual writing before so new size can be taken into account
bcoudurier
parents:
4223
diff
changeset
|
1850 trk->cluster[trk->entry].pos = url_ftell(pb) - size; |
1129 | 1851 trk->cluster[trk->entry].samplesInChunk = samplesInChunk; |
1852 trk->cluster[trk->entry].size = size; | |
1853 trk->cluster[trk->entry].entries = samplesInChunk; | |
1437 | 1854 trk->cluster[trk->entry].dts = pkt->dts; |
1855 trk->trackDuration = pkt->dts - trk->cluster[0].dts + pkt->duration; | |
1856 | |
3397
76918939de90
warn if pts is not set, prevent writing negative/weird cts, happens when using genpts and streamcopy
bcoudurier
parents:
3396
diff
changeset
|
1857 if (pkt->pts == AV_NOPTS_VALUE) { |
76918939de90
warn if pts is not set, prevent writing negative/weird cts, happens when using genpts and streamcopy
bcoudurier
parents:
3396
diff
changeset
|
1858 av_log(s, AV_LOG_WARNING, "pts has no value\n"); |
76918939de90
warn if pts is not set, prevent writing negative/weird cts, happens when using genpts and streamcopy
bcoudurier
parents:
3396
diff
changeset
|
1859 pkt->pts = pkt->dts; |
76918939de90
warn if pts is not set, prevent writing negative/weird cts, happens when using genpts and streamcopy
bcoudurier
parents:
3396
diff
changeset
|
1860 } |
3396 | 1861 if (pkt->dts != pkt->pts) |
4941 | 1862 trk->flags |= MOV_TRACK_CTTS; |
3396 | 1863 trk->cluster[trk->entry].cts = pkt->pts - pkt->dts; |
4941 | 1864 trk->cluster[trk->entry].flags = 0; |
5913
11bb10c37225
Replace all occurences of PKT_FLAG_KEY with AV_PKT_FLAG_KEY.
cehoyos
parents:
5910
diff
changeset
|
1865 if (pkt->flags & AV_PKT_FLAG_KEY) { |
4941 | 1866 if (mov->mode == MODE_MOV && enc->codec_id == CODEC_ID_MPEG2VIDEO) { |
1867 mov_parse_mpeg2_frame(pkt, &trk->cluster[trk->entry].flags); | |
1868 if (trk->cluster[trk->entry].flags & MOV_PARTIAL_SYNC_SAMPLE) | |
1869 trk->flags |= MOV_TRACK_STPS; | |
1870 } else { | |
1871 trk->cluster[trk->entry].flags = MOV_SYNC_SAMPLE; | |
1872 } | |
1873 if (trk->cluster[trk->entry].flags & MOV_SYNC_SAMPLE) | |
1874 trk->hasKeyframes++; | |
4937 | 1875 } |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1876 trk->entry++; |
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1877 trk->sampleCount += samplesInChunk; |
1080 | 1878 mov->mdat_size += size; |
298
0b2eed7b1210
movenc patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
286
diff
changeset
|
1879 |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1880 put_flush_packet(pb); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1881 return 0; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1882 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
1883 |
5993 | 1884 // QuickTime chapters involve an additional text track with the chapter names |
1885 // as samples, and a tref pointing from the other tracks to the chapter one. | |
1886 static void mov_create_chapter_track(AVFormatContext *s, int tracknum) | |
1887 { | |
1888 MOVMuxContext *mov = s->priv_data; | |
1889 MOVTrack *track = &mov->tracks[tracknum]; | |
1890 AVPacket pkt = { .stream_index = tracknum, .flags = AV_PKT_FLAG_KEY }; | |
1891 int i, len; | |
1892 | |
1893 track->mode = mov->mode; | |
1894 track->tag = MKTAG('t','e','x','t'); | |
1895 track->timescale = MOV_TIMESCALE; | |
1896 track->enc = avcodec_alloc_context(); | |
1897 track->enc->codec_type = AVMEDIA_TYPE_SUBTITLE; | |
1898 | |
1899 for (i = 0; i < s->nb_chapters; i++) { | |
1900 AVChapter *c = s->chapters[i]; | |
1901 AVMetadataTag *t; | |
1902 | |
1903 int64_t end = av_rescale_q(c->end, c->time_base, (AVRational){1,MOV_TIMESCALE}); | |
1904 pkt.pts = pkt.dts = av_rescale_q(c->start, c->time_base, (AVRational){1,MOV_TIMESCALE}); | |
1905 pkt.duration = end - pkt.dts; | |
1906 | |
1907 if ((t = av_metadata_get(c->metadata, "title", NULL, 0))) { | |
1908 len = strlen(t->value); | |
1909 pkt.size = len+2; | |
1910 pkt.data = av_malloc(pkt.size); | |
1911 AV_WB16(pkt.data, len); | |
1912 memcpy(pkt.data+2, t->value, len); | |
6012 | 1913 ff_mov_write_packet(s, &pkt); |
5993 | 1914 av_freep(&pkt.data); |
1915 } | |
1916 } | |
1917 } | |
1918 | |
5992
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1919 static int mov_write_header(AVFormatContext *s) |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1920 { |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1921 ByteIOContext *pb = s->pb; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1922 MOVMuxContext *mov = s->priv_data; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1923 int i; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1924 |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1925 if (url_is_streamed(s->pb)) { |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1926 av_log(s, AV_LOG_ERROR, "muxer does not support non seekable output\n"); |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1927 return -1; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1928 } |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1929 |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1930 /* Default mode == MP4 */ |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1931 mov->mode = MODE_MP4; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1932 |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1933 if (s->oformat != NULL) { |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1934 if (!strcmp("3gp", s->oformat->name)) mov->mode = MODE_3GP; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1935 else if (!strcmp("3g2", s->oformat->name)) mov->mode = MODE_3GP|MODE_3G2; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1936 else if (!strcmp("mov", s->oformat->name)) mov->mode = MODE_MOV; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1937 else if (!strcmp("psp", s->oformat->name)) mov->mode = MODE_PSP; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1938 else if (!strcmp("ipod",s->oformat->name)) mov->mode = MODE_IPOD; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1939 |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1940 mov_write_ftyp_tag(pb,s); |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1941 if (mov->mode == MODE_PSP) { |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1942 if (s->nb_streams != 2) { |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1943 av_log(s, AV_LOG_ERROR, "PSP mode need one video and one audio stream\n"); |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1944 return -1; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1945 } |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1946 mov_write_uuidprof_tag(pb,s); |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1947 } |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1948 } |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1949 |
5993 | 1950 mov->nb_streams = s->nb_streams; |
1951 if (mov->mode & (MODE_MOV|MODE_IPOD) && s->nb_chapters) | |
1952 mov->chapter_track = mov->nb_streams++; | |
1953 | |
1954 mov->tracks = av_mallocz(mov->nb_streams*sizeof(*mov->tracks)); | |
5992
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1955 if (!mov->tracks) |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1956 return AVERROR(ENOMEM); |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1957 |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1958 for(i=0; i<s->nb_streams; i++){ |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1959 AVStream *st= s->streams[i]; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1960 MOVTrack *track= &mov->tracks[i]; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1961 AVMetadataTag *lang = av_metadata_get(st->metadata, "language", NULL,0); |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1962 |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1963 track->enc = st->codec; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1964 track->language = ff_mov_iso639_to_lang(lang?lang->value:"und", mov->mode!=MODE_MOV); |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1965 if (track->language < 0) |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1966 track->language = 0; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1967 track->mode = mov->mode; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1968 track->tag = mov_find_codec_tag(s, track); |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1969 if (!track->tag) { |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1970 av_log(s, AV_LOG_ERROR, "track %d: could not find tag, " |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1971 "codec not currently supported in container\n", i); |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1972 goto error; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1973 } |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1974 if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO){ |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1975 if (track->tag == MKTAG('m','x','3','p') || track->tag == MKTAG('m','x','3','n') || |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1976 track->tag == MKTAG('m','x','4','p') || track->tag == MKTAG('m','x','4','n') || |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1977 track->tag == MKTAG('m','x','5','p') || track->tag == MKTAG('m','x','5','n')) { |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1978 if (st->codec->width != 720 || (st->codec->height != 608 && st->codec->height != 512)) { |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1979 av_log(s, AV_LOG_ERROR, "D-10/IMX must use 720x608 or 720x512 video resolution\n"); |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1980 goto error; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1981 } |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1982 track->height = track->tag>>24 == 'n' ? 486 : 576; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1983 } |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1984 track->timescale = st->codec->time_base.den; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1985 if (track->mode == MODE_MOV && track->timescale > 100000) |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1986 av_log(s, AV_LOG_WARNING, |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1987 "WARNING codec timebase is very high. If duration is too long,\n" |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1988 "file may not be playable by quicktime. Specify a shorter timebase\n" |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1989 "or choose different container.\n"); |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1990 }else if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO){ |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1991 track->timescale = st->codec->sample_rate; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1992 if(!st->codec->frame_size && !av_get_bits_per_sample(st->codec->codec_id)) { |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1993 av_log(s, AV_LOG_ERROR, "track %d: codec frame size is not set\n", i); |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1994 goto error; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1995 }else if(st->codec->frame_size > 1){ /* assume compressed audio */ |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1996 track->audio_vbr = 1; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1997 }else{ |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1998 st->codec->frame_size = 1; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
1999 track->sampleSize = (av_get_bits_per_sample(st->codec->codec_id) >> 3) * st->codec->channels; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2000 } |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2001 if (track->mode != MODE_MOV) { |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2002 if (track->timescale > UINT16_MAX) { |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2003 av_log(s, AV_LOG_ERROR, "track %d: output format does not support " |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2004 "sample rate %dhz\n", i, track->timescale); |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2005 goto error; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2006 } |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2007 if (track->enc->codec_id == CODEC_ID_MP3 && track->timescale < 16000) { |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2008 av_log(s, AV_LOG_ERROR, "track %d: muxing mp3 at %dhz is not supported\n", |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2009 i, track->enc->sample_rate); |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2010 goto error; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2011 } |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2012 } |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2013 }else if(st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE){ |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2014 track->timescale = st->codec->time_base.den; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2015 } |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2016 if (!track->height) |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2017 track->height = st->codec->height; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2018 |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2019 av_set_pts_info(st, 64, 1, track->timescale); |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2020 } |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2021 |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2022 mov_write_mdat_tag(pb, mov); |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2023 mov->time = s->timestamp + 0x7C25B080; //1970 based -> 1904 based |
5993 | 2024 |
2025 if (mov->chapter_track) | |
2026 mov_create_chapter_track(s, mov->chapter_track); | |
5992
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2027 |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2028 put_flush_packet(pb); |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2029 |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2030 return 0; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2031 error: |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2032 av_freep(&mov->tracks); |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2033 return -1; |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2034 } |
391e3ca10474
movenc: Swap positions of mov_write_header and mov_write_packet
conrad
parents:
5974
diff
changeset
|
2035 |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2036 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
|
2037 { |
4609
065557d6fffb
Rename movenc.c MOVContext to MOVMuxContext, since MOVContext is already used
rbultje
parents:
4587
diff
changeset
|
2038 MOVMuxContext *mov = s->priv_data; |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2669
diff
changeset
|
2039 ByteIOContext *pb = s->pb; |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2040 int res = 0; |
1129 | 2041 int i; |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2042 |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3909
diff
changeset
|
2043 int64_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
|
2044 |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2045 /* Write size of mdat tag */ |
1080 | 2046 if (mov->mdat_size+8 <= UINT32_MAX) { |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
2047 url_fseek(pb, mov->mdat_pos, SEEK_SET); |
1080 | 2048 put_be32(pb, mov->mdat_size+8); |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
2049 } else { |
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
2050 /* overwrite 'wide' placeholder atom */ |
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
2051 url_fseek(pb, mov->mdat_pos - 8, SEEK_SET); |
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
2052 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
|
2053 put_tag(pb, "mdat"); |
1080 | 2054 put_be64(pb, mov->mdat_size+16); |
909
69e06b6f91a3
>4gb fixes by (Dirk Musfeldt | d.musfeldt meilenstein de)
michael
parents:
896
diff
changeset
|
2055 } |
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
|
2056 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
|
2057 |
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
|
2058 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
|
2059 |
5993 | 2060 if (mov->chapter_track) |
2061 av_freep(&mov->tracks[mov->chapter_track].enc); | |
2062 | |
1131 | 2063 for (i=0; i<mov->nb_streams; i++) { |
1129 | 2064 av_freep(&mov->tracks[i].cluster); |
2065 | |
3024
19de43025f0f
cosmetics, remove whitespaces before and after parenthesis
bcoudurier
parents:
3010
diff
changeset
|
2066 if(mov->tracks[i].vosLen) av_free(mov->tracks[i].vosData); |
342
0c1b489c96bf
memleak patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
299
diff
changeset
|
2067 |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2068 } |
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
|
2069 |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2070 put_flush_packet(pb); |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2071 |
4783 | 2072 av_freep(&mov->tracks); |
2073 | |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2074 return res; |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2075 } |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2076 |
4206 | 2077 #if CONFIG_MOV_MUXER |
1169 | 2078 AVOutputFormat mov_muxer = { |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2079 "mov", |
3424
7a0230981402
Make long_names in lavf/lavdev optional depending on CONFIG_SMALL.
diego
parents:
3397
diff
changeset
|
2080 NULL_IF_CONFIG_SMALL("MOV format"), |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2081 NULL, |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2082 "mov", |
4609
065557d6fffb
Rename movenc.c MOVContext to MOVMuxContext, since MOVContext is already used
rbultje
parents:
4587
diff
changeset
|
2083 sizeof(MOVMuxContext), |
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
|
2084 CODEC_ID_AAC, |
239 | 2085 CODEC_ID_MPEG4, |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2086 mov_write_header, |
6012 | 2087 ff_mov_write_packet, |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2088 mov_write_trailer, |
4567
963e3b76c7a6
Add AVFMT_VARIABLE_FPS to specify which muxers do not need duplicated frames.
michael
parents:
4463
diff
changeset
|
2089 .flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS, |
3766
f062deeedb8d
Change codec_tag type from const struct AVCodecTag ** to const struct AVCodecTag * const *
reimar
parents:
3759
diff
changeset
|
2090 .codec_tag = (const AVCodecTag* const []){codec_movvideo_tags, codec_movaudio_tags, 0}, |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2091 }; |
1169 | 2092 #endif |
4206 | 2093 #if CONFIG_TGP_MUXER |
1169 | 2094 AVOutputFormat tgp_muxer = { |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2095 "3gp", |
3424
7a0230981402
Make long_names in lavf/lavdev optional depending on CONFIG_SMALL.
diego
parents:
3397
diff
changeset
|
2096 NULL_IF_CONFIG_SMALL("3GP format"), |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2097 NULL, |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2098 "3gp", |
4609
065557d6fffb
Rename movenc.c MOVContext to MOVMuxContext, since MOVContext is already used
rbultje
parents:
4587
diff
changeset
|
2099 sizeof(MOVMuxContext), |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2100 CODEC_ID_AMR_NB, |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2101 CODEC_ID_H263, |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2102 mov_write_header, |
6012 | 2103 ff_mov_write_packet, |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2104 mov_write_trailer, |
715
e214703e4b76
30_clean_up_global_header_flag.patch by (Calcium | calcium nurs or jp)
michael
parents:
711
diff
changeset
|
2105 .flags = AVFMT_GLOBALHEADER, |
3766
f062deeedb8d
Change codec_tag type from const struct AVCodecTag ** to const struct AVCodecTag * const *
reimar
parents:
3759
diff
changeset
|
2106 .codec_tag = (const AVCodecTag* const []){codec_3gp_tags, 0}, |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2107 }; |
1169 | 2108 #endif |
4206 | 2109 #if CONFIG_MP4_MUXER |
1169 | 2110 AVOutputFormat mp4_muxer = { |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2111 "mp4", |
3424
7a0230981402
Make long_names in lavf/lavdev optional depending on CONFIG_SMALL.
diego
parents:
3397
diff
changeset
|
2112 NULL_IF_CONFIG_SMALL("MP4 format"), |
286
eccf0c3e3289
Using the extension m4a for audio only MPEG-4 files is increasingly
michael
parents:
259
diff
changeset
|
2113 "application/mp4", |
3452
712d6fab85ee
m4v/m4a are usual itunes/ipod/iphone extensions
bcoudurier
parents:
3451
diff
changeset
|
2114 "mp4", |
4609
065557d6fffb
Rename movenc.c MOVContext to MOVMuxContext, since MOVContext is already used
rbultje
parents:
4587
diff
changeset
|
2115 sizeof(MOVMuxContext), |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2116 CODEC_ID_AAC, |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2117 CODEC_ID_MPEG4, |
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2118 mov_write_header, |
6012 | 2119 ff_mov_write_packet, |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2120 mov_write_trailer, |
4567
963e3b76c7a6
Add AVFMT_VARIABLE_FPS to specify which muxers do not need duplicated frames.
michael
parents:
4463
diff
changeset
|
2121 .flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS, |
3766
f062deeedb8d
Change codec_tag type from const struct AVCodecTag ** to const struct AVCodecTag * const *
reimar
parents:
3759
diff
changeset
|
2122 .codec_tag = (const AVCodecTag* const []){ff_mp4_obj_type, 0}, |
201
85def00971c3
mov, 3gp, mp4 muxer by (Thomas Raivio <tjraivio at cc dot hut dot fi>)
michaelni
parents:
diff
changeset
|
2123 }; |
1169 | 2124 #endif |
4206 | 2125 #if CONFIG_PSP_MUXER |
1169 | 2126 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
|
2127 "psp", |
3424
7a0230981402
Make long_names in lavf/lavdev optional depending on CONFIG_SMALL.
diego
parents:
3397
diff
changeset
|
2128 NULL_IF_CONFIG_SMALL("PSP MP4 format"), |
659
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
2129 NULL, |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
2130 "mp4,psp", |
4609
065557d6fffb
Rename movenc.c MOVContext to MOVMuxContext, since MOVContext is already used
rbultje
parents:
4587
diff
changeset
|
2131 sizeof(MOVMuxContext), |
659
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
2132 CODEC_ID_AAC, |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
2133 CODEC_ID_MPEG4, |
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
2134 mov_write_header, |
6012 | 2135 ff_mov_write_packet, |
659
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
2136 mov_write_trailer, |
911
343ddd5b793c
Fix for title field in PSP compatible mp4 files. Patch by
banan
parents:
910
diff
changeset
|
2137 .flags = AVFMT_GLOBALHEADER, |
3766
f062deeedb8d
Change codec_tag type from const struct AVCodecTag ** to const struct AVCodecTag * const *
reimar
parents:
3759
diff
changeset
|
2138 .codec_tag = (const AVCodecTag* const []){ff_mp4_obj_type, 0}, |
659
6d7c0e6d929e
Sony PSP variation of MP4 patch by <tjcannell AT blueyonder DOT co DOT uk>
mmu_man
parents:
657
diff
changeset
|
2139 }; |
1169 | 2140 #endif |
4206 | 2141 #if CONFIG_TG2_MUXER |
1169 | 2142 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
|
2143 "3g2", |
3424
7a0230981402
Make long_names in lavf/lavdev optional depending on CONFIG_SMALL.
diego
parents:
3397
diff
changeset
|
2144 NULL_IF_CONFIG_SMALL("3GP2 format"), |
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
|
2145 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
|
2146 "3g2", |
4609
065557d6fffb
Rename movenc.c MOVContext to MOVMuxContext, since MOVContext is already used
rbultje
parents:
4587
diff
changeset
|
2147 sizeof(MOVMuxContext), |
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
|
2148 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
|
2149 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
|
2150 mov_write_header, |
6012 | 2151 ff_mov_write_packet, |
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
|
2152 mov_write_trailer, |
715
e214703e4b76
30_clean_up_global_header_flag.patch by (Calcium | calcium nurs or jp)
michael
parents:
711
diff
changeset
|
2153 .flags = AVFMT_GLOBALHEADER, |
3766
f062deeedb8d
Change codec_tag type from const struct AVCodecTag ** to const struct AVCodecTag * const *
reimar
parents:
3759
diff
changeset
|
2154 .codec_tag = (const AVCodecTag* const []){codec_3gp_tags, 0}, |
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
|
2155 }; |
1169 | 2156 #endif |
4206 | 2157 #if CONFIG_IPOD_MUXER |
3143 | 2158 AVOutputFormat ipod_muxer = { |
2159 "ipod", | |
3424
7a0230981402
Make long_names in lavf/lavdev optional depending on CONFIG_SMALL.
diego
parents:
3397
diff
changeset
|
2160 NULL_IF_CONFIG_SMALL("iPod H.264 MP4 format"), |
3143 | 2161 "application/mp4", |
3452
712d6fab85ee
m4v/m4a are usual itunes/ipod/iphone extensions
bcoudurier
parents:
3451
diff
changeset
|
2162 "m4v,m4a", |
4609
065557d6fffb
Rename movenc.c MOVContext to MOVMuxContext, since MOVContext is already used
rbultje
parents:
4587
diff
changeset
|
2163 sizeof(MOVMuxContext), |
3143 | 2164 CODEC_ID_AAC, |
2165 CODEC_ID_H264, | |
2166 mov_write_header, | |
6012 | 2167 ff_mov_write_packet, |
3143 | 2168 mov_write_trailer, |
2169 .flags = AVFMT_GLOBALHEADER, | |
4698 | 2170 .codec_tag = (const AVCodecTag* const []){codec_ipod_tags, 0}, |
3143 | 2171 }; |
2172 #endif |