我有一系列TIF格式的图像,我想以固定的FPS(比如每秒10张图像)创建一部电影,这是无损的.有一个简单的方法吗?我一直在尝试使用convert
Imagemagick,ffmpeg
但是,我无法弄清楚要使用什么设置来避免任何压缩.
我基本上有一个字节矩阵.每行(意为byte [])表示图像.如何创建一个电影(任何格式 - avi,mpeg,等等),并将其保存为文件?每个图像可以是以下之一:
int JPEG Encoded formats.
int NV16 YCbCr format, used for video.
int NV21 YCrCb format used for images, which uses the NV21 encoding format.
int RGB_565 RGB format used for pictures encoded as RGB_565.
int YUY2 YCbCr format used for images, which uses YUYV (YUY2) encoding format.
int YV12 Android YUV format: This format is exposed to software decoders and applications.
Run Code Online (Sandbox Code Playgroud)
只要我创建电影,我就可以选择我喜欢的格式.
public void createMovie(byte[][] images) {
// and ideas on what to write here?
} …
Run Code Online (Sandbox Code Playgroud) 我正在使用UIImagePickerController来允许我的用户从资产库中选择一个视频.
当用户选择第二个屏幕上的"选择"按钮时,视图显示进度条和"压缩视频..."消息.
为什么会这样?
有什么办法可以避免这种压缩操作吗?
我有这个代码用电影显示gif图像.
public class GIFView extends View{
private Movie movie;
private InputStream is;
private long moviestart;
public GIFView(Context context) {
super(context);
is=getResources().openRawResource(R.drawable.anim_cerca);
movie=Movie.decodeStream(is);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
long now=android.os.SystemClock.uptimeMillis();
if (moviestart == 0)
moviestart = now;
int relTime = (int)((now - moviestart) % movie.duration());
movie.setTime(relTime);
movie.draw(canvas,10,10);
this.invalidate();
}
}
Run Code Online (Sandbox Code Playgroud)
当gif加载时,我的问题就出现了,它画得非常糟糕,只显示了第一帧,而另一帧则被打扰了.我能做什么?
编辑:问题是模拟器!它不会显示GIF,但设备它没关系!:)
我有一个iPad应用程序,用于创建和显示视频MPMoviePlayerViewController
.这是我的代码:
MPMoviePlayerViewController *mpvc = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:URLEncode(uri)]];
[mpvc setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[mpvc setWantsFullScreenLayout:YES];
[<MainViewController> presentModalViewController:mpvc animated:YES];
Run Code Online (Sandbox Code Playgroud)
电影加载/播放工作正常,但是,当电影控制器出现时,它会在顶部显示状态栏(连接,电池,小时),即使我在主窗口上取消激活它也是如此.
我试过做:
[mpvc setWantsFullScreenLayout:YES];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
Run Code Online (Sandbox Code Playgroud)
似乎没有任何工作,但是如果我也放了:
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
Run Code Online (Sandbox Code Playgroud)
状态栏消失了!但电影控制器仍然会调整大小,好像状态栏在那里(即使我已经使用过-setWantsFullScreenLayout:
).
有人能指出一种简单(经过验证)的方式来显示没有状态栏的视频吗?
谢谢.
我有一个名为videoplay.html
以下内容的html文件
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
</head>
<body>
<p>
This is demo html file for playing movie file embedded.
</p>
<p>
<video controls>
<source src="myvideoname.mov">
</video>
</p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
使用以下代码(Loading from application bundle)
它加载html内容并显示电影,并能够播放电影文件.
NSURL *baseURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
NSString *path = [[NSBundle mainBundle] pathForResource:@"videoplay" ofType:@"html"];
NSString *content = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
[self.webView loadHTMLString:content baseURL:baseURL];
Run Code Online (Sandbox Code Playgroud)
使用以下代码(Loading from Document folder of application)
它加载html内容但显示黑色部分而不是电影文件.
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir =[documentPaths objectAtIndex:0]
NSString …
Run Code Online (Sandbox Code Playgroud) 每当我更改AVPlayerLayer的帧时,视频不会立即调整大小,而是动画为新大小.
例如:我将帧从(0,0,100,100)更改为(0,0,400,400),视图的帧立即更改,但视频的大小设置为新大小.
有没有人遇到过这个问题?如果有,是否有人知道禁用默认动画的方法?
谢谢!
我可能没有把我的头衔措辞得很好,也许更正确的说我的NSNotification并没有在完成比赛后放弃我的电影观点.我发现其他人有这个问题,但没有解决方案,似乎它可能是iOS 6的问题,这就是我正在运行的.
视频完成播放后,您需要按"完成"才能解除,但我希望它能自动关闭,因为我将使用MPMovieControlStyleNone一旦我将其整理出来.这是我的代码,未使用的部分被删除:`
#import "MovieViewController.h"
@interface MovieViewController ()
@end
@implementation MovieViewController
@synthesize moviePlayer = _moviePlayer;
- (IBAction)playMovie:(id)sender
{
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"TestMovie" ofType:@"mov"]];
_moviePlayer =
[[MPMoviePlayerController alloc]
initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:_moviePlayer];
_moviePlayer.controlStyle = MPMovieControlStyleDefault;
_moviePlayer.shouldAutoplay = YES;
[self.view addSubview:_moviePlayer.view];
[_moviePlayer setFullscreen:YES animated:NO];
}
- (void) moviePlayBackDidFinish:(NSNotification*)notification {
MPMoviePlayerController *player = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
if ([player
respondsToSelector:@selector(setFullscreen:animated:)])
{
[player.view removeFromSuperview];
}
}
@end`
Run Code Online (Sandbox Code Playgroud) 我正在使用UIImagePickerController来允许我的用户从资产库中选择一个视频.
最初显示UIImagePickerController时,它会显示已录制的各种电影的缩略图.
一旦用户选择了电影,它就会显示一个"预览"视图,允许它们播放并可能编辑所选的电影.
有没有办法避免显示此视图,而是返回在缩略图屏幕上选择的电影?
这是我正在使用的代码:
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
imagePicker.allowsEditing = NO;
[self presentModalViewController:imagePicker animated:YES];
Run Code Online (Sandbox Code Playgroud) [更新]
按照建议,我更改了所有父视图控制器以支持所有方向.我的app结构如下:AppDelegate> RootViewController> Videos> VideoDetails> MPMoviePlayerViewController.
如果我改变所有这些以支持所有方向,视频将在风景中播放.但支持所有方向并不是我想要的,并导致其他问题.还有其他工作或我可以做的其他事情吗?
谢谢
[/更新]
我有一个基于肖像的iPhone应用程序,它使用MPMoviePlayerViewController的自定义子类显示视频.当用户按下播放时,我创建了这个类的实例,并按模式呈现它,如下所示:
- (IBAction) playPressed:(id)sender {
NSString *filepath = [[NSBundle mainBundle] pathForResource:self.currentVideoModel.videoFileName ofType:@"m4v"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
// MovieViewController is just a simple subclass of MPMoviePlayerViewController
self.moviePlayerController = [[MovieViewController alloc] initWithContentURL:fileURL];
// full screen code.
[self.moviePlayerController.moviePlayer setScalingMode:MPMovieScalingModeFill];
[self.moviePlayerController.moviePlayer setFullscreen:TRUE];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlaybackComplete:) name:MPMoviePlayerPlaybackDidFinishNotification object:self.moviePlayerController];
[self presentMoviePlayerViewControllerAnimated:self.moviePlayerController];
}
Run Code Online (Sandbox Code Playgroud)
问题是它在纵向上播放得很好但是当我将iPhone转为横向时,视频仍然以纵向而非横向播放:(应用中的所有视图控制器仅支持纵向.
我的MPMoviePlayerViewController子类只覆盖以下方法以允许方向更改,但它没有任何影响:
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return (toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight || toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
Run Code Online (Sandbox Code Playgroud)
我甚至尝试以编程方式旋转视频,但绝对没有运气,它始终保持纵向模式.
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation …
Run Code Online (Sandbox Code Playgroud) iphone movie mpmovieplayercontroller orientation screen-orientation
movie ×10
iphone ×4
video ×4
ios ×2
ipad ×2
android ×1
avfoundation ×1
avi ×1
compression ×1
ffmpeg ×1
gif ×1
image ×1
imagemagick ×1
ios6 ×1
java ×1
mpeg ×1
orientation ×1
statusbar ×1
uiwebview ×1