selvinEduardo / javacv

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

use AV_PIX_FMT_BGR24 as input format for x264 failed during avcodec_open #369

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

If I set the recorder pixel format to BGR24 as following:
        recorder.setVideoCodec(avcodec.AV_CODEC_ID_H264);
        recorder.setPixelFormat(avutil.AV_PIX_FMT_BGR24);

What is the expected output? What do you see instead?

The codec open fails during following pieces of codec:
        /* open the codec */
        if ((ret = avcodec_open2(video_c, video_codec, options)) < 0) {
            release();
            throw new Exception("avcodec_open2() error " + ret + ": Could not open video codec.");
            }

The return value is -22.

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

version 1.2 on Android, Galaxy Note2.

Please provide any additional information below.

I found x264 encoder could support directly rgb input and the encoding 
performance might be higher than yuv420p input since we could skip the rgb to 
yuv conversion step in ffmpeg.

Original issue reported on code.google.com by hone...@gmail.com on 9 Oct 2013 at 7:57

GoogleCodeExporter commented 9 years ago
I see what the problem is. We need to open the codec named "libx264rgb", but it 
has the same codec ID than the one named "libx264", so we need to open it by 
name. I added new properties to fix that in this revision:
http://code.google.com/p/javacv/source/detail?r=1f7e7fba7f368b3e06c14d128a92a781
e30d268b

Calling the following works for me:
    recorder.setVideoCodecName("libx264rgb");
Let me know if that works you!

BTW, this won't help with encoding performance. AFAIK, it's only useful for 
lossless encoding.

Original comment by samuel.a...@gmail.com on 13 Oct 2013 at 2:27

GoogleCodeExporter commented 9 years ago
Changes included in JavaCV 0.7. Thanks for reporting!

Original comment by samuel.a...@gmail.com on 7 Jan 2014 at 1:09