From 2fcf67f7f6894cd33d5c4ad611d0f875862d51d8 Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Tue, 16 Aug 2016 09:49:28 +0200 Subject: [PATCH] Fix HEVC from mp4. --- MP42/MP42Mp4Importer.m | 8 ++++++++ MP42/MP42Muxer.m | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/MP42/MP42Mp4Importer.m b/MP42/MP42Mp4Importer.m index 28f3225..63ba45d 100644 --- a/MP42/MP42Mp4Importer.m +++ b/MP42/MP42Mp4Importer.m @@ -237,6 +237,14 @@ free(ppValue); return magicCookie; } + else if (!strcmp(media_data_name, "hvc1")) { + uint8_t *ppValue; + uint32_t pValueSize; + MP4GetTrackBytesProperty(_fileHandle, srcTrackId, "mdia.minf.stbl.stsd.hvc1.hvcC.content", &ppValue, &pValueSize); + magicCookie = [NSData dataWithBytes:ppValue length:pValueSize]; + free(ppValue); + return magicCookie; + } else if (!strcmp(media_data_name, "mp4v")) { uint8_t *ppConfig; uint32_t pConfigSize; MP4GetTrackESConfiguration(_fileHandle, srcTrackId, &ppConfig, &pConfigSize); diff --git a/MP42/MP42Muxer.m b/MP42/MP42Muxer.m index 1eba54f..b8a2843 100644 --- a/MP42/MP42Muxer.m +++ b/MP42/MP42Muxer.m @@ -135,6 +135,7 @@ if ([track isMemberOfClass:[MP42VideoTrack class]] && track.format == kMP42VideoCodecType_H264) { if (magicCookie.length < sizeof(uint8_t) * 6) { + [unsupportedTracks addObject:track]; continue; } @@ -207,10 +208,12 @@ [helper->importer setActiveTrack:track]; } else { + [unsupportedTracks addObject:track]; continue; } } else { + [unsupportedTracks addObject:track]; continue; } } @@ -260,8 +263,10 @@ // AC-3 audio track else if ([track isMemberOfClass:[MP42AudioTrack class]] && track.format == kMP42AudioCodecType_AC3) { - if ([magicCookie length] < sizeof(uint64_t) * 6) + if (magicCookie.length < sizeof(uint64_t) * 6) { + [unsupportedTracks addObject:track]; continue; + } const uint64_t *ac3Info = (const uint64_t *)[magicCookie bytes]; @@ -399,8 +404,10 @@ // VobSub bitmap track else if ([track isMemberOfClass:[MP42SubtitleTrack class]] && track.format == kMP42SubtitleCodecType_VobSub) { - if (magicCookie.length < sizeof(uint32_t) * 16) + if (magicCookie.length < sizeof(uint32_t) * 16) { + [unsupportedTracks addObject:track]; continue; + } dstTrackId = MP4AddSubpicTrack(_fileHandle, timeScale, 640, 480);