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