Directshow Video capture on Windows Mobile - Windows Mobile Development and Hacking General

Hi
I'm trying to write an app to capture video through integrate cameras using directshow. Now, the prob is though the app is doing this now, but after capture is stopped, encoding takes a loooooong time to complete. The encoder being used is WMV9. Now, the inbuilt camera apps must be doing this differently because they dont take any extra time after capture is stopped. So, any suggestion how to optimize the process (how to use a different encoder, or otherwise) to speed up the capture?
TIA

Just found out that HTC devices ship with a filter named "HTC Source Filter". Somewhere on directx.audio group I found out that someone had delved into it a bit and found that it was a capture filter from HTC (both audio and video). I checked in registry and that is true. So, it must be some optimized filter that we can use for capture.
Now, I tried to enumerate the pins on this capture filter, for which I have to first query for an IPersistPropertyBag interface on this filter (used the clsid of the filter from the registry and CoCreateInstance for it returns S_OK). But the QueryInterface returns E_NOINTERFACE. Any opinions/suggestions here? Because the registry clearyly shows that this is a capture filter. Is there any other way I can use this filter?
---My Code---
HRESULT hResult = S_OK;
IGraphBuilder *pFilterGraph;
ICaptureGraphBuilder2 *pCaptureGraphBuilder;
htcDDR.Data1 = 0xA06DF275;
htcDDR.Data2 = 0xC4F3;
htcDDR.Data3 = 0x46C7;
htcDDR.Data4[0] = 0xB5;
htcDDR.Data4[1] = 0x20;
htcDDR.Data4[2] = 0x3A;
htcDDR.Data4[3] = 0x16;
htcDDR.Data4[4] = 0xB3;
htcDDR.Data4[5] = 0xD1;
htcDDR.Data4[6] = 0xB8;
htcDDR.Data4[7] = 0xC2;
hResult = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC,
IID_IGraphBuilder,(void**)&pFilterGraph);
hResult = CoCreateInstance(CLSID_CaptureGraphBuilder, NULL,
CLSCTX_INPROC, IID_ICaptureGraphBuilder2,
(void**)& pCaptureGraphBuilder);
hResult = pCaptureGraphBuilder->SetFiltergraph( pFilterGraph );
IBaseFilter *pVideoCaptureFilter;
hResult=CoCreateInstance(htcDDR, NULL, CLSCTX_INPROC,
IID_IBaseFilter, (void**)&pVideoCaptureFilter);
IPersistPropertyBag *pPropertyBag;
hResult=pVideoCaptureFilter->QueryInterface( IID_IPersistPropertyBag, (void**) &pPropertyBag );
/* This is where I get the E_NOINTERFACE*/
---------------

Capture Performance on WM 5
Hello shantzg001,
I'm quite new in C++ mobile developpement and have the same problem with the encoding performance of the WM9 encoder. Have you find something new to improve that perfomance or change the default encoder (HTC built in) ?
Thanks

hey thecrets, Im afraid I couldn't...

Hello guys,
I've got an HTC Athena and I find encoded videos are crappy. I'm not a coder, at least I'm not a windows mobile coder, Id just like to know if that would be possible to record videos directly to the microdrive or a SD card in raw mode, so I would encode the video later on my desktop PC.
Do you think a machine like the Athena is powerfull enough to handle video recording in raw mode ? Would the microdrive fast enough ?
Another thing, I can't access more than CIF video mode, is it possible to reach higher resolutions with directshow ?
I know there is a software called coolcamera, but it was not updated since 1 year, and my device is not compatible.
Very very last question, if raw mode is possible, could one of you upload here a release of his proggy ?
Thanks dudes ! I don't expect n95 videos on our devices,but I'm sure it can be really better than what we have.

Hi~
have you solve your problem now? I came across the same problem, and have no idea.

I could be wrong ( or just a moron) but isn't there a webcam program for ppc out there that does exactly what you are trying to create?

@arigold1: If that was directed me, then Yes, there is a webcam program but that is not what I "was" trying to create..I needed to do the recording but not as a webcam but smthing else as part of another project that I was doing at that time..

Related

converting ASCII to Unicode

