Commit c696910a2c5fc9d2e43f268e75971a7e50e4a14f

Authored by 梁星国
1 parent e7a3775c

提交上传0.1.18

CNLiveUploadManager.podspec
@@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
8 8
9 Pod::Spec.new do |s| 9 Pod::Spec.new do |s|
10 s.name = 'CNLiveUploadManager' 10 s.name = 'CNLiveUploadManager'
11 - s.version = '0.1.17' 11 + s.version = '0.1.18'
12 s.summary = '压缩上传,组件化中加入新参数加入outPath,不在直接取' 12 s.summary = '压缩上传,组件化中加入新参数加入outPath,不在直接取'
13 13
14 # This description is used to generate tags and improve search results. 14 # This description is used to generate tags and improve search results.
CNLiveUploadManager/Classes/CNLiveUploadManager.h
@@ -147,7 +147,7 @@ typedef void (^progressHandlerBlock)(float progress);//进度 @@ -147,7 +147,7 @@ typedef void (^progressHandlerBlock)(float progress);//进度
147 + (PLSFilePreset)presetWithVideoLimitType:(AppPhototLimitType)limitType url:(NSURL *)url dataL:(float)dataL; 147 + (PLSFilePreset)presetWithVideoLimitType:(AppPhototLimitType)limitType url:(NSURL *)url dataL:(float)dataL;
148 148
149 ///根据分辨力设置码率 149 ///根据分辨力设置码率
150 -+ (float)bitrateWithPreset:(PLSFilePreset)perset avAsset:(AVAsset *)avAsset url:(NSURL *)url dataL:(float)dataL; 150 ++ (float)bitrateWithPreset:(PLSFilePreset)perset limitType:(AppPhototLimitType)limitType avAsset:(AVAsset *)avAsset url:(NSURL *)url dataL:(float)dataL;
151 151
152 @end 152 @end
153 153
CNLiveUploadManager/Classes/CNLiveUploadManager.m
@@ -2239,7 +2239,7 @@ static CNLiveUploadManager *_uploadManager; @@ -2239,7 +2239,7 @@ static CNLiveUploadManager *_uploadManager;
2239 shortVideoTranscoder.outputURL = [NSURL fileURLWithPath:editOutputPath]; 2239 shortVideoTranscoder.outputURL = [NSURL fileURLWithPath:editOutputPath];
2240 shortVideoTranscoder.outputFileType = PLSFileTypeMPEG4; 2240 shortVideoTranscoder.outputFileType = PLSFileTypeMPEG4;
2241 shortVideoTranscoder.outputFilePreset = [CNLiveUploadManager presetWithVideoLimitType:limitType url:url dataL:dataL];//分辨率 2241 shortVideoTranscoder.outputFilePreset = [CNLiveUploadManager presetWithVideoLimitType:limitType url:url dataL:dataL];//分辨率
2242 - shortVideoTranscoder.bitrate = [CNLiveUploadManager bitrateWithPreset:shortVideoTranscoder.outputFilePreset avAsset:avAsset url:url dataL:dataL]; 2242 + shortVideoTranscoder.bitrate = [CNLiveUploadManager bitrateWithPreset:shortVideoTranscoder.outputFilePreset limitType:limitType avAsset:avAsset url:url dataL:dataL];
2243 shortVideoTranscoder.timeRange = timeRange; 2243 shortVideoTranscoder.timeRange = timeRange;
2244 shortVideoTranscoder.rotateOrientation = PLSPreviewOrientationPortrait; //视频显示 2244 shortVideoTranscoder.rotateOrientation = PLSPreviewOrientationPortrait; //视频显示
2245 shortVideoTranscoder.videoSelectedRect = CGRectZero; //视频剪裁区域 2245 shortVideoTranscoder.videoSelectedRect = CGRectZero; //视频剪裁区域
@@ -2326,7 +2326,7 @@ static CNLiveUploadManager *_uploadManager; @@ -2326,7 +2326,7 @@ static CNLiveUploadManager *_uploadManager;
2326 shortVideoTranscoder.outputURL = [NSURL fileURLWithPath:editOutputPath]; 2326 shortVideoTranscoder.outputURL = [NSURL fileURLWithPath:editOutputPath];
2327 shortVideoTranscoder.outputFileType = PLSFileTypeMPEG4; 2327 shortVideoTranscoder.outputFileType = PLSFileTypeMPEG4;
2328 shortVideoTranscoder.outputFilePreset = [CNLiveUploadManager presetWithVideoLimitType:limitType url:url dataL:dataL];//分辨率 2328 shortVideoTranscoder.outputFilePreset = [CNLiveUploadManager presetWithVideoLimitType:limitType url:url dataL:dataL];//分辨率
2329 - shortVideoTranscoder.bitrate = [CNLiveUploadManager bitrateWithPreset:shortVideoTranscoder.outputFilePreset avAsset:avAsset url:url dataL:dataL]; 2329 + shortVideoTranscoder.bitrate = [CNLiveUploadManager bitrateWithPreset:shortVideoTranscoder.outputFilePreset limitType:limitType avAsset:avAsset url:url dataL:dataL];
2330 shortVideoTranscoder.timeRange = timeRange; 2330 shortVideoTranscoder.timeRange = timeRange;
2331 shortVideoTranscoder.rotateOrientation = PLSPreviewOrientationPortrait; //视频显示 2331 shortVideoTranscoder.rotateOrientation = PLSPreviewOrientationPortrait; //视频显示
2332 shortVideoTranscoder.videoSelectedRect = CGRectZero; //视频剪裁区域 2332 shortVideoTranscoder.videoSelectedRect = CGRectZero; //视频剪裁区域
@@ -2392,8 +2392,8 @@ static CNLiveUploadManager *_uploadManager; @@ -2392,8 +2392,8 @@ static CNLiveUploadManager *_uploadManager;
2392 } 2392 }
2393 2393
2394 }else if (limitType == AppPhototLimitTypeFriendsCircle) {//朋友圈 2394 }else if (limitType == AppPhototLimitTypeFriendsCircle) {//朋友圈
2395 - if (dataL > kCNUploadSize30MB) {  
2396 - return PLSFilePreset640x480; 2395 + if (dataL > kCNUploadSize100MB) {
  2396 + return PLSFilePreset960x540;
2397 }else { 2397 }else {
2398 return PLSFilePreset960x540; 2398 return PLSFilePreset960x540;
2399 } 2399 }
@@ -2422,7 +2422,7 @@ static CNLiveUploadManager *_uploadManager; @@ -2422,7 +2422,7 @@ static CNLiveUploadManager *_uploadManager;
2422 } 2422 }
2423 2423
2424 ///根据分辨力设置码率 2424 ///根据分辨力设置码率
2425 -+ (float)bitrateWithPreset:(PLSFilePreset)perset avAsset:(AVAsset *)avAsset url:(NSURL *)url dataL:(float)dataL{ 2425 ++ (float)bitrateWithPreset:(PLSFilePreset)perset limitType:(AppPhototLimitType)limitType avAsset:(AVAsset *)avAsset url:(NSURL *)url dataL:(float)dataL{
2426 2426
2427 float bitrate = avAsset.pls_bitrate; 2427 float bitrate = avAsset.pls_bitrate;
2428 2428
@@ -2433,44 +2433,70 @@ static CNLiveUploadManager *_uploadManager; @@ -2433,44 +2433,70 @@ static CNLiveUploadManager *_uploadManager;
2433 }else if (perset == PLSFilePresetHighestQuality) { 2433 }else if (perset == PLSFilePresetHighestQuality) {
2434 return 6000 * 1000; 2434 return 6000 * 1000;
2435 }else { 2435 }else {
2436 - if (dataL > 150*1024*1024) {  
2437 - float scale = (20*1024*1024)/dataL;  
2438 - if (bitrate *scale > 300 * 1000) {  
2439 - return 200 *1000;  
2440 - }else {  
2441 - return bitrate *scale;  
2442 - }  
2443 - }else if (dataL > 50*1024*1024) {  
2444 - float scale = (25*1024*1024)/dataL;  
2445 - if (bitrate *scale > 400 * 1000) {  
2446 - return 400 *1000;  
2447 - }else {  
2448 - return bitrate *scale;  
2449 - } 2436 +
  2437 + if (limitType == AppPhototLimitTypeFriendsCircle) {//朋友圈
2450 2438
2451 - }else if (dataL > 40*1024*1024) {  
2452 - if (bitrate *0.4 > 450 * 1000) {  
2453 - return 450 *1000; 2439 + if (dataL > 150*1024*1024) {
  2440 + float scale = (50*1024*1024)/dataL;
  2441 + if (bitrate *scale > 3000 * 1000) {
  2442 + return 3000 * 1000;
  2443 + }else {
  2444 + return bitrate *scale;
  2445 + }
  2446 + }else if (dataL > 75*1024*1024) {
  2447 +
  2448 + float scale = (60*1024*1024)/dataL;
  2449 + if (bitrate *scale > 5000 * 1000) {
  2450 + return 5000 * 1000;
  2451 + }else {
  2452 + return bitrate *scale;
  2453 + }
2454 }else { 2454 }else {
2455 - return bitrate *0.40; 2455 + return bitrate;
2456 } 2456 }
2457 2457
2458 - }else if (dataL > 30*1024*1024) {  
2459 -  
2460 - if (bitrate *0.60 > 700 * 1000) {  
2461 - return 550 *1000; 2458 + }else {
  2459 + if (dataL > 150*1024*1024) {
  2460 + float scale = (20*1024*1024)/dataL;
  2461 + if (bitrate *scale > 300 * 1000) {
  2462 + return 200 *1000;
  2463 + }else {
  2464 + return bitrate *scale;
  2465 + }
  2466 + }else if (dataL > 50*1024*1024) {
  2467 + float scale = (25*1024*1024)/dataL;
  2468 + if (bitrate *scale > 400 * 1000) {
  2469 + return 400 *1000;
  2470 + }else {
  2471 + return bitrate *scale;
  2472 + }
  2473 +
  2474 + }else if (dataL > 40*1024*1024) {
  2475 + if (bitrate *0.4 > 450 * 1000) {
  2476 + return 450 *1000;
  2477 + }else {
  2478 + return bitrate *0.40;
  2479 + }
  2480 +
  2481 + }else if (dataL > 30*1024*1024) {
  2482 +
  2483 + if (bitrate *0.60 > 700 * 1000) {
  2484 + return 550 *1000;
  2485 + }else {
  2486 + return bitrate *0.60;
  2487 + }
  2488 + }else if (dataL > 20*1024*1024) {
  2489 +
  2490 + return bitrate *0.80;
  2491 + }else if (dataL > 10*1024*1024) {
  2492 +
  2493 + return bitrate *0.9;
2462 }else { 2494 }else {
2463 - return bitrate *0.60; 2495 + return bitrate;
2464 } 2496 }
2465 - }else if (dataL > 20*1024*1024) {  
2466 2497
2467 - return bitrate *0.80;  
2468 - }else if (dataL > 10*1024*1024) {  
2469 -  
2470 - return bitrate *0.9;  
2471 - }else {  
2472 - return bitrate;  
2473 } 2498 }
  2499 +
2474 } 2500 }
2475 2501
2476 } 2502 }