-
Notifications
You must be signed in to change notification settings - Fork 42
Open
Description
I am trying to get get the data of video from the photo library. I am using following code:-
{
videoArray = [self getContentFrom:group withAssetFilter:[ALAssetsFilter allVideos]];
if (videoArray.count) {
ALAssetRepresentation *rep = [videoArray lastObject];
Byte *buffer = (Byte *)malloc(rep.size);
NSUInteger buffered = [rep getBytes:buffer fromOffset:0.0 length:rep.size error:nil];
NSData *data = [NSData dataWithBytesNoCopy:buffer length:buffered freeWhenDone:YES];
RtmpWrapper *rtmp = [[RtmpWrapper alloc] init];
BOOL ret = [rtmp openWithURL:@"rtmp://173.224.117.133:1935/oflaDemo/1" enableWrite:YES];
if (ret) {
NSData *video =
data;
NSLog(@"original video length: %d", [video length]);
NSUInteger length = [video length];
NSUInteger chunkSize = 20 * 5120;
NSUInteger offset = 0;
// Let's split video to small chunks to publish to media server
do {
NSUInteger thisChunkSize = length - offset > chunkSize ? chunkSize : length - offset;
NSData *chunk = [NSData dataWithBytesNoCopy:(char *)[video bytes] + offset
length:thisChunkSize
freeWhenDone:NO];
offset += thisChunkSize;
// Write new chunk to rtmp server
[rtmp write:chunk withCompletion: ^(NSUInteger sent, NSError *error) {
NSLog(@"sent -> %d", sent);
if (error) {
NSLog(@"error -> %@", [error description]);
}
}];
sleep(1);
}
while (offset < length);
}
// Close rtmp connection and release class object
[rtmp close];
}
}
It is not displaying video on website. Any reason what I am doing wrong?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels