MOV_TO_MP4

简介: MOV_TO_MP4
-(void)MovToMp4
{
    AVURLAsset *avAsset = [AVURLAsset URLAssetWithURL:[NSURL fileURLWithPath:screenFilePath] options:nil];
    NSArray *compatiblePresets = [AVAssetExportSession exportPresetsCompatibleWithAsset:avAsset];
    if ([compatiblePresets containsObject:AVAssetExportPresetLowQuality])
    {
        AVAssetExportSession *exportSession = [[AVAssetExportSession alloc]initWithAsset:avAsset presetName:AVAssetExportPresetHighestQuality];
        NSDateFormatter* formater = [[NSDateFormatter alloc] init];
        [formater setDateFormat:@"yyyyMMddHHmmss"];
        NSString *_mp4Path = [[NSHomeDirectory() stringByAppendingFormat:@"/Documents/%@.mp4", [formater stringFromDate:[NSDate date]]] retain];
        [formater release];
        exportSession.outputURL = [NSURL fileURLWithPath:_mp4Path];
        exportSession.outputFileType = AVFileTypeMPEG4;
        CMTime start = CMTimeMakeWithSeconds(1.0, 600);
        CMTime duration = CMTimeMakeWithSeconds(3.0, 600);
        CMTimeRange range = CMTimeRangeMake(start, duration);
        exportSession.timeRange = range;
        [exportSession exportAsynchronouslyWithCompletionHandler:^{
            switch ([exportSession status]) {
                case AVAssetExportSessionStatusFailed:
                    NSLog(@"Export failed: %@", [[exportSession error] localizedDescription]);
                    break;
                case AVAssetExportSessionStatusCancelled:
                    NSLog(@"Export canceled");
                    break;
                case AVAssetExportSessionStatusCompleted:
                {
                    NSLog(@"开始上传屏幕快照");
                  [g_api UpdateScreen:_mp4Path];   
                }
                    break;
                default:
                    break;
            }
            [exportSession release];
        }];
    }
}
相关文章
|
10月前
|
存储 编解码 iOS开发
视频文件格式:MOV与MP4格式的区别是什么?
视频文件有多种格式,很多人在下载时不知道该选择哪种文件格式。不同格式有不同特点,各自有优缺点。本文将详细介绍常见的MOV和MP4的特点与区别,以供读者了解及选择。
1223 2
视频文件格式:MOV与MP4格式的区别是什么?
|
23天前
|
JavaScript
汇编指令学习(JMP、JE、JS、JP,JO,JB)
汇编指令学习(JMP、JE、JS、JP,JO,JB)
226 0
|
23天前
|
索引 存储 C语言
【汇编】[bx+idata]的寻址方式、SI和DI寄存器
【汇编】[bx+idata]的寻址方式、SI和DI寄存器
113 0
【汇编】[bx+idata]的寻址方式、SI和DI寄存器
成功解决smtplib.SMTPAuthenticationError: (535, b'Error: \xc7\xeb\xca\xb9\xd3\xc3\xca\xda\xc8\xa8\xc2\xeb
成功解决smtplib.SMTPAuthenticationError: (535, b'Error: \xc7\xeb\xca\xb9\xd3\xc3\xca\xda\xc8\xa8\xc2\xeb
|
存储 编解码 JSON
MP4封装格式
MP4封装格式介绍及解释,本文介绍 mp4 里面各种 box 的作用,包括 mdat box, moov box,mdhd box 等等。
337 0
|
SQL XML 前端开发
数据持久化技术——MP(二)
数据持久化技术——MP(二)
196 0
数据持久化技术——MP(二)
数据持久化技术——MP(三)
数据持久化技术——MP(三)
117 0
|
druid 前端开发 Java
数据持久化技术——MP(一)
数据持久化技术——MP(一)
273 0
数据持久化技术——MP(一)
XC6SLX9-2TQG144C
赛灵思的XC6SLX9-2TQG144C是Spartan-6系列的现场可编程门阵列
157 0
CB2201 ADC应用指南
介绍CB2201开发板的ADC外设使用
CB2201 ADC应用指南

热门文章

最新文章