hi ther i wonder if you could help me on this simple task. I'm creating a GPS application to run on the XDA2, i'm using eVC++ to do the implementation.
at the moment i'm reading the GPS signal via bluetooth over a virtual COM port, the signal coming from the GPS if a ASCII sinal and i'm duimping this into a char buffer.
However i need to convert this to UNICODE in order to display it on the Pocket PC, how's best to convert a buffer full of ASCII into Unicode so i may display it?
I tried using MultiByteToWideChar(), but it doesn't seem to work properly, maybe i haven't set it up correctly? Could someone point me in the right direction!
Below is an example of what i tried:
Code:
char buf[50]; // contains output from GPS
TCHAR Message[50]; //where i intended to put the message so i could display it
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, buf, -1, Message, 0);
Thank in advance
I'm sure it's not the right way to go about it, but I generally wsprintf for short strings.
However, don't listen to me, I'm a mad man. Check this page out instead:
http://www.i18nguy.com/unicode/c-unicode.html
V
Thanks for that, out of curiosity, how would you use wsprintf to convert ASCII to unicode, i tried that before with no real success!
The last value passed to MultiByteToWideChar tells this function the size of the result buffer, Message in your case. You have passed zero, all that does is makes the function return the size of a TCHAR variable it needs to put the Ascii input buf into.
You need to put sizeof(Message) as the last parameter and not zero.
The other way (better way ?) of doing this is first you call the MultiByteToWideChar function with the zero parameter as you have and then you malloc the result * sizeof(TCHAR).
Thanks for the advise, after looking into the function more i realised this is where i was going wrong, and i have now managed to make the conversion. Thanks for pointing that out though!

intro!

Hi Guys,
I'm going through the forum, I'm new to embedded developement, I've been able to do my first MessageBox("Hello World") in C using VS2005.
I want to understand how all this works, like :
- Accessing any "mass storage" device ? (the root FS ?, /, c:\, whatevername )
- Dumping the whole registry + values.
- Logging Process and activity even while "device locked" (new process, etc..)
And having more knownledge about the internals and devices, booting etc..
I'm kind of lost and my embedded knowledge is very thin..
The PPC i have is running WM5 on QTEK9100 (SPVM3000)..
Any pointers, posts, sources, small explication are more than welcome...
Hope you can help,
Regards,
r.
Welcome!
Wow those sure are some heavy requests for someone who is just starting.
How much experience do you have with C and Win32 APIs?
To start you off here is an excellent site for Windows Mobile programming tips and tricks:
www.pocketpcdn.com
Couple more pointers:
Device root is "\", no drives (SD cards mounted as folders) kind of like Linux.
All path are absolute - no ".\" or ".."
You can use standard C or Win32 functions for file operations.
Registry functions are also same as Desktop windows except you have to use the "Ex" version of of the function.
Example:
RegOpenKey - not implemented, use RegOpenKeyEx.
For process lists etc, google for ToolHelp32.
Thanks,
I'm at ease w/ ANSI C, have some familiarity w/ Win32 APIs,
but as far as I'm seeing I'm trying to code on Win32 Intel First,
then i try to "port" it to PocketPC Mobile, sometime it works
sometime functions doesn't even exists... MSDN doesn't seems very consistent over Win32 vs WM, but as I'm new I guess i'm missing a lot..
WinMain() prototype changes according to your target...otherwise
VS2005 yell about Overloading WinMain, It is VERY annnoying..anyway
Thanks for the links and the *Ex trick, I'll try to get deeper with this.
I have a strange problem trying to do my Own MessageBoxPrintf:
int MessageBoxPrintf(int, const char * title, const char * fmt, ...)
{
va_list ap;
char * buffer = NULL;
/* formatting and fixed size yes...*/
buffer = (char *) malloc (1024 * sizeof(char));
if (!buffer)
return -1;
memset(buffer, 0, 1024);
va_start(ap, fmt);
vsprintf(buffer, fmt, ap);
va_end(ap);
MessageBox(NULL, (LPCWSTR)buffer, (LPCWSTR)title, type);
return 0;
}
It does compile, but it display craps, since there is no stderr,stdout,stdin and
that I'm mostly coding on Win32/VMware, I don't know how to debug on my PPC (no USB connection), and I have no idea what's wrong.. it might be obvious, but it's late..
As I don't know what LPCWSTR stand for, I assumed char * and it did work on Win32 (XP) without hassle (except LPCWSTR types which are wrong for Win32 Target), so why it doesn't on WM5... is a mystery for me now..
Hope to be on speed ASAP to be able to release some stuff..
Thanks for your help,
Cheers,
r.
all WinAPI function on Pocket PC works with Unicode strings. So you have to convert from ANSI to Unicode.
ok, does the TEXT() macros convert to Unicode string, it seems not.
How to convert from ANSI to Unicode ?
you can work directly with wchar_t or use tchar that can be ansi or unicode, otherwise look for MultiByteToWideChar or CString object _T and TEXT Macro aren't for converting ansi but they makes unicode prefix strings... for example MessageBox(hWnd,_T("Hello World"),_T("my messagebox"),MB_OK);
I hope this help and don't forget MSDN have all replies
have fun,
Guybrush
ok it works! thanks!
just another question, how to dump the "disk" or how those devices are booting ROM?/Flash?
Currently I'm copying all the files from / to the SD card mount point is there anything else?
again thanks for your help.
++
r.

[help needed] NEC PC9801 Emulator [updated]

Hi,
I have a touch HD (blackstone) and I wanted to run the Pocket PC official port of "Neko Project" on it :
http://retropc.net/yui/np2wce.html
It a NEC PC9801 Emulator (an old japanese PC like computer, with a lot of cool games ).
Two problems :
- the mouse module is disabled, probably because the target Pocket PC dont have a touch screen, the code looks like this (WinCE/MOUSEMNG.CPP)
BYTE mousemng_getstat(SINT16 *x, SINT16 *y, int clear) {
*x = 0;
*y = 0;
(void)clear;
return(0xa0);
}
Its clearly different from the file Win9x/MOUSEMNG.CPP for the win32 port
- the second problem, there is no 800x480 resolution support, this could be corrected in this file I think : WinCE/NP2.H
My request, can anyone (with a good experience on Windows Mobile coding) help me correct these two problems ? the source code is available on the link above (the file np2_081as.zip).
I'm somewhat good at coding in Win32 API but have never coded on Pocket PC...
Thanks in advance
Bye
UP please ?
Hi, here's a little update,
I managed to change the resolution to 480x800, no need to use wvgafix now
I even managed to detect the exact mouse position, but when I click nothing happens
Here is the source code, can anyone take a look and help me correcting the mouse part ? I tryed to copy the code from the win9x source but it didnt work...
http://rapidshare.com/files/185069548/np2.zip
Thanks in advance
UP please ?

[REF] *Leo camera Hints & Tips*. Updated 19th December.

