-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
High quality gif with FfmpegFrameRecorder #1112
Comments
Check the logs to make sure the same codec gets used in both cases.
|
You mean grabber and recorder? |
You're not using filters. If you're using the same codecs with the same
settings, the quality will be the same.
|
Ah, I see what you mean, we can't set the palette as part of the settings of the codec, we need to go through filters. Sounds like issue #287. Try to do something similar to what is shown there. |
Thanks, Yes I have seen that issue before, and it get me the idea... But didn't know how exactly do this... |
I thnik palettegen needs the whole video, but we extract frame by frame... |
We don't need to pass the whole video, and there's a single-frame mode too: |
Aha. any body can provide me the sample code to genearte palette? |
No idea? |
Yes, it's possible, make sure you're trying to use the right names for the
input and output, you shouldn't need anything else than "in" and "out".
|
@saudet Ok, I will Try again and report the result. |
I have tried in many ways but no success. one of trys: but it trows this exception: |
I don't think they were meant to be used together like that. In any case, try to follow what the documentation says... |
I don't think it is possible to do this with ffmpegframefilter! I had tried another ways but no success! |
I'm pretty sure it's possible, we just need to spend more time trying things out... It would probably help to check the debug log of FFmpeg. |
How can i get the log of this library? ffmpeg -i StickAround.mp4 -filter_complex "[0:v] palettegen" palette.png I think we should do this in two step, once generating palette and the use it. I have this exception: so what should I do? any other users have any idea? |
@saudet You have written this library and you know it better than me... |
@zhengxuzeng You have tried this before, Do have any Idea? |
Please provide more information, such as the messages that appear on the console. |
I did as You said , and these are results: FFmpegLogCallback.set();
String myPath = G.APPLICATION_DIR + "/aatempPalletteGen.png";
String filterCommand = "";
filterCommand = " palettegen [myout]; [0:v][myout] paletteuse ";
FFmpegFrameFilter paletteFilter = new FFmpegFrameFilter(filterCommand, frames.get(0).getW(), frames.get(0).getH());
try {
paletteFilter.start();
paletteFilter.push(myFrame);
Frame frame = paletteFilter.pull();
paletteFilter.stop();
paletteFilter.release();
FileOutputStream fileOutputStream = new FileOutputStream(new File(myPath));
new AndroidFrameConverter().convert(frame)
.compress(Bitmap.CompressFormat.PNG, 100, fileOutputStream);
} catch (FrameFilter.Exception e) {
Log.e("FrameFilter.Exception ", e.getMessage());
} catch (FileNotFoundException e) {
Log.e("FileNotFoundException ", e.getMessage());
}
Second Try: FFmpegLogCallback.set();
String myPath = G.APPLICATION_DIR + "/aatempPalletteGen.png";
String myPalette = G.APPLICATION_DIR + "/MytempPalletteGen.png";
String filterCommand = "";
filterCommand = " palettegen "+myPalette ;
FFmpegFrameFilter paletteFilter = new FFmpegFrameFilter(filterCommand, frames.get(0).getW(), frames.get(0).getH());
try {
paletteFilter.start();
paletteFilter.push(myFrame);
Frame frame = paletteFilter.pull();
paletteFilter.stop();
paletteFilter.release();
FileOutputStream fileOutputStream = new FileOutputStream(new File(myPath));
new AndroidFrameConverter().convert(frame)
.compress(Bitmap.CompressFormat.PNG, 100, fileOutputStream);
} catch (FrameFilter.Exception e) {
Log.e("FrameFilter.Exception ", e.getMessage());
} catch (FileNotFoundException e) {
Log.e("FileNotFoundException ", e.getMessage());
} //Logs:
|
Do you have a filter command that works with ffmpeg on the command line? If so, try to start by using that! |
I don't understand what you mean? I have tested palletgen in command line and it worked... |
So try to use the same exact command with FFmpegFrameFilter. Don't add any filename or anything. |
this is simple command: |
You're adding filenames and what not to the filter command itself: That won't work! You're not doing that with ffmpeg on the command line, so don't do it with FFmpegFrameFilter either. |
That's the output filename, FFmpegFrameFilter doesn't support that. You'll need to use FFmpegFrameRecorder for that. I already gave you a complete example above. |
Actually, no, I didn't, here are examples: |
Yes, I pointed that does FFmpegFrameFilter can do this filter ? and you said yes ... And I'm currently using FfmpegframeRecorder! Every thing is ok , but the problem is ffmpeg itself needs palettegen and paletuse to generate high quality gifs. and as I found from my searches this is the correct way to make high quality gifs. the pixel format and other things are effective but they aren't sufficient to make the most high quality ones.
I see this now, and I update my javacv and ffmpeg to latest version. thank for your update.but it seems it does'nt help in this case. |
If it doesn't work for you, you're doing something else wrong that is unrelated to your filters. |
what was the clue in here? I don't understand... You mean FrameFilter can perform all of filters?! I really need it man... |
Happy to help, but I won't do everything for you. Start by getting the code from |
Hi,
I'm using FfmpegFrameGrabber and FfmpegFrameRecorder to making Gif.
First I extract Gif frames by grabber and convert them to bitmaps by
Bitmap frameBitmap = new AndroidFrameConverter().convert(frame );
then I do some Edits on Them and convert them to Frame object again. and then make gif of them by recorder.
I have tested different PixelFormat But the quality is still bad.
also set videoquality to 1.
....
from ffmpeg documentation I have found these commands make the Gif with high quality..
ffmpeg -i StickAround.mp4 -filter_complex "[0:v] palettegen" palette.png
ffmpeg -i StickAround.mp4 -i palette.png -filter_complex "[0:v][1:v] paletteuse" prettyStickAround.gif
is it possible to do this?
I know it may be done by FrameFilter but I dont know how...
The text was updated successfully, but these errors were encountered: