Reputation: 1564
as UIImagePickerController can got the video , but how to add subtitle to the video ?
any tips.... Thanks for your in advance .
Upvotes: 1
Views: 994
Reputation: 8720
If you want to add subtitles as an overlay:
Create a label or text view over top of the view playing the movie. Then make a data class to hold the label text and time starting and ending.
Then you can lookup the text every second or so and display the text as appropriate.
If you need to hard code the subtitles, then it can't be done in real-time. You will need to extract the frames, then add the text to the images, then save the new frames as a movie.
You can start searching for AssetWriter for more info on this.
Upvotes: 0
Reputation: 58796
Unfortunately there are no APIs for working with images like that. The only video-related functions relate to playback, using the built in "trim" editing feature, and being able to read/write the raw file data for a movie.
You can access the raw data for a movie (and save it out again) so if you could find third-party libraries that supported this you could in theory add this yourself. You would do something like generating frames of text using the regular iPhone APIs and then overlay them into the existing video.
The problem would be finding libraries that are suitable, the limited memory on the iPhone (it's unlikely you could load the entire movie into memory at once), and the CPU cost of decoding/recoding the movie data.
Upvotes: 0
Reputation: 43452
You can't. The control of video is very limited on the phone, in general you can only clip the beginning and end, and I imagine that that is handled by lopping things off at the GOPs where it is easy. Adding a subtitle would require at a minimum transmuxing the file (for a soft subtitle), and probably reencoding the entire stream (for a hard subtitle). Performing that on the iPhone's CPU would be very slow, and the HW encoder is not exposed at a level you can use (even if it was it might have limitations that prevent it from being used for this sort of thing).
Upvotes: 1