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

Java Development

Reply
Developer
zac_mathews
Posts: 31
Registered: ‎08-07-2008
My Device: Not Specified
Accepted Solution

How to Record Video and Audio in to a single file just like Default BB Video Recorder ?

[ Edited ]

Hi

Is there any way to record audio and video into a single file using ..  Something like Default Video Recorder. My purpose is to stream this recording to server using SocketConnection. I successfully streamed video but it does not contain any audio....

Manager.createPlayer("capture://video?"+<encoding goes here>);

 

 

 

I was going thru other post and didn't found anything.

Is it possiable to record audio & video with single player instance???...

I tried  following encoding

 

  1. encoding=video/3gpp&mode=standard
  2. encoding=video/3gpp&mode=mms
  3. encoding=video/3gpp&width=480&height=352&video_codec=MPEG-4&audio_codec=AMR
  4. encoding=video/3gpp&width=176&height=144&video_codec=MPEG-4&audio_codec=AMR
  5. encoding=video/3gpp&width=480&height=352&video_codec=H263&audio_codec=AMR
  6. encoding=video/3gpp&width=176&height=144&video_codec=H263&audio_codec=AMR

unfortunately none of them have Audio content.... 

How can i record Video & Audio using single Player instance???? is it possiable??...

(I am able to convert 1st encoding raw file to .3gp file using YouTube downloader)

Please Help....

Thanks in Advance...

Please use plain text.
Developer
zac_mathews
Posts: 31
Registered: ‎08-07-2008
My Device: Not Specified

Re: How to Record Video and Audio in to a single file just like Default BB Video Recorder ?

:smileysad:

*** DOES BLACKBERRY ALLOW TO RECORD VIDEO AND AUDIO AT SAMETIME USING MMAPI ***

 

    Is there anybody from BlackBerry or anybody who knows how to record audio and video just like Default BlackBerry Video recorder.

 

All i want to do is instead of saving recorded file on device i want to save it to server. So i cannot use default BB Video Recorder..

 

 ** I have succecssfully SAVED raw video OR audio file on server. My problem is i am not able to record Video & audio at same time.... :smileysad: ...

 

 

I am using Storm 9550 Simulator (basically OS ver 5.0 simulators).

 

:smileysad: Please Help....

 

 

Please use plain text.
Developer
rcmaniac25
Posts: 1,804
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.2174, Z10 (STL100-3)-10.3.0.700 Dev OS, Z30 (STA100-5)-10.3.0.700 Dev OS, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: How to Record Video and Audio in to a single file just like Default BB Video Recorder ?

Yes it does. I usually just do #1 but I don't know how it works on the Simulator.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.
Developer
zac_mathews
Posts: 31
Registered: ‎08-07-2008
My Device: Not Specified

Re: How to Record Video and Audio in to a single file just like Default BB Video Recorder ?

Thanks rcmaniac25 for your reply....

 

After few more research... I found that all the time Audio was infact recording with video....

 

All the time i was trying to open these files on PC and converting it to 3gp using YouTube downloader:smileymad:... Then at last i decided to open it in Default BB Media Player and both audio and video is working fne :smileyvery-happy: .,... Thank God....

 

 

Please use plain text.
Super Contributor
lyon819
Posts: 253
Registered: ‎08-19-2010
My Device: BB10, Playbook, 9900, 9800, 9700, 9550, 9530, 9500, 8700.
My Carrier: TT

Re: How to Record Video and Audio in to a single file just like Default BB Video Recorder ?

1. format memory.

or

2. Plug out battery and reboot.

or

3. restore previous files.

 

These method should solve the problem.

 

 

-Fight with BB10
Please use plain text.
Super Contributor
lyon819
Posts: 253
Registered: ‎08-19-2010
My Device: BB10, Playbook, 9900, 9800, 9700, 9550, 9530, 9500, 8700.
My Carrier: TT

Re: How to Record Video and Audio in to a single file just like Default BB Video Recorder ?

The code is below, but no sound......?? Only video image....

 

private static final String STREAM_VIDEO_FILE = "file:///SDCard/BlackBerry/videos/bb2_final_1.sbv";//not sure 3 gp to sbv??
    String _encoding = "encoding=video/3gpp&mode=standard";

        private static Player _player;
        private static VideoControl _vc;
        private RecordControl _rc;
//        private static boolean _visible = true;
        private static boolean _locationSet = false;
