0

i already know that i should use AVFoundationto get the CGContextRef from .mp4 file;

and use like :

CATextLayer *subtitle1Text = [[CATextLayer alloc] init];
[subtitle1Text setFont:@"Helvetica-Bold"];
[subtitle1Text setFontSize:36];
[subtitle1Text setFrame:CGRectMake(0, 0, size.width, 400)];
[subtitle1Text setString:[self.subtitles objectAtIndex:idx]];
[subtitle1Text setAlignmentMode:kCAAlignmentCenter];
[subtitle1Text setForegroundColor:[[UIColor whiteColor] CGColor]];

[subtitle1Text drawInContext:context];

to make subtitles;

now the question is how can i get CGContextRef from .mp4 file?

i mean i've got the url of .mp4 file, but how can i add CATextLayer in the mp4?

abhishekkharwar
  • 3,529
  • 2
  • 18
  • 31
罗储华
  • 15
  • 1
  • 7
  • Have you checked this tutorial? http://www.raywenderlich.com/30200/avfoundation-tutorial-adding-overlays-and-animations-to-videos – aBilal17 May 18 '15 at 07:42
  • In this tutorial everything is mentioned, – aBilal17 May 18 '15 at 07:59
  • i've found http://www.raywenderlich.com/30200/avfoundation-tutorial-adding-overlays-and-animations-to-videos, and now i'm trying to read it,but it's kind of difficult.....but think you any way @aBilal17 – 罗储华 May 18 '15 at 08:03

1 Answers1

0

You have to use AVFoundation framework in order to add text on video you can have a look into the following link for more detail. You have add the text layer on video layer and then have to export it.

AVMutableComposition

Have a look into bellow sample code there is a way to add watermark you can create subtitles by changing few properties like start time and end time.

AVSimpleEditoriOS

abhishekkharwar
  • 3,529
  • 2
  • 18
  • 31