0

I'm trying to add subtitles to an existing movie and everything seems to work as expected except for the background of the subtitles track that should be transparent.

MediaHandler media = GetMediaHandler([[subtitlesTrack media] quickTimeMedia]);
MediaSetGraphicsMode(media, graphicsModeStraightAlpha, NULL);

I have already tried the above code found here but I was not able to use the GetMediaHandler and MediaSetGraphicsMode functions. Maybe I'm missing some includes.

I would prefer doing it using only the QTKit framework if possible.

Community
  • 1
  • 1
Bruno Ferreira
  • 942
  • 9
  • 22
  • Are you targeting 64-bit or 32-bit? Most if not all of the old QuickTime stuff is not available in 64-bit. Only QTKit (the Objective-C-based framework) is available in 64-bit. – Peter Hosey Jan 14 '13 at 01:29
  • I'm targeting 64-bit platform. So that means that I cannot use the C API? If not is there a way to do the same with the QTKit? – Bruno Ferreira Jan 14 '13 at 01:34
  • Correct: 64-bit apps cannot use the old C QuickTime API. I don't know of a way to do this with QTKit. You might look into AVFoundation, though I don't know of a way to do this with that, either (even *playing* subtitles with AVFoundation is a mystery I still haven't solved yet). – Peter Hosey Jan 14 '13 at 02:31
  • @PeterHosey Thanks. I'll take a look at AVFoundation. – Bruno Ferreira Jan 14 '13 at 08:59

1 Answers1

1

If you're using this code as an example in a 32-bit Mac application, to get alpha transparency to work normally, the second parameter to MediaSetGraphicsMode() must be graphicsModePreBlackAlpha.

If you use graphicsModeStraightAlpha, the video frames after compression into the QuickTime media won't have an alpha channel, at least under Mac OS 10.10.5.

You also need to be sure to use a video codec that supports alpha channels - not all of them do.

Bob Murphy
  • 5,814
  • 2
  • 32
  • 35