//        private static RichTextField _status;
        private static OutputStream _out;
        private static FileConnection _fc;

        public VideoTime videoThread=new VideoTime();

        /*
         * constructor passed the chosen video encoding property value
         */
        public VideoRecordingApplication()
        {

            try {
                /*
                 * create a video media player to capture video using the passed encoding value
                 */
                _player = javax.microedition.media.Manager.createPlayer( "capture://video?" + _encoding );

                /*
                 * try to start the player
                 */
                _player.start();

                _vc = (VideoControl)_player.getControl( "VideoControl" );

                _rc = (RecordControl)_player.getControl( "RecordControl" );

                /*
                 * Initialize the mode on how the video is displayed.
                 * This method must be called before the video can be displayed.
                 *
                 * USE_GUI_PRIMITIVE defines a mode on how the GUI is displayed.
                 * It is used in conjunction with initDisplayMode(int, java.lang.Object).
                 */
                final Field videoField = (Field)_vc.initDisplayMode( VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field" );

                /*
                 * add field to this screen's manager
                 */
                add( videoField );

//                _status = new RichTextField( "Idle" );
//                add( _status );
                
            } catch ( final Exception e ) {
                System.out.println( "Exception in VideoScreen constructor" );
            }

            addMenuItem( new MenuItem( "Start Record", 0, 0 )
            {
                public void run() {
                startThread();
                }

            } );
            
            

/*            addMenuItem( new MenuItem( "Stop Record", 0, 0 )
            {
                public void run()
                {
                    stopRecord();
                }
            } );
*/

            addMenuItem( new MenuItem( "Commit Record", 0, 0 )
            {
                public void run()
                {
                    commit();
                }
            } );



        }
        
        public void startThread(){
            videoThread.start();
            
        }
        
        public class VideoTime extends Thread {
            boolean takingVideo;
            
            public VideoTime(){
                takingVideo=true;

            }
            public void run()
            {
                while (takingVideo){
                startRecord();
                stopRecord();
                
                }
            }
            
            public void stopTakingVideo(){
                takingVideo=false;
                
            }
        }

        /*
         * decipher and act upon shortcut keys
         */
        protected boolean keyChar( char c, int status, int time )
        {
            switch( c ) {
                case 's':
                    startRecord();
                    return true;
                case 'x':
                    stopRecord();
                    return true;
                case 'c':
                    commit();
                    return true;

                default:
                    return false;
            }
        }

        /*
         * record captured video
         */
        private void startRecord()
        {
            try {
                /*
                 * _locationSet == false by default
                 */
                if( !_locationSet )
                {
                    /*
                     * test if "Use OutputStream" CheckboxField is set
                     */
                        try {
                            _fc = (FileConnection)Connector.open( STREAM_VIDEO_FILE );

                            /*
                             * create streaming file if it does not exist
                             */
                            if( !_fc.exists() )
                            {
                                _fc.create();
                            }

                            /*
                             * zap the file
                             */
                            _fc.truncate( 0 );

                            /*
                             * ready to write video stream
                             */
                            _out = _fc.openOutputStream();
                        } catch ( Exception e ) {
                            return;
                        }

                        _rc.setRecordStream( _out );


                    _locationSet = true;
                }

                /*
                 * Start recording the media.
                 */
                _rc.startRecord();
//                _status.setText( "Recording" );
                Thread.sleep(4000);

            } catch ( Exception e ) {
            }
            

        }

        private void stopRecord()
        {
            try {
                /*
                 * Stop recording the media.
                 * stopRecord will not automatically stop the Player.
                 * It only stops the recording, putting the Player in "standby" mode
                 */
                _rc.stopRecord();
                Thread.sleep(10000);

//                _status.setText( "Recording stopped" );
            } catch ( Exception e ) {
            }
        }

        private void commit()
        {
            videoThread.stopTakingVideo();
            try {
                /*
                 * Complete the current recording.
                 * If the recording is in progress, commit will implicitly call stopRecord.
                 */
                
                _rc.commit();

//                Dialog.alert( "Committed" );
                _locationSet = false;
//                _status.setText( "Committed" );

                /*
                 * video stream was recorded
                 */

                    /*
                     * close the stream
                     */
                    try {
                        _out.close();
                        _fc.close();
                    } catch ( Exception e ) {
                    }

            } catch ( Exception e ) {
            }
        }

    }

-Fight with BB10
Please use plain text.
Super Contributor
lyon819
Posts: 253
Registered: ‎08-19-2010
My Device: BB10, Playbook, 9900, 9800, 9700, 9550, 9530, 9500, 8700.
My Carrier: TT

Re: How to Record Video and Audio in to a single file just like Default BB Video Recorder ?

Could you show your code to us??

-Fight with BB10
Please use plain text.
Developer
rcmaniac25
Posts: 1,804
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.2174, Z10 (STL100-3)-10.3.0.700 Dev OS, Z30 (STA100-5)-10.3.0.700 Dev OS, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: How to Record Video and Audio in to a single file just like Default BB Video Recorder ?

@lyon819: Start a new thread since this one has been solved already.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.