0

我目前rtmpdump在我的 iOS 应用程序中用作 C 程序。但是,我似乎不能多次使用它而不必重新启动应用程序。这可能是什么原因,我该如何解决?

相关代码:

NSDictionary *details = [args objectAtIndex:0]; //rtmpe deatils
NSString *flvStore = [args objectAtIndex:1];
NSString *mp4Store = [args objectAtIndex:2];
[self performSelectorOnMainThread:@selector(updateProgressBar:) withObject:flvPath waitUntilDone:NO];
[self getFlashFile:details withFlvPathName:flvStore];

NSFileManager *fileManager = [NSFileManager defaultManager];
if([fileManager fileExistsAtPath:flvPath]){
    NSNumber *filesize = 0;
    NSDictionary *fileAttributes = [[NSFileManager defaultManager] fileAttributesAtPath:flvPath traverseLink:NO];
    if(fileAttributes != nil){
        filesize = [fileAttributes objectForKey:NSFileSize];
    }

    if([filesize longLongValue] > 1024){
        [self removeFlvWrapper:flvPath withMp4PathName:mp4Path andTitle:[thePid objectForKey:@"title"]];
    }
    [fileManager removeItemAtPath:flvPath error:NULL];
}

- (void)getFlashFile:(NSDictionary *)details withFlvPathName:(NSString *)flvPath {
static char **rt_argv;
static int    rt_argc;

rt_argc = 16;
rt_argv = (char **)malloc(sizeof(char *) * (rt_argc));
rt_argv[0] = "rtmpdump";
rt_argv[1] = (char *)[@"-r" UTF8String];
rt_argv[2] = (char *)[[details objectForKey:@"r"] UTF8String];
rt_argv[3] = (char *)[@"-a" UTF8String];
rt_argv[4] = (char *)[[details objectForKey:@"a"] UTF8String];
rt_argv[5] = (char *)[@"-f" UTF8String];
rt_argv[6] = (char *)[@"WIN 10,0,32,18" UTF8String];
rt_argv[7] = (char *)[@"-W" UTF8String];
rt_argv[8] = (char *)[[details objectForKey:@"W"] UTF8String];
rt_argv[9] = (char *)[@"-p" UTF8String];
rt_argv[10] = (char *)[[details objectForKey:@"p"] UTF8String];
rt_argv[11] = (char *)[@"-y" UTF8String];
rt_argv[12] = (char *)[[details objectForKey:@"y"] UTF8String];
rt_argv[13] = (char *)[@"-o" UTF8String];
rt_argv[14] = (char *)[flvPath UTF8String];
rt_argv[15] = (char *)[@"-q" UTF8String];

getStream(rt_argc, rt_argv);
finished = true;
}

您还可以查看iPlayerFetch.m 下的 BigBadOwl 存储库以查看类似代码。

4

1 回答 1

0

我最终在 Objective-C 中创建了 rtmpdump 的替代方案。该代码使用 librtmp 而不是 rtmpdump,但灵感来自 rtmpdump。

谢谢!

于 2013-02-17T22:56:19.260 回答