FFMPEG for iPhone 录制视频编码
您好,发现了很多很多通过 ffmpeg 进行视频编码的链接1,2,3,4 等,但它们都是从使用终端命令开始的,但是当我尝试实现任何终端如:
git clone git://github.com/lajos/iFrameExtractor.git
它说
-bash:git:找不到命令。
另外据我所知,不可能在 iPhone 上使用终端命令。任何人都可以指出如何对通过 ffmpeg 录制的视频进行 mp4
格式的编码,并减少视频的大小?提前致谢。
编辑: 我已经实现了这种方法来调整我的视频大小,并且它成功发生,我能够在服务器上发送视频,但随后在服务器端它在检索数据和使用它时出现问题。
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[self convertVideoToLowQuailtyWithInputURL:videoURL1 outputURL:[NSURL fileURLWithPath:videoStoragePath] handler:^(AVAssetExportSession *exportSession)
{
if (exportSession.status == AVAssetExportSessionStatusCompleted)
{
NSLog(@"%@",exportSession.error);
printf("completed\n");
}
else
{
NSLog(@"%@",exportSession.error);
printf("error\n");
}
}];
}
- (void)convertVideoToLowQuailtyWithInputURL:(NSURL*)inputURL
outputURL:(NSURL*)outputURL
handler:(void (^)(AVAssetExportSession*))handler
{
[[NSFileManager defaultManager] removeItemAtURL:outputURL error:nil];
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:inputURL options:nil];
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetLowQuality];
exportSession.outputURL = outputURL;
exportSession.outputFileType = AVFileTypeQuickTimeMovie;
[exportSession exportAsynchronouslyWithCompletionHandler:^(void)
{
handler(exportSession);
[exportSession release];
}];
}
Hi found lots and lots of links for video encoding through ffmpeg 1,2,3,4 etc but they all start with using terminal commands but when i try to implement any on terminal like:
git clone git://github.com/lajos/iFrameExtractor.git
it says that
-bash: git: command not found.
Also as per my knowledge it is not possible to use terminal command on iPhone. Can anybody point out how to encode a video recorded through ffmpeg in mp4
format and also to reduce the size of the video?Thanks in advance.
EDIT:
I am already implementing this method to resize my video and it successfully takes place and I am able to send the video on server but then on server side it's giving problem in retrieving the data and to use it.
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[self convertVideoToLowQuailtyWithInputURL:videoURL1 outputURL:[NSURL fileURLWithPath:videoStoragePath] handler:^(AVAssetExportSession *exportSession)
{
if (exportSession.status == AVAssetExportSessionStatusCompleted)
{
NSLog(@"%@",exportSession.error);
printf("completed\n");
}
else
{
NSLog(@"%@",exportSession.error);
printf("error\n");
}
}];
}
- (void)convertVideoToLowQuailtyWithInputURL:(NSURL*)inputURL
outputURL:(NSURL*)outputURL
handler:(void (^)(AVAssetExportSession*))handler
{
[[NSFileManager defaultManager] removeItemAtURL:outputURL error:nil];
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:inputURL options:nil];
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetLowQuality];
exportSession.outputURL = outputURL;
exportSession.outputFileType = AVFileTypeQuickTimeMovie;
[exportSession exportAsynchronouslyWithCompletionHandler:^(void)
{
handler(exportSession);
[exportSession release];
}];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ffmpeg 是一个过时的方法,请尝试
AVFoundation
框架中的AVAssetWriter
。ffmpeg is an obsolete method try
AVAssetWriter
inAVFoundation
framework.