Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
oly104
Posts: 15
Registered: ‎04-16-2013
My Device: DevAlpha B
My Carrier: Robi
Accepted Solution

H264 video resizing

[ Edited ]

Hi,

 

I am trying to get the encoded data from camera API and then write this data to a file. Video codec I am using is H264. I want to change the width and height of the video using following code.

 

error=camera_set_video_property(mCameraHandle,
                CAMERA_IMGPROP_WIDTH, 540,
		CAMERA_IMGPROP_HEIGHT, 960,
	        CAMERA_IMGPROP_VIDEOCODEC,CAMERA_VIDEOCODEC_H264
		);

But I am getting an error CAMERA_EINVAL. I have also noticed that for rear camera only 1080*1920 and for front camera 720*1280 resolutions work. All other resolutions give the same error.

 

I also tried to get the supported resolution using following codeblock:

unsigned int supportedRes;
camera_res_t resolutions[100]; camera_get_video_output_resolutions(mCameraHandle, 0, &supportedRes,resolutions); fprintf(stderr, "Resolution error: %s\n",ErrorToString(error).toAscii().constData()); fprintf(stderr, "supported Resolutions %d\n", supportedRes);
for(int i =0 ; i < supportedRes; i++){ fprintf(stderr,"Resolution %d: width: %u height: %u\n", i, resolutions[i].width,resolutions[i].height);
}

 the output is:

supported Resolutions 13
Resolution 0: width: 0 height: 0
Resolution 1: width: 6 height: 3
Resolution 2: width: 0 height: 520215
Resolution 3: width: 17 height: 21
Resolution 4: width: 0 height: 0
Resolution 5: width: 1 height: 0
Resolution 6: width: 0 height: 1
Resolution 7: width: 1 height: 18
Resolution 8: width: 0 height: 0
Resolution 9: width: 1 height: 0
Resolution 10: width: 0 height: 1
Resolution 11: width: 1 height: 3
Resolution 12: width: 0 height: 4294967295

 

and can't figure out the problem.

Any help will be highly appreciated.

 

 

Please use plain text.
Developer
Innovatology
Posts: 1,280
Registered: ‎03-03-2011
My Device: Playbook, Z10, Q10, Z30 with Files & Folders and Orbit of course
My Carrier: Vodafone

Re: H264 video resizing

Your resolution array is uninitialized. You have only asked camera_get_video_output_resolutions() to tell you the number of resolutions because your second parameter is 0. Read the function documentation under "description" aboiut pre-sizing.

 

Also, always check the return code of such functions and only continue if OK.

 

Files & Folders, the unified file & cloud manager for PlayBook and BB10 with SkyDrive, SugarSync, Box, Dropbox, Google Drive, Google Docs. Free 3-day trial! - Jon Webb - Innovatology - Utrecht, Netherlands
Please use plain text.
Contributor
oly104
Posts: 15
Registered: ‎04-16-2013
My Device: DevAlpha B
My Carrier: Robi

Re: H264 video resizing

Thanks a lot for your reply.
It worked.

But I have a new problem.  Viewfinder height does not match requested video height. Viewfinder height remains 1920.

but I change the video height according to the suppoerted resolution.

I get the supported resolutions for viewFinder using following codeblock:

unsigned int supportedResvf;
	camera_res_t resolutionsvf[100];
	error = camera_get_video_vf_resolutions(mCameraHandle, 15, &supportedResvf,resolutionsvf);
	fprintf(stderr, "Resolution error: %s\n",ErrorToString(error).toAscii().constData());
	fprintf(stderr, "supported Resolutions vf %d\n", supportedResvf);
	for(int i =0 ; i < supportedResvf; i++){
		fprintf(stderr,"Resolution %d: width: %u height: %u\n", i, resolutionsvf[i].width, resolutionsvf[i].height);
	}

 When I try to change the height of the viewFinder using the function

error=camera_set_videovf_property()  and use CAMERA_IMGPROP_HEIGHT as a parameter
"error" contains CAMERA_EINVAL.

Please use plain text.
Developer
Innovatology
Posts: 1,280
Registered: ‎03-03-2011
My Device: Playbook, Z10, Q10, Z30 with Files & Folders and Orbit of course
My Carrier: Vodafone

Re: H264 video resizing

Sorry, don't know that one. Anyone else?

Files & Folders, the unified file & cloud manager for PlayBook and BB10 with SkyDrive, SugarSync, Box, Dropbox, Google Drive, Google Docs. Free 3-day trial! - Jon Webb - Innovatology - Utrecht, Netherlands
Please use plain text.
Contributor
oly104
Posts: 15
Registered: ‎04-16-2013
My Device: DevAlpha B
My Carrier: Robi

Re: H264 video resizing

[ Edited ]

Thanks again.
I have solved the problem. We can specify the foriegn window size before attaching the viewFinder with it. Then set resolution of viewFinder.

Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer
My Carrier: other

Re: H264 video resizing

you should be able to set CAMERA_IMGPROP_WIDTH & HEIGHT via camera_set_videovf_property() and camera_set_video_property().

you can only change the vf size prior to starting the viewfinder.

 

Please use plain text.