Add Muxer end to end tests

Following test cases are added:
1. Mux H264 video
2. Mux H265 video
3. Mux HDR video

Each test case performs following actions:
1. Extract track and samples from input Mp4 using MediaExtractor.
2. Feed those samples into Mp4 muxer.
3. Use extractor to extract the samples from muxed file and create dump file.

PiperOrigin-RevId: 512589069
This commit is contained in:
sheenachhabra 2023-02-27 12:14:51 +00:00 committed by tonihei
parent a02c8d855c
commit ffc268eb7e
5 changed files with 2916 additions and 0 deletions

Binary file not shown.

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,337 @@
seekMap:
isSeekable = true
duration = 1065600
getPosition(0) = [[timeUs=0, position=44]]
getPosition(1) = [[timeUs=0, position=44]]
getPosition(532800) = [[timeUs=0, position=44]]
getPosition(1065600) = [[timeUs=0, position=44]]
numberOfTracks = 2
track 0:
total output bytes = 89876
sample count = 30
format 0:
id = 1
sampleMimeType = video/avc
codecs = avc1.64001F
maxInputSize = 36722
width = 1080
height = 720
frameRate = 32.113037
initializationData:
data = length 29, hash 4746B5D9
data = length 10, hash 7A0D0F2B
sample 0:
time = 0
flags = 1
data = length 36692, hash D216076E
sample 1:
time = 66722
flags = 0
data = length 5312, hash D45D3CA0
sample 2:
time = 33355
flags = 0
data = length 599, hash 1BE7812D
sample 3:
time = 200200
flags = 0
data = length 7735, hash 4490F110
sample 4:
time = 133455
flags = 0
data = length 987, hash 560B5036
sample 5:
time = 100100
flags = 0
data = length 673, hash ED7CD8C7
sample 6:
time = 166822
flags = 0
data = length 523, hash 3020DF50
sample 7:
time = 333655
flags = 0
data = length 6061, hash 736C72B2
sample 8:
time = 266922
flags = 0
data = length 992, hash FE132F23
sample 9:
time = 233555
flags = 0
data = length 623, hash 5B2C1816
sample 10:
time = 300300
flags = 0
data = length 421, hash 742E69C1
sample 11:
time = 433755
flags = 0
data = length 4899, hash F72F86A1
sample 12:
time = 400400
flags = 0
data = length 568, hash 519A8E50
sample 13:
time = 367022
flags = 0
data = length 620, hash 3990AA39
sample 14:
time = 567222
flags = 0
data = length 5450, hash F06EC4AA
sample 15:
time = 500500
flags = 0
data = length 1051, hash 92DFA63A
sample 16:
time = 467122
flags = 0
data = length 874, hash 69587FB4
sample 17:
time = 533855
flags = 0
data = length 781, hash 36BE495B
sample 18:
time = 700700
flags = 0
data = length 4725, hash AC0C8CD3
sample 19:
time = 633955
flags = 0
data = length 1022, hash 5D8BFF34
sample 20:
time = 600600
flags = 0
data = length 790, hash 99413A99
sample 21:
time = 667322
flags = 0
data = length 610, hash 5E129290
sample 22:
time = 834155
flags = 0
data = length 2751, hash 769974CB
sample 23:
time = 767422
flags = 0
data = length 745, hash B78A477A
sample 24:
time = 734055
flags = 0
data = length 621, hash CF741E7A
sample 25:
time = 800800
flags = 0
data = length 505, hash 1DB4894E
sample 26:
time = 967622
flags = 0
data = length 1268, hash C15348DC
sample 27:
time = 900900
flags = 0
data = length 880, hash C2DE85D0
sample 28:
time = 867522
flags = 0
data = length 530, hash C98BC6A8
sample 29:
time = 934255
flags = 536870912
data = length 568, hash 4FE5C8EA
track 1:
total output bytes = 9529
sample count = 45
format 0:
peakBitrate = 200000
id = 2
sampleMimeType = audio/mp4a-latm
codecs = mp4a.40.2
maxInputSize = 294
channelCount = 1
sampleRate = 44100
language = und
initializationData:
data = length 2, hash 5F7
sample 0:
time = 0
flags = 1
data = length 23, hash 47DE9131
sample 1:
time = 67208
flags = 1
data = length 6, hash 31EC5206
sample 2:
time = 90416
flags = 1
data = length 148, hash 894A176B
sample 3:
time = 113645
flags = 1
data = length 189, hash CEF235A1
sample 4:
time = 136854
flags = 1
data = length 205, hash BBF5F7B0
sample 5:
time = 160083
flags = 1
data = length 210, hash F278B193
sample 6:
time = 183291
flags = 1
data = length 210, hash 82DA1589
sample 7:
time = 206520
flags = 1
data = length 207, hash 5BE231DF
sample 8:
time = 229750
flags = 1
data = length 225, hash 18819EE1
sample 9:
time = 252958
flags = 1
data = length 215, hash CA7FA67B
sample 10:
time = 276187
flags = 1
data = length 211, hash 581A1C18
sample 11:
time = 299395
flags = 1
data = length 216, hash ADB88187
sample 12:
time = 322625
flags = 1
data = length 229, hash 2E8BA4DC
sample 13:
time = 345833
flags = 1
data = length 232, hash 22F0C510
sample 14:
time = 369062
flags = 1
data = length 235, hash 867AD0DC
sample 15:
time = 392270
flags = 1
data = length 231, hash 84E823A8
sample 16:
time = 415500
flags = 1
data = length 226, hash 1BEF3A95
sample 17:
time = 438729
flags = 1
data = length 216, hash EAA345AE
sample 18:
time = 461937
flags = 1
data = length 229, hash 6957411F
sample 19:
time = 485166
flags = 1
data = length 219, hash 41275022
sample 20:
time = 508375
flags = 1
data = length 241, hash 6495DF96
sample 21:
time = 531604
flags = 1
data = length 228, hash 63D95906
sample 22:
time = 554812
flags = 1
data = length 238, hash 34F676F9
sample 23:
time = 578041
flags = 1
data = length 234, hash E5CBC045
sample 24:
time = 601250
flags = 1
data = length 231, hash 5FC43661
sample 25:
time = 624479
flags = 1
data = length 217, hash 682708ED
sample 26:
time = 647708
flags = 1
data = length 239, hash D43780FC
sample 27:
time = 670916
flags = 1
data = length 243, hash C5E17980
sample 28:
time = 694145
flags = 1
data = length 231, hash AC5837BA
sample 29:
time = 717354
flags = 1
data = length 230, hash 169EE895
sample 30:
time = 740583
flags = 1
data = length 238, hash C48FF3F1
sample 31:
time = 763791
flags = 1
data = length 225, hash 531E4599
sample 32:
time = 787020
flags = 1
data = length 232, hash CB3C6B8D
sample 33:
time = 810229
flags = 1
data = length 243, hash F8C94C7
sample 34:
time = 833458
flags = 1
data = length 232, hash A646A7D0
sample 35:
time = 856687
flags = 1
data = length 237, hash E8B787A5
sample 36:
time = 879895
flags = 1
data = length 228, hash 3FA7A29F
sample 37:
time = 903125
flags = 1
data = length 235, hash B9B33B0A
sample 38:
time = 926333
flags = 1
data = length 264, hash 71A4869E
sample 39:
time = 949562
flags = 1
data = length 257, hash D049B54C
sample 40:
time = 972770
flags = 1
data = length 227, hash 66757231
sample 41:
time = 996000
flags = 1
data = length 227, hash BD374F1B
sample 42:
time = 1019208
flags = 1
data = length 235, hash 999477F6
sample 43:
time = 1042437
flags = 1
data = length 229, hash FFF98DF0
sample 44:
time = 1065666
flags = 536870913
data = length 6, hash 31B22286
tracksEnded = true

