TechSmith / mp4v2

Fork of mp4v2: https://code.google.com/archive/p/mp4v2/
Other
284 stars 135 forks source link

Can mp4v2 encapsulate h265 #37

Open hgstudy opened 4 years ago

hgstudy commented 4 years ago

hi Can h265 be encapsulated?

CarlEdman commented 4 years ago

Definitely. Most days, I'm embedding h265 into mp4 with GPAC and then tagging it with the mp4v2 tools.

avp24 commented 2 years ago

How to encapsulate h265 into mp4 using Mp4v2 libraries? Any sample code available to verify this instead of using GPAC?

enzo1982 commented 2 years ago

Creating H.265/HEVC files is not currently supported in MP4v2, but code to implement support for it will be added soon.

I'm working on bringing features from 3rd party MP4v2 forks into this one. Support for H.265 was added in the Subler fork available in the galad87/mp4v2 repository.

Edit: Didn't realize this discussion was on the TechSmith fork. My commits to support H.265 will be added to the mp4v2.org fork, of course.

avp24 commented 2 years ago

HI @enzo1982

Thank you for your response. H.265/HEVC support is there in MP4V2 libraries. can access new version of library from https://github.com/Pandalzm/mp4v2-h265 repository. I referred a code for dumping H265 into MP4 file using MP4v2 libraries but facing issues. Do your commits have support to dump H.265 into MP4v2?

enzo1982 commented 2 years ago

Thank you for pointing me at the pandalzm repository. I'm not sure if I've seen this before, but in any case I didn't realize that it was a different implementation from the Subler fork. I will consider both implementations when adding H.265 support to the official MP4v2 codebase and will likely use portions of this code too.

Which one is better suited depends on what data your HEVC encoder provides. The Subler code expects all the contents of the hvcC atom to be supplied as a magic cookie when calling AddH265VideoTrack. The pandalzm code is more similar to the previous AVC/H.264 code and expects the video, sequence and picture parameters to be set separately.

So what data do you have and what are the issues you are running into?

avp24 commented 2 years ago

Sure, I will be awaiting for the support of H.265 in official MP4v2 codebase. Also if possible do share an steps or sample code to access the AddH265VideoTrack API in your library.

The issue in this code I am observing is that I need to pass an H.265 encoded streams having NALU unit start code to be "00 00 00 01" instead of "00 00 01". I receive an encoded frame with 00 00 01 start code which this code do not support and maybe relevant changes might have to be done in this sample code to pass this header and the respective frames.

avp24 commented 2 years ago

Hi @enzo1982

I am trying to embed live streams of H.264 for video and PCMU for audio in mp4 using mp4v2 libraries but the mp4 file is not the expected one. Also there is no sync as well.I tried with recorded files instead of live streams but still see the same issue. Instead of mp4v2 I tried with ffmpeg and it works but cannot use ffmpeg due to some platform specific constraints. Do you have any reference for mp4v2 based on which I can identify the problem.

enzo1982 commented 2 years ago

Also there is no sync as well.

Are you setting the duration parameter when calling MP4WriteSample? It is set to MP4_INVALID_DURATION by default, because some codecs have a fixed sample duration and don't need this. No sync sounds like the sample duration might be wrong or missing.