Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using video data from photo gallary #2

Open
trident10 opened this issue Oct 13, 2014 · 1 comment
Open

Using video data from photo gallary #2

trident10 opened this issue Oct 13, 2014 · 1 comment

Comments

@trident10
Copy link

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?

@minsikzzang
Copy link
Owner

This RTMP wrapper only transfer FLV data not mp4, Probably the video in your photo gallery in MP4 format.

In this case, you might have a look https://github.com/ifactorylab/IFVideoPicker, I will do huge update for IFVideoPicker / RTMPWrapper soon.

Hopefully it helps you out.

Thanks
Min

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants