欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

iOS如何實(shí)現(xiàn)視頻壓縮上傳功能

小編給大家分享一下iOS如何實(shí)現(xiàn)視頻壓縮上傳功能,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

創(chuàng)新互聯(lián)是一家集網(wǎng)站建設(shè),鄢陵企業(yè)網(wǎng)站建設(shè),鄢陵品牌網(wǎng)站建設(shè),網(wǎng)站定制,鄢陵網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營(yíng)銷,網(wǎng)絡(luò)優(yōu)化,鄢陵網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競(jìng)爭(zhēng)力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長(zhǎng)自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。

代碼如下:

- (void)convertVideoWithURL:(NSURL *)url
{
  NSDate *date = [NSDate date];
  NSDateFormatter *dateformatter = [[NSDateFormatter alloc]init];
  [dateformatter setDateFormat:@"YYYY-MM-dd-HH-mm-ss"];
  NSString *dateName = [dateformatter stringFromDate:date];
  NSString *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject;
  NSString *pathName = [path stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.mp4",dateName]];
  NSLog(@"沙盒:%@",pathName);
  //轉(zhuǎn)碼配置
  AVURLAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil];
  AVAssetExportSession *exportSession= [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetMediumQuality];
  exportSession.shouldOptimizeForNetworkUse = YES;
  exportSession.outputURL = [NSURL fileURLWithPath:pathName];
  exportSession.outputFileType = AVFileTypeMPEG4;
  [exportSession exportAsynchronouslyWithCompletionHandler:^{
    int exportStatus = exportSession.status;
    switch (exportStatus)     {
      case AVAssetExportSessionStatusFailed:
      {
        // log error to text view
        NSError *exportError = exportSession.error;
        NSLog (@"AVAssetExportSessionStatusFailed: %@", exportError);
        [SVProgressHUD showErrorWithStatus:@"視頻壓縮失敗"];
        [SVProgressHUD dismissWithDelay:1.0];
        break;
      }
      case AVAssetExportSessionStatusCompleted:
      {
        self.videoData = [NSData dataWithContentsOfFile:pathName];

        [[NetTool shareDL]upLoadVideoWithURL:@"http://192.168.1.102/php/image.php" paremeter:nil data:self.videoData videoName:[NSString stringWithFormat:@"%@.mp4",dateName] progress:^(NSProgress * _Nonnull uploadProgress) {

          [SVProgressHUD showProgress:1.0*uploadProgress.completedUnitCount/uploadProgress.totalUnitCount status:@"正在上傳"];
          NSLog(@"正在上傳%f%%",(1.0*uploadProgress.completedUnitCount/uploadProgress.totalUnitCount)*100);

        } success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
          [SVProgressHUD showSuccessWithStatus:@"上傳成功"];
          [SVProgressHUD dismissWithDelay:1.0];
        } fail:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
          [SVProgressHUD showErrorWithStatus:@"上傳失敗"];
          [SVProgressHUD dismissWithDelay:1.0];
        }];

      }
    }
  }];
}
[manager POST:url parameters:parameter constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) {
    [formData appendPartWithFileData:videoData name:@"upimage" fileName:videoName mimeType:@"video/mp4"];
  } progress:^(NSProgress * _Nonnull uploadProgress) {
    progress(uploadProgress);
  } success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
    success(task,responseObject);
  } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
    fail(task,error);
  }];

以上是“iOS如何實(shí)現(xiàn)視頻壓縮上傳功能”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

網(wǎng)站標(biāo)題:iOS如何實(shí)現(xiàn)視頻壓縮上傳功能
網(wǎng)站地址:http://chinadenli.net/article6/gidpig.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供靜態(tài)網(wǎng)站做網(wǎng)站、手機(jī)網(wǎng)站建設(shè)、定制開(kāi)發(fā)響應(yīng)式網(wǎng)站用戶體驗(yàn)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

手機(jī)網(wǎng)站建設(shè)