File diff suppressed because it is too large Load diff

View file

@ -45,6 +45,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.primitives.Bytes;
import com.google.common.truth.Correspondence;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@ -189,6 +190,12 @@ public class TestUtil {
return Util.toByteArray(getInputStream(context, fileName));
}
/** Returns the bytes of a cache file using its file path. */
public static byte[] getByteArrayFromCache(String cacheFilePath) throws IOException {
InputStream inputStream = new FileInputStream(cacheFilePath);
return Util.toByteArray(inputStream);
}
/** Returns an {@link InputStream} for reading from an asset file. */
public static InputStream getInputStream(Context context, String fileName) throws IOException {
return context.getResources().getAssets().open(fileName);
@ -403,6 +410,26 @@ public class TestUtil {
public static FakeExtractorOutput extractAllSamplesFromFile(
Extractor extractor, Context context, String fileName) throws IOException {
byte[] data = TestUtil.getByteArray(context, fileName);
return extractAllSamplesFromByteArray(extractor, data);
}
/**
* Extracts all samples from the given storage file into a {@link FakeTrackOutput}.
*
* @param extractor The {@link Extractor} to extractor from input.
* @param cacheFilePath The cache file path.
* @return The {@link FakeTrackOutput} containing the extracted samples.
* @throws IOException If an error occurred reading from the input, or if the extractor finishes
* reading from input without extracting any {@link SeekMap}.
*/
public static FakeExtractorOutput extractAllSamplesFromCacheFile(
Extractor extractor, String cacheFilePath) throws IOException {
byte[] data = TestUtil.getByteArrayFromCache(cacheFilePath);
return extractAllSamplesFromByteArray(extractor, data);
}
private static FakeExtractorOutput extractAllSamplesFromByteArray(
Extractor extractor, byte[] data) throws IOException {
FakeExtractorOutput expectedOutput = new FakeExtractorOutput();
extractor.init(expectedOutput);
FakeExtractorInput input = new FakeExtractorInput.Builder().setData(data).build();