亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用AVAsset制作帶有圖片數組和歌曲文件的電影文件

使用AVAsset制作帶有圖片數組和歌曲文件的電影文件

iOS
一只斗牛犬 2019-12-10 13:08:03
我正在嘗試使用圖片數組和音頻文件制作電影文件。為了制作帶有圖片陣列的電影,我在這里用了祖爾的大貼子。一切都太完美了,我的電影里有我的照片。但是,當我嘗試添加一些音軌時,會有很多問題。為了理解我把我的代碼:當我調用此方法時,圖片數組和歌曲文件已準備就緒:-(void) writeImagesToMovieAtPath:(NSString *) path withSize:(CGSize) size{    NSString *documentsDirectoryPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];    NSArray *dirContents = [[NSFileManager defaultManager] directoryContentsAtPath:documentsDirectoryPath];    for (NSString *tString in dirContents) {        if ([tString isEqualToString:@"essai.mp4"])         {            [[NSFileManager defaultManager]removeItemAtPath:[NSString stringWithFormat:@"%@/%@",documentsDirectoryPath,tString] error:nil];        }    }    NSLog(@"Write Started");    NSError *error = nil;    AVAssetWriter *videoWriter = [[AVAssetWriter alloc] initWithURL:                                  [NSURL fileURLWithPath:path] fileType:AVFileTypeMPEG4                                                              error:&error];        NSParameterAssert(videoWriter);    NSDictionary *videoSettings = [NSDictionary dictionaryWithObjectsAndKeys:                                   AVVideoCodecH264, AVVideoCodecKey,                                   [NSNumber numberWithInt:size.width], AVVideoWidthKey,                                   [NSNumber numberWithInt:size.height], AVVideoHeightKey,                                   nil];    AudioChannelLayout channelLayout;    memset(&channelLayout, 0, sizeof(AudioChannelLayout));    channelLayout.mChannelLayoutTag = kAudioChannelLayoutTag_Stereo;音頻文件的AssetWriterInput的狀態始終為“ NO”。我的問題:如何使用AVFoundation將音頻添加到視頻文件?因此,請有人告訴我是否忘記某事或某事有誤,可以幫助我。非常感謝你
查看完整描述

3 回答

?
陪伴而非守候

TA貢獻1757條經驗 獲得超8個贊

AVChannelLayoutKey應該指向一個包含AudioChannelLayout的NSData實例。

您指向一個NSNumber。


查看完整回答
反對 回復 2019-12-11
  • 3 回答
  • 0 關注
  • 572 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號