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

Convert go_router assets to gif #232

Merged
merged 7 commits into from
Dec 21, 2023
Merged

Convert go_router assets to gif #232

merged 7 commits into from
Dec 21, 2023

Conversation

chunhtai
Copy link
Contributor

Also added the feature to output gif

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read the Flutter Style Guide recently, and have followed its advice.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@@ -301,7 +302,10 @@ class DiagramGenerator {
// Almost lossless quality (can't use lossless '0' because Safari
// doesn't support it).
'-crf', '1',
'-c:v', 'libx264', // encode to mp4 H.264
if (metadata.videoFormat == VideoFormat.mp4)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I convert video to GIF, it helps a lot to generate a palette file first so that the palette for the GIF is optimal.

I do this by:

ffmpeg -i "$input" -vf "fps=$fps,scale=$width:-1:flags=lanczos,palettegen" "$palette"

Which generates a temporary palette file in $palette.

Then I supply this to the actual creation of the video:

ffmpeg -i "$input" -i "$palette" -filter_complex "fps=$fps,scale=$width:-1:flags=lanczos[x];[x][1:v]paletteuse" "$output";

The difference is really noticeable (I just converted your mp4 file here):
push_same_shell

You might want to add that as an extra step (to generate the palette).

// This can be useful if one job relies on the product of another job.
// TODO(chunhtai): figure out how to `join` WorkJob[s] so that this iteration
// logic is not needed.
final Map<int, List<WorkerJob>> jobs = <int, List<WorkerJob>>{};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if there is a better way to make one workerJob to wait for another since the ProcessPool runs everything in parallel.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, there's not a good solution to this at the moment. I'll see if I can add something like that to process_runner.

How about this: google/process_runner#35

@@ -65,7 +65,7 @@ void main() {
temporaryDirectory.path,
],
workingDirectory: path.join(
DiagramGenerator.projectDir, 'utils', 'diagram_generator'),
DiagramGenerator.projectDir, 'packages', 'diagram_generator'),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test hasn't been run for a while it seems

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, wow, yeah. Looks like the bin/ tests weren't being run.

Here's a PR for that (and this fix): #234

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already enabled the test in this pr.

Copy link
Contributor

@gspencergoog gspencergoog Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't notice that part. OK. I'll just close my PR.

.github/workflows/test.yml Outdated Show resolved Hide resolved
ci/test Outdated Show resolved Hide resolved
Copy link
Contributor

@gspencergoog gspencergoog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

32384589-a60f0e74-c078-11e7-9bc1-e5b5287aea9d

@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 21, 2023
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Dec 21, 2023
Copy link

auto-submit bot commented Dec 21, 2023

auto label is removed for flutter/assets-for-api-docs/232, Failed to merge flutter/assets-for-api-docs/232 with Pull request flutter/assets-for-api-docs/232 could not be merged: 2 of 2 required status checks are expected..

@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 21, 2023
Copy link

auto-submit bot commented Dec 21, 2023

auto label is removed for flutter/assets-for-api-docs/232, Failed to merge flutter/assets-for-api-docs/232 with Pull request flutter/assets-for-api-docs/232 could not be merged: 2 of 2 required status checks are expected..

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Dec 21, 2023
@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 21, 2023
@auto-submit auto-submit bot merged commit 9599a88 into flutter:main Dec 21, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants