我正在尝试在远程服务器上播放视频文件.视频格式为flv,服务器为Flash Media Server3.5.
我将通过RTMP连接到服务器并使用Android Media Player实现视频文件的palyback.
真的,有可能吗?任何帮助都是我的荣幸.
我试图从rtsp服务器解码h264流并在iPhone上呈现它.
我找到了一些库并阅读了一些关于它的文章.
图书馆来自dropCam for iPhone,名为RTSPClient和DecoderWrapper.
但我不能使用在ffmpeg上使用的DecodeWrapper解码帧数据.
这是我的代码.
VideoViewer.m
- (void)didReceiveFrame:(NSData*)frameData presentationTime:(NSDate*)presentationTime
{
[VideoDecoder staticInitialize];
mConverter = [[VideoDecoder alloc] initWithCodec:kVCT_H264 colorSpace:kVCS_RGBA32 width:320 height:240 privateData:nil];
[mConverter decodeFrame:frameData];
if ([mConverter isFrameReady]) {
UIImage *imageData =[mConverter getDecodedFrame];
if (imageData) {
[mVideoView setImage:imageData];
NSLog(@"decoded!");
}
}
}
---VideoDecoder.m---
- (id)initWithCodec:(enum VideoCodecType)codecType
colorSpace:(enum VideoColorSpace)colorSpace
width:(int)width
height:(int)height
privateData:(NSData*)privateData {
if(self = [super init]) {
codec = avcodec_find_decoder(CODEC_ID_H264);
codecCtx = avcodec_alloc_context();
// Note: for H.264 RTSP streams, the width and height are usually not specified (width and height …Run Code Online (Sandbox Code Playgroud) 我将在MPMediaPlayerController上寻找时间线.
我尝试使用MPMediaPlayerController的未记录的方法setCurrentTime,如下所示.
[player setCurrentTime:1.f];
Run Code Online (Sandbox Code Playgroud)
然后苹果崩溃跟随......
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MPMoviePlayerController setCurrentTime:]: unrecognized selector sent to instance 0x5619fe0'
*** Call stack at first throw:
(
0 CoreFoundation 0x00f59be9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x010ae5c2 objc_exception_throw + 47
2 CoreFoundation 0x00f5b6fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00ecb366 ___forwarding___ + 966
4 CoreFoundation 0x00ecaf22 _CF_forwarding_prep_0 + 50
5 MPlayerExample 0x0000227d -[MPlayerExampleViewController PauseVideo] + 69
6 Foundation 0x000367f6 __NSFireDelayedPerform + 441
7 CoreFoundation 0x00f3afe3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
8 …Run Code Online (Sandbox Code Playgroud)