I started this hints and tips thread for the HD2 (LEO) as i like most others wasn't to happy with the default camera app that the HD2(LEO) had to offer, to be honest the camera quality was lacking in most areas. The purpose of this thread is to collate all tips and have them available within the first few posts as opposed to having to search for tips among the many pages and threads. Please submit additional tips and hints you have and I will update the first few posts.
you will need a registry editor to do most of these tweaks and their may also be .cabs attached to the bottom of the corresponding post to save the effort need when editing the registry. u can use apps like resco, memmaid, sktool to edit the registry or an app of ur liking
for best possible picture from the HD2(LEO) - you may want to use these setting, use with all mods i post here and you will be very happy with the outcome and possibly feel overwhelmed by the quality of your HD2(LEO) cameras like most ive share these with
WB - either auto or indoor light dependent on ambient light
iso auto - if in a very bright sunny outdoor type weather set this to 100 for best result
5M resolution
wide-screen OFF
touch focus OFF
super fine quality
contrast +4
saturation +3
sharpness +4
metering mode average
1). extrasuperfine quality
Go to HKLM\software\htc\camera\image\jpegquaity\superfine and replace the 5Msize value with 746028 (default value = 643628)
or install the extrasuperfine.cab or install BsB Tweaks 1.5
before and after photos
http://forum.xda-developers.com/showpost.php?p=5157324&postcount=107
http://forum.xda-developers.com/showpost.php?p=5135805&postcount=55
http://forum.xda-developers.com/showpost.php?p=5135911&postcount=56
http://forum.xda-developers.com/showpost.php?p=5130666&postcount=3
2). unlock additional video modes
Go to [HKLM\Software\HTC\Camera\P2 and replace the EncodeFormat value with 2147483647
or install the additionalvideomodes.cab
this will unlock all modes/resolutions listed below
H263(3gp)
CIF 352x288 \ M 176x144
mpeg4
L 320x240 \ CIF 352x288 \ VGA 640x480
3gpp2
S 128x96 \ M 176x144 \ L 320x240 \ CIF 352x288 \ VGA 640x480
motion jpeg
S 128x96 \ M 176x144 \ L 320x240 \ CIF 352x288 \ VGA 640x480
H264
L 320x240 \ CIF 352x288
3). enable .BMP mode in camera
Go to [HKLM\Software\HTC\Camera\P1 and replace the EncodeFormat value with 3
(not quiet working cant get it to stick auto goes back to jpeg in camera app, im hoping people can help me out alittle with this one)
4). improve camera recording quality of mpeg4-vga (boost bit-rate = less fussiness and pixels)
Go to [HKLM\Software\HTC\Camera\recparam\MP4VGA and replace the BitRate value with 4194304 (default value = 2097152)
this will increase your video quality from 2100avg bit-rate to 4500avg bit-rate, leave fps set to 30 as when detail is high in video it causes major fps loss, so with this ur camera will run better than ever and also have improved image quality while recording in MPEG4 vga mode, going any higher in bit-rate will cause slower fps and offer no additional improvement over my posted tweak
please keep in mind that video size increases approx 2times of the default settings, so a 10sec vid normally cost 2700kb while the tweak costs 5500kb
im working on 720p, micro-modes, bmp files and also increased video quality so keep looking for updates daily
ADDED:
19/12/09 = new cab for improve camera recording quality of mpeg4-vga
DAMIEN123_666 said:
2). unlock additional video modes
Go to [HKLM\Software\HTC\Camera\P2 and replave the EncodeFormat value with 2147483647
this will unlock all modes/resolutions listed below
Click to expand...
Click to collapse
Thanks Damien, but I'm not able to enter a 10 Digit Number in EncodeFormat. Only 8 digits are possible. Did you change the key type?
cyclingfan74 said:
Thanks Damien, but I'm not able to enter a 10 Digit Number in EncodeFormat. Only 8 digits are possible. Did you change the key type?
Click to expand...
Click to collapse
hi no its the same, should be a value : double word (decimal). u can use both sktools and memmaid to edit the value, what app are u using ?
I'm using Taskmanager v3.1 by FdcSoft
cyclingfan74 said:
I'm using Taskmanager v3.1 by FdcSoft
Click to expand...
Click to collapse
hi ive made a cab please use it for ease
Thanks, but I installed SKTools now. It worked. I mean, I could enter a 10-digit number at least. Let's see, if the tweak is working, too.
Yes it did!
I have tried all the new video modes but mpeg4 still gives best results?, does for me.
Wow, thanks for this great thread and useful hints! I'm really looking forward to 720p video recording! This would be awesome!!
jrvenge said:
I have tried all the new video modes but mpeg4 still gives best results?, does for me.
Click to expand...
Click to collapse
Normally mp4 will always give the best results.
menus are active, still don't understand the quality ... good for me anyway ;-)
Hey, great work. This thread is something I would like to see sticky or linked in the wiki.
I am unable to select anything other than JPEG and BMP format. It then greys out. The registry entry mentioned above was changed with the cab. Anyone tell me the default value for this so I can change it back? I cannot uninstall the cab as it is not listed in programs.
DAMIEN123_666 said:
hi ive made a cab please use it for ease
Click to expand...
Click to collapse
Hi,
Could you please detail what this cab changes? I installed it and now cannot select anything other than JPEG and BMP. It allows one change then greys out.
Thanks.
derta said:
Hey, great work. This thread is something I would like to see sticky or linked in the wiki.
Click to expand...
Click to collapse
i hope to so, i assume i have to earn this though
why
why will disabling touch focus improve quality?
why will disabling touch focus improve quality?
Click to expand...
Click to collapse
the focus on this camera for light is controlled by this option basically
touch focus = spot = the overall light of the picture is dictated by the spot u select to focus on
center focus = center picture = the overall light of the picture is dictated by the center light in the picture
average focus = the picture takes all light form around the image and averages it out for one even picture,
so basically if u take a picture of a object that gives off light like a tv or light or sumat like this the touch focus, focuses on that object and the rest of the picture will be over dark and maybe even black, when average focus is selected it evens it out so u get to see all the objects in the light and dark evenly
DAMIEN123_666 said:
the focus on this camera for light is controlled by this option basically
touch focus = spot = the overall light of the picture is dictated by the spot u select to focus on
center focus = center picture = the overall light of the picture is dictated by the center light in the picture
average focus = the picture takes all light form around the image and averages it out for one even picture,
so basically if u take a picture of a object that gives off light like a tv or light or sumat like this the touch focus, focuses on that object and the rest of the picture will be over dark and maybe even black, when average focus is selected it evens it out so u get to see all the objects in the light and dark evenly
Click to expand...
Click to collapse
The 3 modes all have their uses though, you need to work out when to use them. For example when taking a picture of a large plasma or LCD TV in the dark the touch focus is excellent. You end up with a very clear screen image and nothing else. If you try bto do the same with a 'better' camera phone, like a symbian you just cant get the same effect.
rovex said:
The 3 modes all have their uses though, you need to work out when to use them. For example when taking a picture of a large plasma or LCD TV in the dark the touch focus is excellent. You end up with a very clear screen image and nothing else. If you try bto do the same with a 'better' camera phone, like a symbian you just cant get the same effect.
Click to expand...
Click to collapse
very true matey, for general images of say out doors or portraits the setup on post one i made is by far the best option but if you do intend to take images of brighter objects touch focus will give better results if you only wanna focus on that object
play with the settings is all i can recommend
thx for the video cab, awesome!
SD Card Storage Capacity official update
@ DAMIEN : Hey mate, I better ask first than ask too late... Do you think these (Yours, also future) tweaks won't have problem with the official ones? I ask because there's another one out - SD Card Storage Capacity - from HTC. I guess it has nothing to do with the tweaks, but you know... Thx devilman
4). improve camera recording quality of mpeg4-vga (boost bit-rate = less fussiness and pixels)
Go to [HKLM\Software\HTC\Camera\recparam\MP4VGA and replace the BitRate value with 4194304
Go to [HKLM\Software\HTC\Camera\recparam\MP4VGA and replace the FrameRate value with 60
Click to expand...
Click to collapse
I accidentally set VSbitrate value to 4194304. could someone please provide me the original setting?...

Why can't i capture image and video both?Why only one at a time?

hi
I am a newbie android developer.
I did post this in Q&A, where people told me to ask this is the dev section. So i am posting it here, it is a question related to the application I am developing.
Know some fundamentals of Android OS.
Also familiar with Java, just new to Android.
I am building an application where i need to access the camera to click pictures and videos
At this stage, I can do only one thing at a time.(either click image/video, i have both the codes, the intents and everything however i need to change the code and can use only one at a time, for example if video code is executing, i dont see a focus on the screen for image to be captured... however the record button is visible, but when image code is executed i dont see any record button...i do see the focus on the screen for the capture.. )
My code is in the onCreate function, i know this is the function called first in the lifecycle, so i tried putting both code for images and videos in this function, but i can do only one.
here is my
Code:
/*code for images*/
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File imagesFolder = new File(Environment.getExternalStorageDirectory(), "MyImages1");
imagesFolder.mkdirs(); // <----
File image = new File(imagesFolder, "IMAGE_001.JPG");
Uri uriSavedVideo = Uri.fromFile(image);
intent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedVideo);// set the image file name
startActivityForResult(intent,CAPTURE_IMAGE_ACTIVI TY_REQUEST_CODE);
/*code for videos
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
File videosFolder = new File(Environment.getExternalStorageDirectory(), "MyVideos1");
videosFolder.mkdirs(); // <----
File video = new File(videosFolder, "video_001.mp4");
Uri uriSavedVideo = Uri.fromFile(video);
intent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedVideo);// set the image file name
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); // set the video image quality to high
startActivityForResult(intent,CAPTURE_VIDEO_ACTIVI TY_REQUEST_CODE);
*/
why can i click image or video only but not both in my application?
guys sorry for the second post..
but please do reply something..
give me some hints..directions as to what I should look for..
so that I can proceed..
You let the Camera.apk do your work. Maybe there is a way, if you take the video yourself: Use the MediaRecorder and Camera classes.

Categories

Resources