shaileshmulange / javacv

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

[Android] Create video from image, Video is green #216

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

I want to create a video from some images

I use this code :

opencv_core.IplImage img = cvLoadImage("/sdcard/folder/img1.jpg");
FFmpegFrameRecorder recorder = new 
FFmpegFrameRecorder("/sdcard/folder/test.mpeg",200,150);

    try {
       recorder.setCodecID( CODEC_ID_MPEG1VIDEO);
       recorder.setFrameRate(30);
       recorder.setPixelFormat(  PIX_FMT_YUV420P);
       recorder.start();

       for (int i=0;i<100;i++)
       {
          recorder.record(image[x]);
       }
       recorder.stop();
    }
    catch (Exception e){
       e.printStackTrace();
    }

What is the expected output? What do you see instead?
It create the video well but it's all green.

What version of the product are you using? On what operating system?
Android 2.3.6

I find an answer on internet "This has been fixed in the latest 
FFmpegFrameRecorder.java" with the link of this class but i don't know how to 
fix my problem.

Any idea ?

Original issue reported on code.google.com by matso...@gmail.com on 13 Jul 2012 at 1:19

GoogleCodeExporter commented 9 years ago
This new FFmpegFrameRecorder class doesn't work?

Original comment by samuel.a...@gmail.com on 13 Jul 2012 at 1:20

GoogleCodeExporter commented 9 years ago
In fact, i don't know how to replace the old one by the new

Could you explain the procedure?

Original comment by matso...@gmail.com on 13 Jul 2012 at 1:23

GoogleCodeExporter commented 9 years ago
Just rename the class to something else and add it to your own project files

Original comment by samuel.a...@gmail.com on 13 Jul 2012 at 1:24

GoogleCodeExporter commented 9 years ago
Ok, so i create a new class in my package named newFFmpegFrameRecord et 
copy/paste the code, but there is a lot of errors like for example 
avformat_new_stream(oc, null); who doesnt exist.

Original comment by matso...@gmail.com on 13 Jul 2012 at 1:58

GoogleCodeExporter commented 9 years ago
Oh, right, try the previous version:
http://javacv.googlecode.com/git-history/5bbb841a1d9b03328ad0c3dbc723ad6903220d6
2/src/main/java/com/googlecode/javacv/FFmpegFrameRecorder.java

Original comment by samuel.a...@gmail.com on 13 Jul 2012 at 2:22

GoogleCodeExporter commented 9 years ago
That's green again. =/

Original comment by matso...@gmail.com on 13 Jul 2012 at 2:33

GoogleCodeExporter commented 9 years ago
Let's see, your imageWidth is not a multiple of 16, that's probably not 
supported by MPEG-1 and the great majority of codecs... 

Original comment by samuel.a...@gmail.com on 13 Jul 2012 at 2:52

GoogleCodeExporter commented 9 years ago
I resize the images and it's works :)

Thank you so much !

Original comment by matso...@gmail.com on 13 Jul 2012 at 3:07

GoogleCodeExporter commented 9 years ago
Great! FYI, I adjusted FFmpegFrameRecorder to have it always round up the 
imageWidth to the next multiple of 16. Let me know if you have any issue with 
JavaCV 0.2, thanks!

Original comment by samuel.a...@gmail.com on 22 Jul 2012 at 12:44

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
cv_loadImage function is not working. I think i need its import file, can any 
one tell me what is its import file? Thanks!

Original comment by whizpool...@gmail.com on 11 Sep 2014 at 5:52

GoogleCodeExporter commented 9 years ago
opencv_core.IplImage img = cvLoadImage("/sdcard/folder/img1.jpg");
FFmpegFrameRecorder recorder = new 
FFmpegFrameRecorder("/sdcard/folder/test.mpeg",200,150);

    try {
       recorder.setCodecID( CODEC_ID_MPEG1VIDEO);
       recorder.setFrameRate(30);
       recorder.setPixelFormat(  PIX_FMT_YUV420P);
       recorder.start();

       for (int i=0;i<100;i++)
       {
       recoder.recode(img);

       }
       recorder.stop();
    }
    catch (Exception e){
       e.printStackTrace();
    }

same but not work fine for me

Original comment by toqeer.g...@gmail.com on 9 Jan 2015 at 11:17