johnson-pkt / javacv

Automatically exported from code.google.com/p/javacv
GNU General Public License v2.0
0 stars 0 forks source link

How to use ffmpegframerecoder.java to compress video streams on android? #168

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?
I hope to get a ".mp4" file which can be stored in the sdcard and played on 
android,but what I got is just a file 257 bytes and can't be played.

What version of the product are you using? On what operating system?
javacv+Opencv 2.3.1 android 2.3.4

Please provide any additional information below.
Follow my code:
  @Override
    public synchronized void onPreviewFrame(byte[] data, Camera camera) {
        try {
            mCameraData = data;
            Camera.Size size = camera.getParameters().getPreviewSize();
            cameraWidth = size.width;
            cameraHeight = size.height;
            Log.d(LOG_TAG, "onPreviewFrame - wrote bytes: " + data.length + "; size: " + cameraWidth + " x " + cameraHeight);

            try {
                doRecord(data, size.width, size.height);
                Log.d(LOG_TAG, "start recording");
            } catch (com.googlecode.javacv.FrameRecorder.Exception e) {
                Log.e(LOG_TAG, "record failed");
            }

            Log.d(LOG_TAG, "recording finish");

        } catch (RuntimeException e) {
        // The camera has probably just been released, ignore.
        }

    }
    public void doRecord(byte[] data, int width, int height) throws com.googlecode.javacv.FrameRecorder.Exception {

        if(frame!= null){
             decodeYUV420SP(_temp, data, width, height);//convert YUV to RGB
             frame.getIntBuffer().put(_temp);
        }

        recorder.record(frame);//call the API

    }
Can you help me to solve this problem?Thank you very much!

Original issue reported on code.google.com by fujiaoji...@gmail.com on 7 Mar 2012 at 9:31

GoogleCodeExporter commented 8 years ago
hi,Samuel,
  I forgot to tell you that I successfully wrote the yuv datas into a file,but after I converted them to RGB and tried to write them into a file ,what I got was just an empty file.

Original comment by fujiaoji...@gmail.com on 7 Mar 2012 at 9:39

GoogleCodeExporter commented 8 years ago
I explain bit what needs to be done in issue #160. Let me know if you have 
problem with that, thanks

Original comment by samuel.a...@gmail.com on 7 Mar 2012 at 5:55

GoogleCodeExporter commented 8 years ago
hi,samuel,
 First thanks for your answer.I saw the issue #160 and write the code as what you said.But I still cant get the right package.Can you tell me if  through the following code 
         decodeYUV420SP(_temp, data, width, height);//convert yuv to rgb
         frame.getIntBuffer().put(_temp); 
         recorder.record(frame);
I can get the continually data and compress them into the wanted format?

Original comment by fujiaoji...@gmail.com on 8 Mar 2012 at 2:51

GoogleCodeExporter commented 8 years ago
That looks alright, assuming there are no other problems in the rest of your 
code, such as using an incorrect type of IplImage frame object.

Please post your questions on the mailing list if possible, thank you!

Original comment by samuel.a...@gmail.com on 8 Mar 2012 at 3:02