You Are Here:

Community: Developer Discussion Boards

Reply « Previous Thread | Next Thread »

#1 Old video capturing using MIDlet - 2006-02-09, 16:19

Join Date: Jan 2006
Posts: 17
bangus
Offline
Registered User
i can't seem to find codes to use a MIDlet to capture video.. can anyone help me? thanx..
Reply With Quote

#2 Old Re: video capturing using MIDlet - 2006-02-11, 20:21

Join Date: Nov 2003
Posts: 3,641
Location: Bangalore , India
Send a message via Yahoo to balagopalks
balagopalks's Avatar
balagopalks
Offline
Forum Nokia Expert
Please check this link.There is an example too..
http://www.forum.nokia.com/info/sw.n..._0_en.pdf.html

Hope this helps!

Regards
Gopal
Reply With Quote

#3 Old Re: video capturing using MIDlet - 2006-02-16, 12:12

Join Date: Feb 2006
Posts: 113
pillar
Offline
Regular Contributor
I'm having the same question. Is it possible to capture video (not just snapshot images like the example in the last reply) with the mmapi? I'm experiencing with mmapi 1.1 and Nokia 6680.

I have been able to use the capture://video to succesfully show the viewfinder, but there seems to be no method for anything else than getSnapShot.

Can someone answer this question?
Reply With Quote

#4 Old Re: video capturing using MIDlet - 2006-02-16, 17:29

Join Date: Jun 2005
Posts: 928
dcrocha's Avatar
dcrocha
Offline
Forum Nokia Expert
You will have to check the MMAPI javadocs, available in all SDK installations. It has complete examples of capturing videos.

Daniel
Reply With Quote

#5 Old Re: video capturing using MIDlet - 2006-02-17, 16:42

Join Date: Feb 2006
Posts: 113
pillar
Offline
Regular Contributor
I have checked MMAPI javadocs and I haven't found a single reference to capturing video. Just capturing video *images* using "capture://video". These are two different things. I would actually want a video with many frames. So can anyone confirm, is that all that you can do - take snapshots? Or is it possible to capture a real video (with many frames)? Thanks.
Reply With Quote

#6 Old Re: video capturing using MIDlet - 2006-02-17, 17:17

Join Date: Jun 2005
Posts: 928
dcrocha's Avatar
dcrocha
Offline
Forum Nokia Expert
Hi,

You are right, the example is for capturing audio, but the procedure for video is the same: create a player with "capture://video", grab a RecordControl out of it and start recording.

As far as I know, though, only S40 3rd edition (some) and Series 60 support capturing video from Java.

Daniel
Reply With Quote

#7 Old Re: video capturing using MIDlet - 2006-02-19, 13:24

Join Date: Jan 2006
Posts: 17
bangus
Offline
Registered User
hey! thank you very much for the info... you're a life saver!
Reply With Quote

#8 Old Re: video capturing using MIDlet - 2006-02-19, 14:06

Join Date: Jan 2006
Posts: 17
bangus
Offline
Registered User
how can i test if it is acutally recording? these are my codes (i apologize for the number of commented out lines):

/*
* IndexMIDlet.java
*
* Created on February 19, 2006, 8:33 PM
*/

package Surveillance;

import java.io.IOException;
import javax.microedition.lcdui.*;
import javax.microedition.media.*;
import javax.microedition.media.control.*;
import javax.microedition.midlet.MIDlet;
import javax.microedition.media.control.VideoControl;
import java.io.*;

/**
*
* @author Viics
* @version
*/
public class IndexMIDlet extends MIDlet implements CommandListener{
//VIDEO MIDLET
private Display display;
private Form form;
private Command exit, record, stopRecord;
private Player player;
private VideoControl videoControl;
private Video video;
private RecordControl recordControl;
private Canvas canvas;

public IndexMIDlet(){
exit = new Command("Exit", Command.EXIT, 0);
record = new Command("Record", Command.ITEM, 0);
stopRecord = new Command("Stop Record", Command.ITEM, 0);

form = new Form("Surveillance");
//form.addCommand(exit);
//form.addCommand(record);
form.setCommandListener(this);
}
public void startApp() {
display = Display.getDisplay(this);
display.setCurrent(form);
showCamera();
}

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}

public void commandAction(Command c, Displayable s){
if (c == exit) {
destroyApp(true);
notifyDestroyed();
}else if (c == record){
video = new Video(this);
video.start();
form.append("Recording...");
}else if (c == stopRecord){
video.stopRecord();
form.append("Stop Recording...");
}
}

public void showCamera() {
try {
player = Manager.createPlayer("capture://video");
player.realize();

videoControl = (VideoControl)player.getControl("VideoControl");
canvas = new VideoCanvas(this, videoControl);
//canvas.addCommand(back);
//canvas.addCommand(capture);
canvas.addCommand(record);
canvas.addCommand(stopRecord);
canvas.addCommand(exit);
canvas.setCommandListener(this);
display.setCurrent(canvas);
player.start();
} catch (IOException ioe) {} catch (MediaException me) {}
}

class Video extends Thread{
IndexMIDlet midlet;
RecordControl rc;

public Video(IndexMIDlet midlet) {
this.midlet = midlet;
}

public void run() {
//captureVideo();
recordVideo();
}

public void captureVideo() {
try {
byte[] raw = videoControl.getSnapshot(null);
Image image = Image.createImage(raw, 0, raw.length);
form.append(image);
display.setCurrent(form);
player.close();
player = null;
videoControl = null;
} catch (MediaException me) { }
}

public void recordVideo(){
try {
// Create a Player that captures live audio.
//Player p = Manager.createPlayer("capture://audio");
//p.realize();
// Get the RecordControl, set the record stream,
// start the Player and record for 5 seconds.
rc = (RecordControl)player.getControl("RecordControl");
ByteArrayOutputStream output = new ByteArrayOutputStream();
rc.setRecordStream(output);
rc.startRecord();
//player.start();
Thread.currentThread().sleep(5000);
//rc.commit();
//player.close();
} //catch (IOException ioe) {}
//catch (MediaException me) {}
catch (InterruptedException ie) { }
}

public void stopRecord(){
try{
rc.stopRecord();
}catch (Exception e){}
}
}
}
Reply With Quote

#9 Old Re: video capturing using MIDlet - 2006-02-22, 13:53

Join Date: Feb 2006
Posts: 113
pillar
Offline
Regular Contributor
Thanks a lot for the help. Now I got it to work. It is still really simple and all, but at least I know I will get it to work.

Quote:
how can i test if it is acutally recording?
What I did was that after recording I just displayed output.size() value. That gives the size of the outputted video. I would assume that if it's more than zero, you have succeeded. I recorded for couple of seconds and the result was 35689 bytes.

Now I just have to figure out how to save that to the memory/memory card and/or send it through Http. Help anyone? :)
Reply With Quote

#10 Old Re: video capturing using MIDlet - 2006-02-22, 14:51

Join Date: Jun 2005
Posts: 928
dcrocha's Avatar
dcrocha
Offline
Forum Nokia Expert
Hi,

Glad it works. You can use for example

ByteArrayOutputStream output = new ByteArrayOutputStream();
rc.setRecordStream(output);

which you can convert to a byte array and send it via HttpConnection to a servlet or php script.

You can also use the very same code and use the JSR 75 FileConnection API to save the byte array to your local file system.

Daniel
Reply With Quote

#11 Old Re: video capturing using MIDlet - 2006-02-22, 15:17

Join Date: Jan 2006
Posts: 17
bangus
Offline
Registered User
can you send me your codes? :D i just want to take a look at how you're doing it. my output always comes out null... this is my email valgino308@yahoo.com thanx

i tried doing this to test if it has recorded:
if(output == null){
form.append("null!");
display.setCurrent(form);
}

it is always null.. i don't know why


this line throws a NullPointerException:
ByteArrayOutputStream output = new ByteArrayOutputStream();

can't figure out why...
Last edited by bangus : 2006-02-23 at 08:19.
Reply With Quote

#12 Old Re: video capturing using MIDlet - 2006-02-24, 07:31

Join Date: Jan 2006
Posts: 3
emanhossny
Offline
Registered User
salamu alikom
i need to record audio & video at the same time & when i test the code which u sent ,i found that
the value of rc is always =null,plz,help me,i'm new in working with the j2me


Quote:
Originally Posted by bangus
how can i test if it is acutally recording? these are my codes (i apologize for the number of commented out lines):

/*
* IndexMIDlet.java
*
* Created on February 19, 2006, 8:33 PM
*/

package Surveillance;

import java.io.IOException;
import javax.microedition.lcdui.*;
import javax.microedition.media.*;
import javax.microedition.media.control.*;
import javax.microedition.midlet.MIDlet;
import javax.microedition.media.control.VideoControl;
import java.io.*;

/**
*
* @author Viics
* @version
*/
public class IndexMIDlet extends MIDlet implements CommandListener{
//VIDEO MIDLET
private Display display;
private Form form;
private Command exit, record, stopRecord;
private Player player;
private VideoControl videoControl;
private Video video;
private RecordControl recordControl;
private Canvas canvas;

public IndexMIDlet(){
exit = new Command("Exit", Command.EXIT, 0);
record = new Command("Record", Command.ITEM, 0);
stopRecord = new Command("Stop Record", Command.ITEM, 0);

form = new Form("Surveillance");
//form.addCommand(exit);
//form.addCommand(record);
form.setCommandListener(this);
}
public void startApp() {
display = Display.getDisplay(this);
display.setCurrent(form);
showCamera();
}

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}

public void commandAction(Command c, Displayable s){
if (c == exit) {
destroyApp(true);
notifyDestroyed();
}else if (c == record){
video = new Video(this);
video.start();
form.append("Recording...");
}else if (c == stopRecord){
video.stopRecord();
form.append("Stop Recording...");
}
}

public void showCamera() {
try {
player = Manager.createPlayer("capture://video");
player.realize();

videoControl = (VideoControl)player.getControl("VideoControl");
canvas = new VideoCanvas(this, videoControl);
//canvas.addCommand(back);
//canvas.addCommand(capture);
canvas.addCommand(record);
canvas.addCommand(stopRecord);
canvas.addCommand(exit);
canvas.setCommandListener(this);
display.setCurrent(canvas);
player.start();
} catch (IOException ioe) {} catch (MediaException me) {}
}

class Video extends Thread{
IndexMIDlet midlet;
RecordControl rc;

public Video(IndexMIDlet midlet) {
this.midlet = midlet;
}

public void run() {
//captureVideo();
recordVideo();
}

public void captureVideo() {
try {
byte[] raw = videoControl.getSnapshot(null);
Image image = Image.createImage(raw, 0, raw.length);
form.append(image);
display.setCurrent(form);
player.close();
player = null;
videoControl = null;
} catch (MediaException me) { }
}

public void recordVideo(){
try {
// Create a Player that captures live audio.
//Player p = Manager.createPlayer("capture://audio");
//p.realize();
// Get the RecordControl, set the record stream,
// start the Player and record for 5 seconds.
rc = (RecordControl)player.getControl("RecordControl");
ByteArrayOutputStream output = new ByteArrayOutputStream();
rc.setRecordStream(output);
rc.startRecord();
//player.start();
Thread.currentThread().sleep(5000);
//rc.commit();
//player.close();
} //catch (IOException ioe) {}
//catch (MediaException me) {}
catch (InterruptedException ie) { }
}

public void stopRecord(){
try{
rc.stopRecord();
}catch (Exception e){}
}
}
}
Reply With Quote

#13 Old Re: video capturing using MIDlet - 2006-02-24, 10:17

Join Date: Jan 2006
Posts: 17
bangus
Offline
Registered User
that is the problem that i am also having.. pillar got it to work.. can you post your codes pillar? :D
Reply With Quote

#14 Old Re: video capturing using MIDlet - 2006-02-24, 14:15

Join Date: Nov 2005
Posts: 4
zOrrO
Offline
Registered User
Not all phones support video capturing
Reply With Quote

#15 Old Re: video capturing using MIDlet - 2006-02-24, 14:42

Join Date: Jun 2005
Posts: 928
dcrocha's Avatar
dcrocha
Offline
Forum Nokia Expert
It depends on the phones you're testing the code. Not all phones support video capturing...

Daniel
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Midlet and native video player greggiannis Mobile Java General 2 2009-10-22 09:30
bad video capturing thru 6230i kshitijesh Mobile Java Media (Graphics & Sounds) 1 2005-10-05 11:56
MMAPI video in a midlet query greggiannis Mobile Java Media (Graphics & Sounds) 0 2005-09-02 03:15
Video Player Midlet problem - please help L_Tambiah Mobile Java General 0 2004-06-26 16:00
Audio in VIDEO PLAYING in midlet rossottom Mobile Java Media (Graphics & Sounds) 0 2003-05-13 18:08

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d134434X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