-
Notifications
You must be signed in to change notification settings - Fork 0
feat(thumb): add stream_thumbnail plugin #133
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8e98f8d
feat: add stream_video_thumbnail plugin
xsahil03x 1ad662f
ci: wire stream_video_thumbnail into PR-title scope and coverage
xsahil03x 3f9bb55
fix: address PR review feedback for stream_video_thumbnail
xsahil03x b0fbafb
refactor: rename package stream_video_thumbnail to stream_thumbnail
xsahil03x 2c93154
chore(thumb): retain original upstream MIT copyright in LICENSE
xsahil03x 30c7bcf
chore(thumb): rename and tidy the example app
xsahil03x b7acd2e
fix(thumb): iOS main-thread results + thumbnailFile contract, Android…
xsahil03x ef5b25a
perf(thumb): fix resource retention across the plugin
xsahil03x File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ## 0.0.1 | ||
|
|
||
| * Initial release. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) 2026 STREAM.IO, INC. | ||
| Copyright (c) 2019 John Zhong | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| # Stream Thumbnail | ||
|
|
||
| ## Introduction | ||
|
|
||
| A Flutter plugin for creating a thumbnail image from a video. Give it a local file path or a video URL and it returns the thumbnail as bytes or as a saved image file. Works on Android, iOS, and web. | ||
|
|
||
| ## Installation | ||
|
|
||
| Add the following to your `pubspec.yaml` and replace `[version]` with the latest version: | ||
|
|
||
| ```yaml | ||
| dependencies: | ||
| stream_thumbnail: ^[version] | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ```dart | ||
| import 'package:stream_thumbnail/stream_thumbnail.dart'; | ||
| ``` | ||
|
|
||
| ### Bytes | ||
|
|
||
| Get the thumbnail as in-memory bytes — ideal for `Image.memory`: | ||
|
|
||
| ```dart | ||
| final bytes = await StreamThumbnail.thumbnailData( | ||
| video: 'https://example.com/video.mp4', | ||
| imageFormat: StreamThumbnailFormat.jpeg, | ||
| maxWidth: 128, // 0 keeps the source resolution | ||
| quality: 25, | ||
| ); | ||
| ``` | ||
|
|
||
| ### File | ||
|
|
||
| Write the thumbnail to disk and get back an `XFile`. If `thumbnailPath` is omitted, the | ||
| image is saved next to the video (or in the cache directory for remote videos): | ||
|
|
||
| ```dart | ||
| final thumbnail = await StreamThumbnail.thumbnailFile( | ||
| video: '/path/to/video.mp4', | ||
| imageFormat: StreamThumbnailFormat.png, | ||
| maxHeight: 200, | ||
| ); | ||
| ``` | ||
|
|
||
| ### Multiple files | ||
|
|
||
| Generate thumbnails for several videos in one call: | ||
|
|
||
| ```dart | ||
| final thumbnails = await StreamThumbnail.thumbnailFiles( | ||
| videos: ['/path/to/a.mp4', '/path/to/b.mp4'], | ||
| ); | ||
| ``` | ||
|
|
||
| ## Options | ||
|
|
||
| Every method accepts the same options: | ||
|
|
||
| | Option | Description | | ||
| | --------------- | ------------------------------------------------------------------------------- | | ||
| | `video`(s) | Path to a local video file or a video URL. | | ||
| | `headers` | HTTP headers sent when fetching a remote video. | | ||
| | `thumbnailPath` | Output path (file variants only). Defaults to the video's folder or cache dir. | | ||
| | `imageFormat` | `JPEG`, `PNG`, or `WEBP`. Defaults to `PNG`. WebP on iOS is backed by `libwebp`.| | ||
| | `maxHeight` / `maxWidth` | Max size in pixels, or `0` to keep the source resolution. | | ||
| | `timeMs` | Capture position in milliseconds. | | ||
| | `quality` | Output quality, `0`–`100` (ignored for PNG). | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| buildscript { | ||
| val kotlinVersion = "2.2.20" | ||
| repositories { | ||
| google() | ||
| mavenCentral() | ||
| } | ||
|
|
||
| dependencies { | ||
| classpath("com.android.tools.build:gradle:8.11.1") | ||
| classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") | ||
| } | ||
| } | ||
|
|
||
| plugins { | ||
| id("com.android.library") | ||
| } | ||
|
|
||
| group = "io.getstream.stream_thumbnail" | ||
| version = "1.0-SNAPSHOT" | ||
|
|
||
| allprojects { | ||
| repositories { | ||
| google() | ||
| mavenCentral() | ||
| } | ||
| } | ||
|
|
||
| android { | ||
| namespace = "io.getstream.stream_thumbnail" | ||
| compileSdk = 36 | ||
|
|
||
| compileOptions { | ||
| sourceCompatibility = JavaVersion.VERSION_11 | ||
| targetCompatibility = JavaVersion.VERSION_11 | ||
| } | ||
|
|
||
| sourceSets { | ||
| getByName("main") { | ||
| java.srcDirs("src/main/kotlin") | ||
| } | ||
| } | ||
|
|
||
| defaultConfig { | ||
| minSdk = 24 | ||
| } | ||
|
|
||
| lint { | ||
| disable.add("InvalidPackage") | ||
| } | ||
| } | ||
|
|
||
| kotlin { | ||
| compilerOptions { | ||
| jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11 | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| org.gradle.jvmargs=-Xmx1536M |
5 changes: 5 additions & 0 deletions
5
packages/stream_thumbnail/android/gradle/wrapper/gradle-wrapper.properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| distributionBase=GRADLE_USER_HOME | ||
| distributionPath=wrapper/dists | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip | ||
| zipStoreBase=GRADLE_USER_HOME | ||
| zipStorePath=wrapper/dists |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| rootProject.name = "stream_thumbnail" |
3 changes: 3 additions & 0 deletions
3
packages/stream_thumbnail/android/src/main/AndroidManifest.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
| package="io.getstream.stream_thumbnail"> | ||
| </manifest> | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.