Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unwanted skewing and distorting using ffmpegframerecorder #1143

Closed
Hosseinyzr opened this issue Feb 25, 2019 · 19 comments
Closed

Unwanted skewing and distorting using ffmpegframerecorder #1143

Hosseinyzr opened this issue Feb 25, 2019 · 19 comments
Labels

Comments

@Hosseinyzr
Copy link

I am using ffmpegframerecorder to record Bitamps that converted to Frame Object.
for some Bitmap sizes mostly near to square sizes the out put is skewd... (but for some others there is no problem)
capture

is there any way to solve it?

@Hosseinyzr Hosseinyzr changed the title unwanted skewing and distorting using ffmpegframerecorder Unwanted skewing and distorting using ffmpegframerecorder Feb 25, 2019
@saudet
Copy link
Member

saudet commented Feb 25, 2019 via email

@Hosseinyzr
Copy link
Author

          File file = new File(soundAddress);

            fFmpegSoundFrameGrabber = new FFmpegFrameGrabber(file);
            fFmpegSoundFrameGrabber.setAudioChannels(1);
            fFmpegSoundFrameGrabber.start();


            recorderVideoWithSound = new FFmpegFrameRecorder(ouputFile, outputWidth, outputheight, 1);

            recorderVideoWithSound.setFormat("mp4");
            recorderVideoWithSound.setVideoQuality(1);
            recorderVideoWithSound.setVideoCodec(AV_CODEC_ID_H264);
            recorderVideoWithSound.setPixelFormat(AV_PIX_FMT_YUV420P);
            recorderVideoWithSound.setFrameRate(frameRate);
            recorderVideoWithSound.setAudioCodec(fFmpegSoundFrameGrabber.getAudioCodec());
            recorderVideoWithSound.setSampleFormat(fFmpegSoundFrameGrabber.getSampleFormat());
            recorderVideoWithSound.setSampleRate(fFmpegSoundFrameGrabber.getSampleRate());
            recorderVideoWithSound.setAudioBitrate(fFmpegSoundFrameGrabber.getAudioBitrate());




            recorderVideoWithSound.start();

            Frame frame2;
            int i = 0;
            while ((frame2 = fFmpegSoundFrameGrabber.grabFrame()) != null) {
                recorderVideoWithSound.record(frame2);
                if (recorderVideoWithSound.getTimestamp() <= fFmpegSoundFrameGrabber.getLengthInTime()) {
                    recorderVideoWithSound.record(proccessedFrames[i % proccessedFrames.length]);
                }


                i++;
            }
            recorderVideoWithSound.stop();
            recorderVideoWithSound.release();
            fFmpegSoundFrameGrabber.stop();
            fFmpegSoundFrameGrabber.release();

@saudet
Copy link
Member

saudet commented Feb 25, 2019

How do you create a "proccessedFrames"?

@Hosseinyzr
Copy link
Author

I have some Bitmaps that using this yo convert them:
Frame frame = new AndroidFrameConverter().convert(bitmap);

@saudet
Copy link
Member

saudet commented Feb 25, 2019

Could you explain how to create one of those problematic Bitmap?

@Hosseinyzr
Copy link
Author

I make them by some basic operation like canvas.drawBitmap() and etc...
I have tried to save each bitmap after generating and there was no problem with them.
and I have tried to resize them to 480 pixel width and the record them and the problem solved.
so for example if I record series of bitmap of size: 741 *723 this problem occurs but if I resize them to 480 * 468 , the problem won't occurs .

@Hosseinyzr
Copy link
Author

and also i don't think it is related to AndroidFrameConverter().convert(bitmap) because i tried another test that I convert the Frame result of it to Bitmap again and save it, and i see they have no problem.
I think there is problem with recorder maybe , or its settings...

@saudet
Copy link
Member

saudet commented Feb 25, 2019

Yes, I think it's an issue with AndroidFrameConverter, but I won't be able to solve this unless I am able to reproduce this issue here. You're still not giving me anything to create such a Bitmap.

@Hosseinyzr
Copy link
Author

Aha, but I think the AndroidFrameConverter is doing well.
and maybe when the image size becomes large , the recorder having problem. yes?
I don't know which part to send , there are many classes related to this.
but I tried to save the result bitmap to png and load it , and there was the same problem.
here is that png file
valen

valen.zip

@saudet
Copy link
Member

saudet commented Feb 25, 2019

Thanks! And how do I load this image to cause this issue?

saudet added a commit that referenced this issue Feb 27, 2019
@saudet saudet added the bug label Feb 27, 2019
@saudet
Copy link
Member

saudet commented Feb 27, 2019

In any case, I probably found the cause. This should be fixed with commit 531220d.
Please give it a try with 1.4.5-SNAPSHOT: http://bytedeco.org/builds/

@Hosseinyzr
Copy link
Author

Hello again,
sorry for my latency !
and ok , I will see that snapshot.🙏

@Hosseinyzr
Copy link
Author

I have another issue , and because it maybe related to AndroidFrameConertor so I ask it here or if you want, I will open new Issue:
If the bitmap has black pixels , they turn into blue or green!
here is the output gif. I have tested it for mp4 output and it has also this problem.
image

If I brighter the image the problem will be vanished .

@saudet
Copy link
Member

saudet commented Mar 5, 2019 via email

@Hosseinyzr
Copy link
Author

but It does not have alpha channel..
its was a jpeg image that was loaded...

@saudet
Copy link
Member

saudet commented Mar 5, 2019 via email

@Hosseinyzr
Copy link
Author

so what is the problem with having alpha channel , though the pixels are fully colored.
and it just affect some black pixels although those black pixels are not transparent.
any idea to solve it?

@Hosseinyzr
Copy link
Author

I checked my code, and I fund this problem is not related to your library ... thanks

@saudet
Copy link
Member

saudet commented Apr 11, 2019

The skewing issue with AndroidFrameConverter is now fixed with JavaCV 1.5.
Thanks for reporting and enjoy!

@saudet saudet closed this as completed Apr 11, 2019
yinmingjun pushed a commit to yinmingjun/javacv that referenced this issue May 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants