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