Add support for muxing some kind of Dolby Vision tracks.
This commit is contained in:
3 files changed
+69
-9
No files matched your search
@@ -223,6 +223,22 @@ typedef struct MP4DemuxHelper {
|
||||
free(ppValue);
|
||||
return magicCookie;
|
||||
}
|
||||
else if (!strcmp(media_data_name, "dvhe")) {
|
||||
uint8_t *ppValue;
|
||||
uint32_t pValueSize;
|
||||
MP4GetTrackBytesProperty(_fileHandle, srcTrackId, "mdia.minf.stbl.stsd.dvhe.hvcC.content", &ppValue, &pValueSize);
|
||||
magicCookie = [NSData dataWithBytes:ppValue length:pValueSize];
|
||||
free(ppValue);
|
||||
return magicCookie;
|
||||
}
|
||||
else if (!strcmp(media_data_name, "dvh1")) {
|
||||
uint8_t *ppValue;
|
||||
uint32_t pValueSize;
|
||||
MP4GetTrackBytesProperty(_fileHandle, srcTrackId, "mdia.minf.stbl.stsd.dvh1.hvcC.content", &ppValue, &pValueSize);
|
||||
magicCookie = [NSData dataWithBytes:ppValue length:pValueSize];
|
||||
free(ppValue);
|
||||
return magicCookie;
|
||||
}
|
||||
else if (!strcmp(media_data_name, "av01")) {
|
||||
uint8_t *ppValue;
|
||||
uint32_t pValueSize;
|
||||
|
||||
+51
-9
@@ -213,6 +213,7 @@ MP42_OBJC_DIRECT_MEMBERS
|
||||
else if ([track isMemberOfClass:[MP42VideoTrack class]] &&
|
||||
(format == kMP42VideoCodecType_HEVC || format == kMP42VideoCodecType_HEVC_PSinBitstream)) {
|
||||
|
||||
MP42VideoTrack *videoTrack = (MP42VideoTrack *)track;
|
||||
uint8_t *hvcCAtom = (uint8_t *)magicCookie.bytes;
|
||||
|
||||
if ([_options[MP42ForceHvc1] boolValue] && magicCookie.length < UINT32_MAX) {
|
||||
@@ -224,15 +225,21 @@ MP42_OBJC_DIRECT_MEMBERS
|
||||
if (magicCookie.length && magicCookie.length < UINT32_MAX && !analyze_HEVC(magicCookie.bytes, (uint32_t)magicCookie.length, &completeness)) {
|
||||
|
||||
dstTrackId = MP4AddH265VideoTrack(_fileHandle, timeScale, MP4_INVALID_DURATION,
|
||||
((MP42VideoTrack *)track).width, ((MP42VideoTrack *)track).height,
|
||||
videoTrack.width, videoTrack.height,
|
||||
magicCookie.bytes, (uint32_t)magicCookie.length,
|
||||
completeness);
|
||||
|
||||
if (dstTrackId) {
|
||||
if (completeness) {
|
||||
MP4SetTrackBytesProperty(_fileHandle, dstTrackId, "mdia.minf.stbl.stsd.hvc1.hvcC.content", magicCookie.bytes, (uint32_t)magicCookie.length);
|
||||
}
|
||||
else {
|
||||
MP4SetTrackBytesProperty(_fileHandle, dstTrackId, "mdia.minf.stbl.stsd.hev1.hvcC.content", magicCookie.bytes, (uint32_t)magicCookie.length);
|
||||
if (videoTrack.dolbyVision.versionMajor > 0) {
|
||||
MP4SetDolbyVisionMetadata(_fileHandle, dstTrackId,
|
||||
videoTrack.dolbyVision.versionMajor,
|
||||
videoTrack.dolbyVision.versionMinor,
|
||||
videoTrack.dolbyVision.profile,
|
||||
videoTrack.dolbyVision.level,
|
||||
videoTrack.dolbyVision.rpuPresentFlag,
|
||||
videoTrack.dolbyVision.elPresentFlag,
|
||||
videoTrack.dolbyVision.blPresentFlag,
|
||||
videoTrack.dolbyVision.blSignalCompatibilityId);
|
||||
}
|
||||
[importer setActiveTrack:track];
|
||||
}
|
||||
@@ -247,16 +254,51 @@ MP42_OBJC_DIRECT_MEMBERS
|
||||
}
|
||||
}
|
||||
|
||||
// Dolby Vision H.265 video track
|
||||
else if ([track isMemberOfClass:[MP42VideoTrack class]] &&
|
||||
(format == kMP42VideoCodecType_DolbyVisionHEVC || format == kMP42VideoCodecType_DolbyVisionHEVC_PSinBitstream)) {
|
||||
|
||||
MP42VideoTrack *videoTrack = (MP42VideoTrack *)track;
|
||||
bool completeness = 0;
|
||||
if (magicCookie.length && magicCookie.length < UINT32_MAX && !analyze_HEVC(magicCookie.bytes, (uint32_t)magicCookie.length, &completeness)) {
|
||||
|
||||
dstTrackId = MP4AddDolbyVisionH265VideoTrack(_fileHandle, timeScale, MP4_INVALID_DURATION,
|
||||
videoTrack.width, videoTrack.height,
|
||||
magicCookie.bytes, (uint32_t)magicCookie.length,
|
||||
videoTrack.dolbyVision.versionMajor,
|
||||
videoTrack.dolbyVision.versionMinor,
|
||||
videoTrack.dolbyVision.profile,
|
||||
videoTrack.dolbyVision.level,
|
||||
videoTrack.dolbyVision.rpuPresentFlag,
|
||||
videoTrack.dolbyVision.elPresentFlag,
|
||||
videoTrack.dolbyVision.blPresentFlag,
|
||||
videoTrack.dolbyVision.blSignalCompatibilityId,
|
||||
completeness);
|
||||
|
||||
if (dstTrackId) {
|
||||
[importer setActiveTrack:track];
|
||||
}
|
||||
else {
|
||||
[unsupportedTracks addObject:track];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
[unsupportedTracks addObject:track];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// AV1 video track
|
||||
else if ([track isMemberOfClass:[MP42VideoTrack class]] && (format == kMP42VideoCodecType_AV1)) {
|
||||
|
||||
MP42VideoTrack *videoTrack = (MP42VideoTrack *)track;
|
||||
if (magicCookie.length && magicCookie.length < UINT32_MAX) {
|
||||
|
||||
dstTrackId = MP4AddAV1VideoTrack(_fileHandle, timeScale, MP4_INVALID_DURATION,
|
||||
((MP42VideoTrack *)track).width, ((MP42VideoTrack *)track).height);
|
||||
videoTrack.width, videoTrack.height,
|
||||
magicCookie.bytes, (uint32_t)magicCookie.length);
|
||||
|
||||
if (dstTrackId) {
|
||||
MP4SetTrackBytesProperty(_fileHandle, dstTrackId, "mdia.minf.stbl.stsd.av01.av1C.av1Config", magicCookie.bytes, (uint32_t)magicCookie.length);
|
||||
[importer setActiveTrack:track];
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -42,6 +42,8 @@ BOOL isTrackMuxable(FourCharCode format)
|
||||
FourCharCode supportedFormats[] = {kMP42VideoCodecType_AV1,
|
||||
kMP42VideoCodecType_HEVC,
|
||||
kMP42VideoCodecType_HEVC_PSinBitstream,
|
||||
kMP42VideoCodecType_DolbyVisionHEVC,
|
||||
kMP42VideoCodecType_DolbyVisionHEVC_PSinBitstream,
|
||||
kMP42VideoCodecType_H264,
|
||||
kMP42VideoCodecType_MPEG4Video,
|
||||
kMP42VideoCodecType_JPEG,
|
||||
|
||||
Reference in new issue
Block a user