Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS video streaming and storing on device afterwards

So far I know how to stream a video and how to download it and afterwards stream it, but here's the tricky bit: streaming it once, storing it on the device and in the future play it from the device.

Is that possible?

like image 366
Tudor Avatar asked Jun 09 '11 08:06

Tudor


People also ask

Does Streaming take up storage iPhone?

But whenever you stream the video, it actually takes up storage in your iPhone. Everytime a video is being watched, your available storage capacity in your phone keeps on getting decreased quite significantly.

Does streaming use up storage?

1 viewer watching your live stream for 1 hour = 1 viewer hour = 0.64 GB (0.00064 TB) of streaming. 100 viewers watch your live stream for 1 hour each = 100 viewer hours = 64.37 GB (0.06437 TB) of streaming. 1,000 viewers watch your stream for 1 hour each = 1,000 viewer hours = 643.73 GB (0.64373 TB) of streaming.


2 Answers

Not quite sure here how you get your stream but look in to the AVAssetWriter, AVAssetWriterInput and AVAssetWriterPixelBufferAdaptor and as soon as you receive data you should be able to append the data to the to the pixel buffer adaptor using:

appendPixelBuffer:withPresentationTime: 

not sure it will work for you but with some fiddling you should be able to adapt your input to match this method. There are lots of example code for setting up the writer

like image 99
Robin Rye Avatar answered Sep 29 '22 16:09

Robin Rye


It's quite easy to save the video. Do something similar to this:

//Saving Movie NSMutableData *data = [[NSMutableData alloc] init]; NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];           [archiver encodeObject:*MovieObject* forKey:@"MovieObjectDataKey"]; [archiver finishEncoding]; [[NSUserDefaults standardUserDefaults] setObject:data forKey:@"MovieObjectDefaultsDataKey"]; [archiver release]; [data release];  //Retrieving movie  NSData *savedMovieData = [[NSUserDefaults standardUserDefaults] objectForKey:@"MovieObjectDefaultsDataKey"]; if (savedMovieData != nil) {     NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:savedMovieData];     *MovieObject* = [[unarchiver decodeObjectForKey:@"MovieObjectDataKey"] retain];     [unarchiver finishDecoding];     [savedMovieData release];     [unarchiver release]; } else {     //Download Stream of Your Movie } 

The only thing you really have to change there is * MovieObject *, once in each step.

like image 27
Dyldo42 Avatar answered Sep 29 '22 18:09

Dyldo42