slavavdovichenko / MediaLibDemos

98 stars 25 forks source link

Frames of Video streaming #37

Open inal opened 10 years ago

inal commented 10 years ago

Hi..

Thanks for the great work.

I am facing an issue: While recording a live video, the frames are not same as of the default frames of the Camera. I want to record a video in the exact frames i.e. 320x568 and while doing so, the video recorded is blurry and also the focus is not correct.

Could you tell me where can I change the frames of the video recorder or give me some idea to resolve this.

Please help.

Thanks in Advance :)

inal commented 10 years ago

Any updates??

ankushdhawan commented 10 years ago

Hi..

I am facing an same issue:

inal commented 10 years ago

Also, i would like to mention that this problem arises specifically in Landscape mode when I am setting the frames of previewView as 568X320.

Thanks in advance.

inal commented 10 years ago

Hi Slavavdovichenko,

Any updates on this?

Thanks

slavavdovichenko commented 10 years ago

Hi,

MediaLibiOS uses the folowing capture mode constants of AVFoundation framework (they are in AVCaptureSession.h): switch (_resolution) { case RESOLUTION_LOW: sessionPreset = AVCaptureSessionPresetLow; // 192x144 break; case RESOLUTION_CIF: sessionPreset = AVCaptureSessionPreset352x288; // 352x288 break; case RESOLUTION_MEDIUM: sessionPreset = AVCaptureSessionPresetMedium; // 480x360 break; case RESOLUTION_VGA: sessionPreset = AVCaptureSessionPreset640x480; // 640x480 break; }

How I can set the sessionPreset for 320x568? I don't know, and you?

It is my idea for you: BroadcastStreamClient class has delegate property: @property (nonatomic, assign) id delegate; and in MPIMediaStreamEvent protocol is the method: -(void)pixelBufferShouldBePublished:(CVPixelBufferRef)pixelBuffer timestamp:(int)timestamp;

This method is invoked every time the video frame is sent to the server, so you can get it and convert it to image with resolution what you need.

inal commented 10 years ago

I was trying the same thing. Thanks a lot for update. Cheers..!!

trident10 commented 10 years ago

Hi slavavdovichenko,

I think there is one option that can be included in the library to have flexible video resolution. AVCaptureStillImageOutput has option to set output setting with custom width and height. For example:-

_stillImageOutput = [[AVCaptureStillImageOutput alloc] init]; NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithDouble:myWidth], (id)kCVPixelBufferWidthKey, [NSNumber numberWithDouble:myHeight], (id)kCVPixelBufferHeightKey, [NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA], (id)kCVPixelBufferPixelFormatTypeKey, nil];

[_stillImageOutput setOutputSettings:options];

Same way, AVCaptureVideoDataOutput has option to set dictionary value videoSettings. Various settings include:- https://developer.apple.com/library/prerelease/iOS/documentation/AVFoundation/Reference/AVFoundation_Constants/index.html#//apple_ref/doc/constant_group/Video_Settings

It would be great if you provide a method to set the dynamic resolution directly instead creating and sending pixelbuffer.

Please do share your thoughts on it.

Thanks Abhi