【问题标题】:Recording and saving photo/video without it being added to Camera Roll在不添加到相机胶卷的情况下录制和保存照片/视频
【发布时间】:2012-11-10 22:47:58
【问题描述】:

我想录制视频,但不让它显示在照片/视频应用、相机胶卷或其他相册中。

使用 Apple 提供的 AVCam 演示应用程序,我正在尝试将录制的视频保存到应用程序自己的 Document 目录中。这工作正常,但保存的视频也注册在相机胶卷/相册中,这是我不想要的。

我尝试将文件扩展名从 .mov 更改为随机的,并且视频确实以未知扩展名保存在正确的位置,实际上它并没有被添加到相机胶卷中,而是在保存对话后立即添加框显示给用户:

无效数据 - 写入资产时出现问题,因为数据 无效,无法查看或播放。

有些应用似乎可以保存到它们自己的 Documents 目录,而不会将拍摄的照片/视频添加到相机胶卷中,即 ReconBot。

所以我的问题是:如何将图片或视频保存到应用的 Documents 目录中而不显示在照片/视频应用中(没有前面提到的对话)?

【问题讨论】:

    标签: iphone ios avfoundation avcam


    【解决方案1】:

    在 AvCam 示例应用程序中,Classes/AVCamCaptureManager.m 的最后是在录制视频后存储视频的例程。只需删除将其存储到相机胶卷的代码,并将复制它的现有代码保留到文档目录:

    -(void)recorder:(AVCamRecorder *)recorder recordingDidFinishToOutputFileURL:(NSURL *)outputFileURL error:(NSError *)error
    {
        // Save it in the app's Documents directory, whence it can be copied from the device via
        // iTunes file sharing.
        [self copyFileToDocuments:outputFileURL];
    
        if ([[UIDevice currentDevice] isMultitaskingSupported]) {
            [[UIApplication sharedApplication] endBackgroundTask:[self backgroundRecordingID]];
        }       
    
        if ([[self delegate] respondsToSelector:@selector(captureManagerRecordingFinished:)]) {
            [[self delegate] captureManagerRecordingFinished:self];
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-05
      • 2018-05-09
      • 2012-07-22
      • 2013-06-27
      • 2015-09-25
      • 2012-05-01
      • 2013-04-03
      • 2016-05-01
      相关资源
      最近更新 更多