Add ApvC codec support to Mp4Muxer.

PiperOrigin-RevId: 707482517
This commit is contained in:
Googler 2024-12-18 03:35:18 -08:00 committed by Copybara-Service
parent 9b628d4542
commit 6d2331fd13
5 changed files with 547 additions and 0 deletions

View File

@ -54,6 +54,7 @@ public class Mp4MuxerEndToEndParameterizedAndroidTest {
"bbb_800x640_768kbps_30fps_avc_2b_firstpts_10_sec.mp4";
private static final String H265_HDR10_MP4 = "hdr10-720p.mp4";
private static final String H265_WITH_METADATA_TRACK_MP4 = "h265_with_metadata_track.mp4";
private static final String APV_MP4 = "sample_with_apvc.mp4";
private static final String AV1_MP4 = "sample_av1.mp4";
private static final String MPEG4_MP4 = "bbb_176x144_192kbps_15fps_mpeg4.mp4";
@ -75,6 +76,7 @@ public class Mp4MuxerEndToEndParameterizedAndroidTest {
H264_WITH_FIRST_PTS_10_SEC,
H265_HDR10_MP4,
H265_WITH_METADATA_TRACK_MP4,
APV_MP4,
AV1_MP4,
MPEG4_MP4,
VP9_WEB,

View File

@ -705,6 +705,8 @@ import org.checkerframework.checker.nullness.qual.PolyNull;
return hvcCBox(format);
case MimeTypes.VIDEO_AV1:
return av1CBox(format);
case MimeTypes.VIDEO_APV:
return apvCBox(format);
case MimeTypes.VIDEO_MP4V:
return esdsBox(format);
case MimeTypes.VIDEO_VP9:
@ -1499,6 +1501,18 @@ import org.checkerframework.checker.nullness.qual.PolyNull;
return BoxUtils.wrapIntoBox("hvcC", contents);
}
/** Returns the apvC box. */
private static ByteBuffer apvCBox(Format format) {
// For APV, the entire codec-specific box is packed into csd-0.
checkArgument(
!format.initializationData.isEmpty(), "csd-0 is not found in the format for avpC box");
byte[] csd0 = format.initializationData.get(0);
checkArgument(csd0.length > 0, "csd-0 is empty for avpC box.");
return BoxUtils.wrapIntoBox("apvC", ByteBuffer.wrap(csd0));
}
/** Returns the av1C box. */
private static ByteBuffer av1CBox(Format format) {
// For AV1, the entire codec-specific box is packed into csd-0.
@ -1675,6 +1689,8 @@ import org.checkerframework.checker.nullness.qual.PolyNull;
return "hvc1";
case MimeTypes.VIDEO_AV1:
return "av01";
case MimeTypes.VIDEO_APV:
return "apv1";
case MimeTypes.VIDEO_MP4V:
return "mp4v-es";
case MimeTypes.VIDEO_VP9:

View File

@ -46,6 +46,7 @@ import java.nio.ByteBuffer;
* <li>H.264 (AVC)
* <li>H.265 (HEVC)
* <li>VP9
* <li>APV
* </ul>
* <li>Audio Codecs:
* <ul>

View File

@ -71,6 +71,7 @@ import org.checkerframework.checker.nullness.qual.EnsuresNonNull;
* <li>H.264 (AVC)
* <li>H.265 (HEVC)
* <li>VP9
* <li>APV
* </ul>
* <li>Audio Codecs:
* <ul>

View File

@ -0,0 +1,527 @@
seekMap:
isSeekable = true
duration = 4166600
getPosition(0) = [[timeUs=0, position=400052]]
getPosition(1) = [[timeUs=0, position=400052], [timeUs=33333, position=446343]]
getPosition(2083300) = [[timeUs=2066644, position=2574107], [timeUs=2099977, position=2607712]]
getPosition(4166600) = [[timeUs=4133288, position=4644330]]
numberOfTracks = 1
track 0:
total output bytes = 4277755
sample count = 125
track duration = 4166600
format 0:
id = 1
containerMimeType = video/mp4
sampleMimeType = video/apv
maxInputSize = 46321
width = 640
height = 480
frameRate = 30.00
colorInfo:
lumaBitdepth = 8
chromaBitdepth = 8
metadata = entries=[Mp4Timestamp: creation time=100000000, modification time=500000000, timescale=10000]
initializationData:
data = length 23, hash 7603C9E2
sample 0:
time = 0
flags = 1
data = length 46291, hash F184D3EA
sample 1:
time = 33333
flags = 1
data = length 45054, hash F206D4C7
sample 2:
time = 66666
flags = 1
data = length 43917, hash 41AF8999
sample 3:
time = 100000
flags = 1
data = length 42718, hash 3133C7AA
sample 4:
time = 133333
flags = 1
data = length 42073, hash 65FC45EF
sample 5:
time = 166666
flags = 1
data = length 41038, hash 7BD21D86
sample 6:
time = 200000
flags = 1
data = length 40179, hash 9BCCCD79
sample 7:
time = 233333
flags = 1
data = length 38738, hash B3D91D1B
sample 8:
time = 266666
flags = 1
data = length 38176, hash FD0085E7
sample 9:
time = 300000
flags = 1
data = length 37326, hash 306F7E88
sample 10:
time = 333333
flags = 1
data = length 36940, hash EE677695
sample 11:
time = 366666
flags = 1
data = length 36320, hash 3FCF3B37
sample 12:
time = 400000
flags = 1
data = length 35664, hash A5C0C7CB
sample 13:
time = 433333
flags = 1
data = length 35666, hash F54C69A5
sample 14:
time = 466666
flags = 1
data = length 35300, hash 77430247
sample 15:
time = 500000
flags = 1
data = length 34693, hash BF72F842
sample 16:
time = 533333
flags = 1
data = length 34708, hash 881A49B1
sample 17:
time = 566655
flags = 1
data = length 33840, hash 9A0CC574
sample 18:
time = 599988
flags = 1
data = length 33835, hash F85444D0
sample 19:
time = 633322
flags = 1
data = length 33845, hash 4B29F464
sample 20:
time = 666655
flags = 1
data = length 33820, hash 3CDA4C6E
sample 21:
time = 699988
flags = 1
data = length 33815, hash 79E145BF
sample 22:
time = 733322
flags = 1
data = length 33832, hash 584A281
sample 23:
time = 766655
flags = 1
data = length 33805, hash 9EA0615E
sample 24:
time = 799988
flags = 1
data = length 33797, hash CC7BD45E
sample 25:
time = 833322
flags = 1
data = length 33476, hash E0627655
sample 26:
time = 866655
flags = 1
data = length 33475, hash FBB3502A
sample 27:
time = 899988
flags = 1
data = length 33465, hash 619353FE
sample 28:
time = 933322
flags = 1
data = length 33459, hash 93D6B187
sample 29:
time = 966655
flags = 1
data = length 33461, hash DF9982DC
sample 30:
time = 999988
flags = 1
data = length 33449, hash 25E4D68E
sample 31:
time = 1033322
flags = 1
data = length 33432, hash F73FC227
sample 32:
time = 1066655
flags = 1
data = length 33419, hash B13787E3
sample 33:
time = 1099988
flags = 1
data = length 33386, hash 788C2D32
sample 34:
time = 1133322
flags = 1
data = length 33727, hash 46D81267
sample 35:
time = 1166655
flags = 1
data = length 33707, hash B5D58D87
sample 36:
time = 1199988
flags = 1
data = length 33671, hash E7BAAE7F
sample 37:
time = 1233322
flags = 1
data = length 33638, hash 18005555
sample 38:
time = 1266655
flags = 1
data = length 33593, hash 42021830
sample 39:
time = 1299988
flags = 1
data = length 33569, hash D8029128
sample 40:
time = 1333322
flags = 1
data = length 33523, hash FB58F62
sample 41:
time = 1366655
flags = 1
data = length 33497, hash 129B0638
sample 42:
time = 1399988
flags = 1
data = length 33473, hash 7A79A045
sample 43:
time = 1433322
flags = 1
data = length 33445, hash 4E0CF40B
sample 44:
time = 1466655
flags = 1
data = length 33418, hash 635FCB0
sample 45:
time = 1499988
flags = 1
data = length 33424, hash D2D749EE
sample 46:
time = 1533322
flags = 1
data = length 33405, hash 5A62251E
sample 47:
time = 1566655
flags = 1
data = length 33403, hash 719C366
sample 48:
time = 1599988
flags = 1
data = length 33422, hash 3ED7C42D
sample 49:
time = 1633322
flags = 1
data = length 33430, hash 7A8CA910
sample 50:
time = 1666655
flags = 1
data = length 33217, hash E28C94FD
sample 51:
time = 1699977
flags = 1
data = length 33263, hash 66DA3079
sample 52:
time = 1733311
flags = 1
data = length 33308, hash 7A7D0074
sample 53:
time = 1766644
flags = 1
data = length 33340, hash C0B0CDEA
sample 54:
time = 1799977
flags = 1
data = length 33372, hash AB58ECF3
sample 55:
time = 1833311
flags = 1
data = length 33436, hash AF2870E0
sample 56:
time = 1866644
flags = 1
data = length 33484, hash 5B399761
sample 57:
time = 1899977
flags = 1
data = length 33533, hash 7C123CE2
sample 58:
time = 1933311
flags = 1
data = length 33577, hash 5B94935F
sample 59:
time = 1966644
flags = 1
data = length 33615, hash 656D8603
sample 60:
time = 1999977
flags = 1
data = length 33556, hash 68E72B55
sample 61:
time = 2033311
flags = 1
data = length 33597, hash FFB1545C
sample 62:
time = 2066644
flags = 1
data = length 33605, hash 84DC1F1D
sample 63:
time = 2099977
flags = 1
data = length 33144, hash 57E599D4
sample 64:
time = 2133311
flags = 1
data = length 33171, hash FB92ED17
sample 65:
time = 2166644
flags = 1
data = length 33651, hash AF3A5151
sample 66:
time = 2199977
flags = 1
data = length 33174, hash C2094641
sample 67:
time = 2233311
flags = 1
data = length 33185, hash 17FC6A0
sample 68:
time = 2266644
flags = 1
data = length 33659, hash 8CAA78B3
sample 69:
time = 2299977
flags = 1
data = length 33164, hash 611D5ED
sample 70:
time = 2333311
flags = 1
data = length 33631, hash 7FC4E90C
sample 71:
time = 2366644
flags = 1
data = length 33157, hash 8C9BE824
sample 72:
time = 2399977
flags = 1
data = length 33613, hash 8F56735C
sample 73:
time = 2433311
flags = 1
data = length 33130, hash FE728EAD
sample 74:
time = 2466644
flags = 1
data = length 33589, hash 5AD12E53
sample 75:
time = 2499977
flags = 1
data = length 33612, hash 40695796
sample 76:
time = 2533311
flags = 1
data = length 33134, hash B0122256
sample 77:
time = 2566644
flags = 1
data = length 33590, hash 5787C725
sample 78:
time = 2599977
flags = 1
data = length 33595, hash 81B7A445
sample 79:
time = 2633311
flags = 1
data = length 33562, hash 3B6CF24A
sample 80:
time = 2666644
flags = 1
data = length 33086, hash DFA77B90
sample 81:
time = 2699977
flags = 1
data = length 33559, hash 7EE31196
sample 82:
time = 2733311
flags = 1
data = length 33534, hash 1E533F20
sample 83:
time = 2766644
flags = 1
data = length 33535, hash EA10535
sample 84:
time = 2799966
flags = 1
data = length 33522, hash AD85B29A
sample 85:
time = 2833300
flags = 1
data = length 33482, hash 242C9D1
sample 86:
time = 2866633
flags = 1
data = length 33474, hash A5BA5430
sample 87:
time = 2899966
flags = 1
data = length 33453, hash 13A2FEFE
sample 88:
time = 2933300
flags = 1
data = length 33409, hash 5C8231F1
sample 89:
time = 2966633
flags = 1
data = length 33385, hash C38CC146
sample 90:
time = 2999966
flags = 1
data = length 33355, hash 950481DC
sample 91:
time = 3033300
flags = 1
data = length 33335, hash 2744D3BC
sample 92:
time = 3066633
flags = 1
data = length 33377, hash 67C4C0
sample 93:
time = 3099966
flags = 1
data = length 33339, hash 746966D3
sample 94:
time = 3133300
flags = 1
data = length 33319, hash 1398764F
sample 95:
time = 3166633
flags = 1
data = length 33287, hash 9E7473D0
sample 96:
time = 3199966
flags = 1
data = length 33265, hash EEAF849B
sample 97:
time = 3233300
flags = 1
data = length 33261, hash 8037846B
sample 98:
time = 3266633
flags = 1
data = length 33226, hash 4F4FAA8D
sample 99:
time = 3299966
flags = 1
data = length 33203, hash 20A984DE
sample 100:
time = 3333300
flags = 1
data = length 33588, hash F0F05CD1
sample 101:
time = 3366633
flags = 1
data = length 33594, hash A3257252
sample 102:
time = 3399966
flags = 1
data = length 33584, hash 54AC38AC
sample 103:
time = 3433300
flags = 1
data = length 33216, hash 7A5A33B9
sample 104:
time = 3466633
flags = 1
data = length 33219, hash F1083DEC
sample 105:
time = 3499966
flags = 1
data = length 33592, hash 3BB94CA7
sample 106:
time = 3533300
flags = 1
data = length 33227, hash 9E084D49
sample 107:
time = 3566633
flags = 1
data = length 33244, hash CCAFE8CB
sample 108:
time = 3599966
flags = 1
data = length 33250, hash 920EF3EA
sample 109:
time = 3633300
flags = 1
data = length 33278, hash D1089D1B
sample 110:
time = 3666633
flags = 1
data = length 33300, hash 2BED2033
sample 111:
time = 3699966
flags = 1
data = length 33321, hash FD2B6BE7
sample 112:
time = 3733300
flags = 1
data = length 33337, hash F63EA811
sample 113:
time = 3766633
flags = 1
data = length 33383, hash 9DAB8833
sample 114:
time = 3799966
flags = 1
data = length 33321, hash 55D58114
sample 115:
time = 3833300
flags = 1
data = length 33347, hash 412B5794
sample 116:
time = 3866633
flags = 1
data = length 33374, hash 283D32F9
sample 117:
time = 3899955
flags = 1
data = length 33420, hash ADA33226
sample 118:
time = 3933288
flags = 1
data = length 33435, hash 483803AC
sample 119:
time = 3966622
flags = 1
data = length 33469, hash EAEF9B95
sample 120:
time = 3999955
flags = 1
data = length 33507, hash CCD8AF2C
sample 121:
time = 4033288
flags = 1
data = length 33509, hash 845D5587
sample 122:
time = 4066622
flags = 1
data = length 33453, hash 28BF6F7F
sample 123:
time = 4099955
flags = 1
data = length 33483, hash A98EABD3
sample 124:
time = 4133288
flags = 536870913
data = length 33477, hash 404E7F2D
tracksEnded = true