1

I have a file with raw compressed video samples (H.264) and I'd like to append them to an AVMutableMovieTrack's media without copying them. The append(_:decodeTime:presentationTime:) documentation implies this is possible: "If the sample buffer carries sample references only, sample data will not be written and sample references to the samples in their original container are appended to the track's media as necessary." That's exactly what I want, but how do I create a CMSampleBuffer that references the data in a file?

ScuBall
  • 11
  • 2
  • Creating `CMSampleBuffer` from H.264 Elementary Stream not a trivial task this days, you need first parse your H.264 file and then create CMSampleBuffer from it. I suggest you read: https://stackoverflow.com/questions/24884827/possible-locations-for-sequence-picture-parameter-sets-for-h-264-stream and also this good Q/A about how to create/display: https://stackoverflow.com/questions/29525000/how-to-use-videotoolbox-to-decompress-h-264-video-stream – vpoltave Sep 21 '20 at 08:48
  • This video can help you as well: https://developer.apple.com/videos/play/wwdc2014/513/ – vpoltave Sep 21 '20 at 08:50
  • Thanks! Those were very helpful links for the H.264 part of my problem. I do have some control over the raw data in the file, so I can make sure it's AVCC if that's what the framework prefers. – ScuBall Sep 23 '20 at 06:37

0 Answers0