Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/122.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios GPUImageMovieWriter和avfiletypempeg4文件类型_Ios_Avfoundation_Gpuimage - Fatal编程技术网

Ios GPUImageMovieWriter和avfiletypempeg4文件类型

Ios GPUImageMovieWriter和avfiletypempeg4文件类型,ios,avfoundation,gpuimage,Ios,Avfoundation,Gpuimage,首先,我要祝贺Brad在GPUImage上的出色工作 我试图对给定的视频文件应用旋转,并获得一个mpeg4(AVFileTypeMPEG4)文件作为输出 执行此操作时,我收到以下消息: *-[AVAssetWriterInput appendSampleBuffer:]当outputSettings不是nil时,输入缓冲区必须为未压缩格式 当使用文件类型设置为AVFileTypeMPEG4的GPUImageMovieWriter的以下init方法时,会出现此问题: - (id)initWithM

首先,我要祝贺Brad在GPUImage上的出色工作

我试图对给定的视频文件应用旋转,并获得一个mpeg4(AVFileTypeMPEG4)文件作为输出

执行此操作时,我收到以下消息:

*-[AVAssetWriterInput appendSampleBuffer:]当outputSettings不是nil时,输入缓冲区必须为未压缩格式

当使用文件类型设置为AVFileTypeMPEG4的GPUImageMovieWriter的以下init方法时,会出现此问题:

- (id)initWithMovieURL:(NSURL *)newMovieURL size:(CGSize)newSize fileType:(NSString *)newFileType outputSettings:(NSMutableDictionary *)outputSettings;
但是,它适用于另一个init方法,该方法实际上生成quicktime电影(默认设置为AVFileTypeQuickTimeMovie)

请告诉我GPUImageWriter从现在起是否能够输出mpeg4电影文件

经过多次调查和尝试,您可以在下面看到我编写的几个代码之一

movieFile = [[GPUImageMovie alloc] initWithURL:inputUrl];
movieFilter = [[GPUImageBrightnessFilter alloc] init];
[movieFilter setInputRotation:videoRotationMode atIndex:0];
[movieFile addTarget:movieFilter];
unlink([[outputUrl path] UTF8String]); // If a file already exists, AVAssetWriter won't let you record new frames, so delete the old movie

NSMutableDictionary *videoSettings = [[NSMutableDictionary alloc] init];;
[videoSettings setObject:AVVideoCodecH264 forKey:AVVideoCodecKey];
[videoSettings setObject:[NSNumber numberWithInteger:width] forKey:AVVideoWidthKey];
[videoSettings setObject:[NSNumber numberWithInteger:height] forKey:AVVideoHeightKey];



AudioChannelLayout channelLayout;
memset(&channelLayout, 0, sizeof(AudioChannelLayout));
channelLayout.mChannelLayoutTag = kAudioChannelLayoutTag_Stereo;

NSDictionary *audioSettings = [NSDictionary dictionaryWithObjectsAndKeys:
                                [ NSNumber numberWithInt: kAudioFormatMPEG4AAC], AVFormatIDKey,
                                [ NSNumber numberWithInt: 2 ], AVNumberOfChannelsKey,
                                [ NSNumber numberWithFloat: 16000.0 ], AVSampleRateKey,
                                [ NSData dataWithBytes:&channelLayout length: sizeof( AudioChannelLayout ) ], AVChannelLayoutKey,
                                [ NSNumber numberWithInt: 32000 ], AVEncoderBitRateKey,
                                nil];



// Will create quicktime file
movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:outputUrl size:CGSizeMake(640.0, 480.0) fileType:AVFileTypeMPEG4 outputSettings:videoSettings];


[movieFilter addTarget:movieWriter];
// Configure this for video from the movie file, where we want to preserve all video frames and audio samples
movieWriter.shouldPassthroughAudio = NO; // default YES
[movieWriter setHasAudioTrack:TRUE audioSettings:audioSettings];
movieFile.audioEncodingTarget = movieWriter;
[movieFile enableSynchronizedEncodingUsingMovieWriter:movieWriter];

[movieWriter setDelegate:self];
[movieWriter startRecording];
[movieFile startProcessing];
提前谢谢


PS:我正在使用iOS6

使用AVFileTypeQuickTimeMovie录制的电影文件确实是符合MPEG4标准的电影。它们包含H.264视频和AAC音频。你为什么不想要这个?你得到的错误实际上是来自AV基金会的一个错误,我还没有花太多时间在电影创作功能上。原因是,生成的视频是针对不同的智能手机类型(Android,黑莓……)。不幸的是,许多智能手机不支持quicktime格式,我不确定仅将扩展名从.mov更改为.mp4是否能像真正的mpeg4文件一样工作。@BradLarson我也有同样的问题,有什么解决方案吗?
movieFile = [[GPUImageMovie alloc] initWithURL:inputUrl];
movieFilter = [[GPUImageBrightnessFilter alloc] init];
[movieFilter setInputRotation:videoRotationMode atIndex:0];
[movieFile addTarget:movieFilter];
unlink([[outputUrl path] UTF8String]); // If a file already exists, AVAssetWriter won't let you record new frames, so delete the old movie

NSMutableDictionary *videoSettings = [[NSMutableDictionary alloc] init];;
[videoSettings setObject:AVVideoCodecH264 forKey:AVVideoCodecKey];
[videoSettings setObject:[NSNumber numberWithInteger:width] forKey:AVVideoWidthKey];
[videoSettings setObject:[NSNumber numberWithInteger:height] forKey:AVVideoHeightKey];



AudioChannelLayout channelLayout;
memset(&channelLayout, 0, sizeof(AudioChannelLayout));
channelLayout.mChannelLayoutTag = kAudioChannelLayoutTag_Stereo;

NSDictionary *audioSettings = [NSDictionary dictionaryWithObjectsAndKeys:
                                [ NSNumber numberWithInt: kAudioFormatMPEG4AAC], AVFormatIDKey,
                                [ NSNumber numberWithInt: 2 ], AVNumberOfChannelsKey,
                                [ NSNumber numberWithFloat: 16000.0 ], AVSampleRateKey,
                                [ NSData dataWithBytes:&channelLayout length: sizeof( AudioChannelLayout ) ], AVChannelLayoutKey,
                                [ NSNumber numberWithInt: 32000 ], AVEncoderBitRateKey,
                                nil];



// Will create quicktime file
movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:outputUrl size:CGSizeMake(640.0, 480.0) fileType:AVFileTypeMPEG4 outputSettings:videoSettings];


[movieFilter addTarget:movieWriter];
// Configure this for video from the movie file, where we want to preserve all video frames and audio samples
movieWriter.shouldPassthroughAudio = NO; // default YES
[movieWriter setHasAudioTrack:TRUE audioSettings:audioSettings];
movieFile.audioEncodingTarget = movieWriter;
[movieFile enableSynchronizedEncodingUsingMovieWriter:movieWriter];

[movieWriter setDelegate:self];
[movieWriter startRecording];
[movieFile startProcessing];