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

Lossless conversion from an image to a video #2322

Open
Phuc-Hong-Tran opened this issue Mar 8, 2025 · 10 comments
Open

Lossless conversion from an image to a video #2322

Phuc-Hong-Tran opened this issue Mar 8, 2025 · 10 comments

Comments

@Phuc-Hong-Tran
Copy link

I'm trying to convert an image to a video using the following settings:

  recorder.videoCodec = avcodec.AV_CODEC_ID_FFV1
  recorder.pixelFormat = AV_PIX_FMT_RGB24;
  recorder.videoCodecName = "libx264rgb";
  recorder.videoQuality = 0.0;
  recorder.format = "avi"
  recorder.frameRate = 1.0
  recorder.videoBitrate = 2000000

The result came out is blurry and have different colours compare to the original image. The original image is a JPEG with RGB colour format, its size is about 67KB. May anyone suggest why this is the case? Thanks in advance

@saudet
Copy link
Member

saudet commented Mar 8, 2025

Try to increase the quality

@Phuc-Hong-Tran
Copy link
Author

Phuc-Hong-Tran commented Mar 8, 2025

@saudet what attribute(s) can I change to increase the quality, is it the videoQuality?

@Phuc-Hong-Tran
Copy link
Author

Okay, so I just did a comparison between running ffmpeg though javacv and running ffpmeg straight from the command line, the output of the ffmpeg though javacv is worse compared to ffpmeg straight from the command line even though both use the same settings, is there any reason why this is the case?

@saudet
Copy link
Member

saudet commented Mar 8, 2025

You could check the output files with ffprobe to spot the differences

@saudet
Copy link
Member

saudet commented Mar 8, 2025

Also, we can easily accomplish this with the ffmpeg program:
http://bytedeco.org/javacpp-presets/ffmpeg/apidocs/org/bytedeco/ffmpeg/ffmpeg.html

@Phuc-Hong-Tran
Copy link
Author

You could check the output files with ffprobe to spot the differences

Well I just check the sizes of those files and I can see the one from ffpmeg command line is 10 times bigger than the other one

@Phuc-Hong-Tran
Copy link
Author

Also, we can easily accomplish this with the ffmpeg program:
http://bytedeco.org/javacpp-presets/ffmpeg/apidocs/org/bytedeco/ffmpeg/ffmpeg.html

Why can't we achieve the same with ffmpegframerecorder, I thought it is a wrapper around ffmpeg already?

@littlejohnyang
Copy link

You just need to do:
recorder.videoCodec = avcodec.AV_CODEC_ID_FFV1
recorder.videoQuality = 0.0;
recorder.frameRate = 30.0
If you read the source code, videoCodecName might be overwriting your videoCodec setting. You'll need gpl dependencies if using libx264. recorder.format is no longer used I think.

@Phuc-Hong-Tran
Copy link
Author

Yeah I tried that already but it didn't fix the issue, look like it has been the issue with the FrameRecorder for a while already

@littlejohnyang
Copy link

littlejohnyang commented Mar 10, 2025

I just manage to use FrameRecorder to record the desktop screen in FFV1 with the above setting though. I also have preset as ultrafast as video option. So it's definitely working. Not sure why it didn't work for you.
Have you tried to use ffmpeg directly and does it end up with the same result?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants