15321250321
              010-86462584

              APP開發 > APP學院 > 解決方案

              短視頻app開發,北京制作短視頻app專業技術流程

              2023-07-24

              短視頻app開發最關鍵的步驟是分為三個步驟,我將教你把每個動作點一層一層地保持在這三個步驟下,動作點API可以根據需要啟用:
              短視頻app開發

              一、短視頻app開發錄像功能:

              a.創業
              B.拍攝的音樂背景
              C.剛開始
              D.添加美麗
              e.加ps過濾器
              F.添加面紙
              G.按段加速執行
              h.完成
              二、短視頻app視頻剪輯
              a.一開始就編寫
              b.增加音樂背景
              c.增加案文效果
              D.增加地震的特殊影響
               

              2.1 APP啟動拍攝

              首先包含七牛短視頻 SDK 頭文件 PLShortVideoKit.h :

               #import <PLShortVideoKit/PLShortVideoKit.h>
              

              然后添加一個 PLShortVideoRecorder 屬性:

               @property (nonatomic,strong) PLShortVideoRecorder *shortVideoRecorder;
              

              創建音視頻的采集和編碼配置對象,這里我們使用默認配置,開發者可以根據自己的需求修改配置:

               PLSVideoConfiguration *videoConfiguration = [PLSVideoConfiguration defaultConfiguration];
               
               PLSAudioConfiguration *audioConfiguration = [PLSAudioConfiguration defaultConfiguration];
              

              創建拍攝 shortVideoRecorder 對象:

               self.shortVideoRecorder = [[PLShortVideoRecorder alloc] initWithVideoConfiguration:videoConfiguration audioConfiguration:audioConfiguration];
               self.shortVideoRecorder.delegate = self;
              

              添加攝像頭預覽視圖:

               [self.view addSubview:self.shortVideoRecorder.previewView];
              

              至此,基本配置完成,我們可以啟動攝像頭預覽:

               [self.shortVideoRecorder startCaptureSession];
              

              2.2 APP給拍攝添加背景音樂

              在開始錄制之前,我們可以添加背景音樂:

               NSURL *audioURL = [NSURL fileURLWithString:@"PATH TO AUDIO"];
               [self.shortVideoRecorder mixAudio:audioURL];
              

              背景音樂只能在開始錄制之前添加,一旦錄制開始了,不能再添加,此時只有刪除已經錄制的視頻文件,才能添加背景音樂。

              2.3 APP開始拍攝

              錄制的視頻存放路徑由 SDK 內部自動生成:

               [self.shortVideoRecorder startRecording];
              

              開發者也可以自己傳入錄制的視頻存放路徑:

               [self.shortVideoRecorder startRecording:customFileURL];
              

              2.4 APP添加美顏

              七牛短視頻 SDK 提供了美顏功能,開發者只需要一個簡單的參數設置即可以打開美顏功能:

               [self.shortVideoRecorder setBeautifyModeOn:YES];
              

              2.5 APP添加濾鏡

              七牛短視頻 SDK 內部提供了 30 多種濾鏡格式,開發者使用濾鏡需要在工程中包含 PLShortVideoKit.bundle,這里面存放了濾鏡的圖片資源,開發者還可以添加自己的濾鏡圖片。

              初始化濾鏡:

              // 初始化濾鏡
               self.filter = [[PLSFilter alloc] init];
              // 設置濾鏡色彩圖片路徑
               NSString *bundlePath = [NSBundle mainBundle].bundlePath;
               NSString *colorImagePath = [bundlePath stringByAppendingString:@"/PLShortVideoKit.bundle/colorFilter/candy/filter.png"];
               self.filter.colorImagePath = colorImagePath;
              

              在短視頻數據回調方法中,我們可以用上面初始化好的濾鏡:

               - (CVPixelBufferRef)shortVideoRecorder:(PLShortVideoRecorder *)recorder cameraSourceDidGetPixelBuffer:(CVPixelBufferRef)pixelBuffer {
               // 進行濾鏡處理
               pixelBuffer = [self.filter process:pixelBuffer];
               
               return pixelBuffer;
               }
              

              2.6 短視頻app添加人臉貼紙

              七牛短視頻 SDK 沒有提供人臉識別的貼紙功能,但是我們 SDK 能很容易的接入友商的貼紙功能,我們以添加 涂圖 的貼紙舉例說明

              包含涂圖的頭文件:

               #import <TuSDKVideo/TuSDKVideo.h>
               #import "StickerScrollView.h"
              

              增加貼紙添加器和貼紙選擇 view:

               @property (nonatomic, strong) TuSDKFilterProcessor *filterProcessor;
               @property (nonatomic, strong) StickerScrollView *stickerView;
              

              初始化貼紙添加的實例:

               self.filterProcessor = [[TuSDKFilterProcessor alloc] initWithFormatType:kCVPixelFormatType_32BGRA isOriginalOrientation:NO];
               self.filterProcessor.outputPixelFormatType = lsqFormatTypeBGRA;
               // TuSDKFilterProcessor 默認不啟用貼紙,這里需要主動啟用貼紙功能
               [self.filterProcessor setEnableLiveSticker:YES];
               self.stickerView = [[StickerScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 300)];
               self.stickerView.stickerDelegate = self;
               self.stickerView.cameraStickerType = lsqCameraStickersTypeSquare;
              

              選擇貼紙。在貼紙選擇的回調,處理貼紙:

               (void)clickStickerViewWith:(TuSDKPFStickerGroup *)stickGroup {
               if (!stickGroup) {
               // 為nil時 移除已有貼紙組;
               [_filterProcessor removeMediaEffectsWithType:TuSDKMediaEffectDataTypeSticker];
               } else {
               // 選中了某個貼紙,將其添加到 filterProcessor 中
               [self.filterProcessor showGroupSticker:stickGroup]; 
               }
               }
              

              貼紙選擇完成之后,我們可以將貼紙應用到視頻錄制中。和濾鏡處理類似,在短視頻拍攝的視頻數據回調中,應用貼紙:

               - (CVPixelBufferRef)shortVideoRecorder:(PLShortVideoRecorder *)recorder cameraSourceDidGetPixelBuffer:(CVPixelBufferRef)pixelBuffer {
               // 進行濾鏡處理
               pixelBuffer = [self.filter process:pixelBuffer];
               
               // TuSDK 進行貼紙處理
               pixelBuffer = [self.filterProcessor syncProcessPixelBuffer:pixelBuffer];
               [self.filterProcessor destroyFrameData];
               
               return pixelBuffer;
               }
              

              2.7 短視頻app分段變速拍攝

              如果想拍攝的視頻以快速或者慢速播放,可以設置拍攝速率:

               self.shortVideoRecorder.recoderRate = PLSVideoRecoderRateTopFast;
              

              2.8 短視頻app結束拍攝

              如果要結束某一段視頻的錄制,可以調用停止錄制方法:

               [self.shortVideoRecorder stopRecording];
              

              調用停止錄制之后,保存的視頻會通過錄制完成回調返回出來:

               - (void)shortVideoRecorder:(PLShortVideoRecorder *)recorder didFinishRecordingToOutputFileAtURL:(NSURL *)fileURL fileDuration:(CGFloat)fileDuration totalDuration:(CGFloat)totalDuration {
               
               }
              

              停止音視頻采集。如果不再需要拍攝視頻,可以調用停止采集方法來結束拍攝:

               [self.shortVideoRecorder stopCaptureSession];
              

               視頻編輯

              3.1 短視頻app開始編輯

              編輯類 PLShortVideoEditor 支持渲染音視頻、水印、濾鏡、背景音樂、MV 特效等功能

              初始化和啟動編輯:

               self.shortVideoEditor = [[PLShortVideoEditor alloc] initWithAsset:asset videoSize:CGSizeZero];
               self.shortVideoEditor.delegate = self;
               self.shortVideoEditor.loopEnabled = YES;
               [self.view addSubview:self.shortVideoEditor.preview];
               
               [self.shortVideoEditor startEditing];
              

              3.2 短視頻app添加背景音樂

              添加背景音樂

               [self.shortVideoEditor addMusic:musicURL timeRange:timeRange volume:1.0];
              

              調節背景音樂音量

               [self.shortVideoEditor updateMusic:timeRange volume:0.5];
              

              3.3 短視頻app添加文字特效

              添加文字的邏輯和添加貼紙使用的是同一個邏輯,用戶可以使用七牛短視頻 Demo 中已經包裝好的添加文字、貼紙的類 PLSStickerView:

               PLSStickerView *stickerView = [[PLSStickerView alloc] initWithFrame:CGRectMake(0, 0, 200, 50)]; 
               
               // 以字典的形式,保存 stickerView 信息
               NSMutableDictionary *stickerSettings = [[NSMutableDictionary alloc] init];
               stickerSettings[PLSStickerKey] = stickerView;
               stickerSettings[PLSSizeKey] = [NSValue valueWithCGSize:viewSize];
               stickerSettings[PLSPointKey] = [NSValue valueWithCGPoint:viewPoint];
               CGFloat rotation = atan2f(transform.b, transform.a);
               rotation = rotation * (180 / M_PI);
               stickerSettings[PLSRotationKey] = [NSNumber numberWithFloat:rotation];
               
               [self.stickerSettingsArray addObject:stickerSettings];
              

              3.4 短視頻app添加抖音特效

              七牛短視頻 SDK 沒有集成特效,但是和人臉貼紙一樣,可以輕松的接入第三方的特效。下面我們還以添加 涂圖 的特效為例,演示特效的添加方式

              首先,初始化特效添加器:

               self.filterProcessor = [[TuSDKFilterProcessor alloc] initWithFormatType:kCVPixelFormatType_32BGRA isOriginalOrientation:isOriginalOrientation];
               self.filterProcessor.delegate = self;
               self.filterProcessor.mediaEffectDelegate = self;
               // 默認關閉動態貼紙功能,即關閉人臉識別功能
               self.filterProcessor.enableLiveSticker = NO;
              

              添加靈魂出竅特效:

              TuSDKMediaSceneEffectData *effectData = [[TuSDKMediaSceneEffectData alloc] initWithEffectsCode:@"LiveSoulOut01"];
              effectData.atTimeRange = [TuSDKTimeRange makeTimeRangeWithStart:kCMTimeZero end:CMTimeMake(INTMAX_MAX, 1)];
              [self.filterProcessor addMediaEffect:effectData];
              

              應用特效。在短視頻編輯視頻數據回調里面,將特效應用,以便預覽特效效果:

               - (CVPixelBufferRef)shortVideoEditor:(PLShortVideoEditor *)editor didGetOriginPixelBuffer:(CVPixelBufferRef)pixelBuffer timestamp:(CMTime)timestamp {
               // 應用特效
               pixelBuffer = [self.filterProcessor syncProcessPixelBuffer:pixelBuffer frameTime:timestamp];
               [self.filterProcessor destroyFrameData];
               
               return pixelBuffer;
               }
              

              視頻導出

              上面我們的短視頻編輯就完成了,現在我們將編輯的視頻使用 PLSAVAssetExportSession

              導出來保存到本地相冊

              初始化視頻導出器:

               NSMutableDictionary *outputSettings = [[NSMutableDictionary alloc] init];
               NSMutableDictionary *movieSettings = [[NSMutableDictionary alloc] init];
               NSMutableDictionary *backgroundAudioSettings = [NSMutableDictionary alloc] init];
               NSMutableArray *stickerSettingsArray = [[NSMutableArray alloc] init];
               NSMutableArray *audioSettingsArray = [[NSMutableArray alloc] init];
               
               // 將導出信息設置到 outputSettings 中
               // do setting...
               
               AVAsset *asset = movieSettings[PLSAssetKey];
               PLSAVAssetExportSession *exportSession = [[PLSAVAssetExportSession alloc] initWithAsset:asset];
               exportSession.outputFileType = PLSFileTypeMPEG4;
               exportSession.shouldOptimizeForNetworkUse = YES;
               exportSession.outputSettings = self.outputSettings;
               exportSession.delegate = self;
               exportSession.isExportMovieToPhotosAlbum = YES;
              

              設置導出視頻相關 block:

               __weak typeof(self) weakSelf = self;
               
               [exportSession setCompletionBlock:^(NSURL *url) {
               NSLog(@"視頻已保存到相冊中");
               }];
               
               [exportSession setFailureBlock:^(NSError *error) {
               NSLog(@"導出視頻失敗");
               }];
               
               [exportSession setProcessingBlock:^(float progress) {
               NSLog(@"視頻導出完成百分比: %f", process);
               }];
              

              實現 PLSAVAssetExportSessionDelegate 的視頻數據回調方法,進行特效處理:

               - (CVPixelBufferRef)assetExportSession:(PLSAVAssetExportSession *)assetExportSession didOutputPixelBuffer:(CVPixelBufferRef)pixelBuffer timestamp:(CMTime)timestamp {
               
               // 特效處理 
               pixelBuffer = [self.filterProcessor syncProcessPixelBuffer:pixelBuffer frameTime:timestamp];
               [self.filterProcessor destroyFrameData];
               
               return pixelBuffer;
               }
              

               總結

              短視頻app開發,北京短視頻app制作專業技術流程,掌握以上短視頻app技術開發要點,開發一個優秀的短視頻app絕對沒有問題。短視頻直播帶貨app開發,2020年4月,非常流行短視頻帶貨直播電商app市場火爆,非常值得進入的短視頻朝陽產業。

              客服QQ:121446412 聯系電話:15321250321

              京ICP備17026149號-1

              版權所有@2011-2022 北京天品互聯科技有限公司 公司地址:北京市海淀區上地信息路甲28號B座(二層)02D室-010號

              主站蜘蛛池模板: 亚洲一区精彩视频| 91一区二区三区四区五区| 国产福利一区二区三区在线观看| 中文乱码人妻系列一区二区| 无码少妇一区二区| 亚洲免费视频一区二区三区| 人妻体内射精一区二区三区| 国产一区二区免费视频| 日本人真淫视频一区二区三区 | 成人一区专区在线观看| 亚洲国产成人一区二区三区| 精品理论片一区二区三区| 一区二区传媒有限公司| 亚洲视频一区二区在线观看| 少妇激情av一区二区| 国产亚洲一区二区三区在线| AV天堂午夜精品一区| 好吊视频一区二区三区| 久久国产精品免费一区| 亚洲av成人一区二区三区在线观看 | 国产av熟女一区二区三区| 一区免费在线观看| 内射白浆一区二区在线观看 | 夜夜精品视频一区二区| 无码中文字幕人妻在线一区二区三区| 91精品一区二区三区久久久久 | 亚洲av无码片区一区二区三区| 国产一区二区精品久久| 无码人妻少妇色欲AV一区二区| 国产丝袜视频一区二区三区| 国产精品无圣光一区二区| 一区二区三区人妻无码| 国产激情з∠视频一区二区 | 日韩高清一区二区三区不卡| 精品免费国产一区二区三区| 视频在线一区二区| 日韩综合无码一区二区| 精品一区二区三区四区在线播放| 一区二区无码免费视频网站| 国产午夜精品一区二区三区极品| 国产精品一区二区AV麻豆 |
              收縮
              • 15321250321