Reputation: 8347
I using avfoundation to record video from my device and going to use imagepicker to select video from gallery and then upload it to local server. Whenever i will fetch uploaded video from server it will not played by using mpmovieplayer, but if i stored some other video of .mov format it will played well. and sometimes my video also played well. my question here is: - is this because of framerate of video - or is this because of streaming problem?
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:outputFileURL])
{
[library writeVideoAtPathToSavedPhotosAlbum:outputFileURL
completionBlock:^(NSURL *assetURL, NSError *error)
{
if (error && [delegate respondsToSelector:@selector(assetLibraryError:forURL:)]) {
[delegate assetLibraryError:error forURL:assetURL];
}
}];
} else {
if ([delegate respondsToSelector:@selector(cannotWriteToAssetLibrary)])
{
[delegate cannotWriteToAssetLibrary];
}
}
[[NSUserDefaults standardUserDefaults] setObject:outputFileURL forKey:@"StoreVideo"];
[library release];
if ([[UIDevice currentDevice] isMultitaskingSupported]) {
[[UIApplication sharedApplication] endBackgroundTask:[self backgroundRecordingID]];
}
if ([delegate respondsToSelector:@selector(recordingFinished)]) {
[delegate recordingFinished];
}
above is the code snipped i am using to save video in asset library after recording.
Upvotes: 1
Views: 589
Reputation: 7844
In order to stream video from a server and play it back with MPMoviePlayer, the file needs to be segmented with the mediafilesegmenter tool. I'm not sure if this is provided with Snow Leopard, but since these tools are updated frequently according to Apple, you should download their latest versions. See Technical Note TN2224 for more information on how to obtain these tools.
The idea is to divide the file into small segments, say 10 seconds each, to facilitate streaming. The tool will create a playlist with an m3u8 extension. The URL to this file is what you will need to provide to MPMoviePlayer.
Even though you are not doing live streaming, you still need to segment your video otherwise it MAY play back on some iOS devices under some iOS versions, but not guaranteed.
Upvotes: 1