고급 비디오 편집을 위한 플러터 패키지로, 완전히 사용자 정의 가능한 사용자 인터페이스를 제공합니다. 사용자는 비디오를 자르고, 자르고, 회전하며, 사용자 지정 커버를 선택할 수 있어 강력한 미디어 조작 기능이 필요한 앱에 적합합니다. 안드로이드 및 iOS 지원으로 pub.dev를 통해 플러터 프로젝트에 원활하게 통합됩니다. 오픈소스이므로 개발자가 필요에 따라 기능을 확장할 수 있습니다. 직관적인 API는 유연성을 희생하지 않으면서도 복잡한 편집 작업을 간단하게 만듭니다.
사용 사례
소셜 미디어 앱에서의 비디오 자르기
콘텐츠 제작을 위한 사용자 지정 비디오 자르기
비디오에 개인화된 커버 추가
업로드 중에 비디오 회전
동적 비디오 미리보기 만들기
모바일 애플리케이션 내에서 비디오 편집
주요 기능
완전히 사용자 정의 가능한 UI
비디오 자르기, 트리밍 및 회전
커버 이미지 선택 지원
크로스 플랫폼(안드로이드 및 iOS)
오픈소스 코드베이스
Flutter와의 간편한 통합
적합한 대상
비디오 중심 앱을 개발하는 개발자
비디오 편집 기능이 있는 소셜 미디어 플랫폼
콘텐츠 생성 도구
비디오 사전 처리가 필요한 모바일 앱
오픈소스 비디오 솔루션을 원하는 팀
경량 비디오 편집이 필요한 앱
고려 사항
비디오 액세스를 위해 네이티브 플랫폼 권한이 필요합니다
미디어 라이브러리로 인해 앱 크기가 증가할 수 있습니다
사용자 정의 UI 디자인은 추가 개발 노력이 필요합니다
성능은 장치 하드웨어에 따라 달라집니다
기본 편집 기능에 제한됨(필터나 효과 없음)
파일 경로 및 저장소 처리가 적절해야 합니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
Flutter video editor
A video editor that allows to edit (trim, crop, rotate and scale) and choose a cover with a very flexible UI design.
📖 Installation
Following steps will help you add this library as a dependency in your flutter project.
Run flutter pub add video_editor, or add video_editor to pubspec.yaml file manually.
Init the controller parameters, the video, the trim and the cover, call cropAspectRatio
rotate90Degrees(RotateDirection)
Rotate the video by 90 degrees in the direction provided
preferredCropAspectRatio
Update the aspect ratio of the crop area
setPreferredRatioFromCrop
Update the aspect ratio to the current crop area ratio
cropAspectRatio
Update the aspect ratio + update the crop area to the center of the video size
updateCrop
Update the controller crop min and max values
updateTrim
Update the controller trim min and max values
createVideoFFmpegConfig
Creates a VideoFFmpegConfig object that can be used to generate an ffmpeg command via the createExportCommand method
createCoverFFmpegConfig
Creates a CoverFFmpegConfig object that can be used to generate an ffmpeg command via the createExportCommand method
Getter
Description
Duration startTrim
The start value of the trimmed area
Duration endTrim
The end value of the trimmed area
Duration trimmedDuration
The duration of the selected trimmed area
bool isTrimmed
Set to true when the trimmed values are not the default video duration
bool isTrimming
Set to true when startTrim or endTrim is changing
Duration maxDuration
The maxDuration possible for the trimmed area
Duration minDuration
The minDuration possible for the trimmed area
Offset minCrop
The top left position of the crop area (between 0.0 and 1.0)
Offset maxCrop
The bottom right position of the crop area (between 0.0 and 1.0)
Size croppedArea
The actual Size of the crop area
double? preferredCropAspectRatio
The preferred crop aspect ratio selected
bool isRotated
Set to true when the rotation is different to 0
int rotation
The rotation angle set 0, 90, 180 and 270
int cacheRotation
The sum of all the rotation applied in the editor
CoverData? selectedCoverVal
The selected cover thumbnail that will be used to export the final cover
Widgets
Click to expand widgets documentation
Crop
1. CropGridViewer
This widget is used to enable the crop actions on top of the video (CropGridViewer.edit), or only to preview the cropped result (CropGridViewer.preview).
Param
Description
required VideoEditorController controller
The controller param is mandatory so every change in the controller settings will propagate in the crop view
EdgeInsets margin
The amount of space by which to inset the crop view, not used in preview mode
bool rotateCropArea
To preserve preferredCropAspectRatio when crop view is rotated
Trimmer
1. TrimSlider
Display the trimmer containing video thumbnails with rotation and crop parameters.
Param
Description
required VideoEditorController controller
The controller param is mandatory so every change in the controller settings will propagate in the trim slider view
double height = 0.0
The height param specifies the height of the generated thumbnails
double quality = 10
The quality param specifies the quality of the generated thumbnails, from 0 to 100 (more info)
double horizontalMargin = 0.0
The horizontalMargin param specifies the horizontal space to set around the slider. It is important when the trim can be dragged (controller.maxDuration < controller.videoDuration)
Widget? child
The child param can be specify to display a widget below this one (e.g: TrimTimeline)
bool hasHaptic = true
The hasHaptic param specifies if haptic feed back can be triggered when the trim touch an edge (left or right)
double maxViewportRatioo = 2.5
The maxViewportRatio param specifies the upper limit of the view ratio
ScrollController? scrollController
The scrollController param specifies the scroll controller to use for the trim slider view
2. TrimTimeline
Display the video timeline.
Param
Description
required VideoEditorController controller
The controller param is mandatory so depending on the controller.maxDuration, the generated timeline will be different
double quantity = 8
Expected quantity of elements shown in the timeline
EdgeInsets padding = EdgeInsets.zero
The padding param specifies the space surrounding the timeline
String localSeconds = 's'
The String to represents the seconds to show next to each timeline element
TextStyle? textStyle
The TextStyle to use to style the timeline text
Cover
1. CoverSelection
Display a couple of generated covers with rotation and crop parameters to updated the selected cover.
Param
Description
required VideoEditorController controller
The controller param is mandatory so every change in the controller settings will propagate in the cover selection view
double size = 0.0
The size param specifies the max size of the generated thumbnails
double quality = 10
The quality param specifies the quality of the generated thumbnails, from 0 to 100 (more info)
double horizontalMargin = 0.0
The horizontalMargin param need to be specify when there is a margin outside the crop view, so in case of a change the new layout can be computed properly.
int quantity = 5
The quantity param specifies the quantity of thumbnails to generate
Wrap? wrap
The wrap widget to use to customize the thumbnails wrapper
Function? selectedCoverBuilder
To returns how the selected cover should be displayed
2. CoverViewer
Display the selected cover with rotation and crop parameters.
Param
Description
required VideoEditorController controller
The controller param is mandatory so every change in the controller settings will propagate the crop parameters in the cover view
String noCoverText = 'No selection'
The noCoverText param specifies the text to display when selectedCover is null
Style
Click to expand style documentation
1. CropStyle
You can create your own CropStyle class to customize the CropGridViewer appareance.
Param
Description
Color croppingBackground = Colors.black.withOpacity(0.48)
The croppingBackground param specifies the color of the paint area outside the crop area when copping
Color background = Colors.black
The background param specifies the color of the paint area outside the crop area when not copping
double gridLineWidth = 1
The gridLineWidth param specifies the width of the crop lines
Color gridLineColor = Colors.white
The gridLineColor param specifies the color of the crop lines
int gridSize = 3
The gridSize param specifies the quantity of columns and rows in the crop view
Color boundariesColor = Colors.white
The boundariesColor param specifies the color of the crop area's corner
Color selectedBoundariesColor = kDefaultSelectedColor
The selectedBoundariesColor param specifies the color of the selected crop area's corner
double boundariesLength = 20
The boundariesLength param specifies the length of the crop area's corner
double boundariesWidth = 5
The boundariesWidth param specifies the width of the crop area's corner
2. TrimStyle
You can create your own TrimStyle class to customize the TrimSlider appareance.
Param
Description
Color background = Colors.black.withOpacity(0.6)
The background param specifies the color of the paint area outside the trimmed area
Color positionLineColor = Colors.red
The positionLineColor param specifies the color of the line showing the video position
double positionLineWidth = 2
The positionLineWidth param specifies the width of the line showing the video position
Color lineColor = Colors.white
The lineColor param specifies the color of the borders around the trimmed area
Color onTrimmingColor = kDefaultSelectedColor
The onTrimmingColor param specifies the color of the borders around the trimmed area while it is getting trimmed
Color onTrimmedColor = kDefaultSelectedColor
The onTrimmedColor param specifies the color of the borders around the trimmed area when the trimmed parameters are not default values
double lineWidth = 2
The lineWidth param specifies the width of the borders around the trimmed area
TrimSliderEdgesType borderRadius = 5
The borderRadius param specifies the border radius around the trimmer
double edgesType = TrimSliderEdgesType.bar
The edgesType param specifies the style to apply to the edges (left & right) of the trimmer
double edgesSize
The edgesSize param specifies the size of the edges behind the icons
Color iconColor = Colors.black
The iconColor param specifies the color of the icons on the trimmed area's edges
double iconSize = 25
The iconSize param specifies the size of the icon on the trimmed area's edges
IconData? leftIcon = Icons.arrow_left
The leftIcon param specifies the icon to show on the left edge of the trimmed area
IconData? rightIcon = Icons.arrow_right
The rightIcon param specifies the icon to show on the right edge of the trimmed area
3. CoverStyle
You can create your own CoverStyle class to customize the CoverSelection appareance.
Param
Description
Color selectedBorderColor = Colors.white
The selectedBorderColor param specifies the color of the border around the selected cover thumbnail
double borderWidth = 2
The borderWidth param specifies the width of the border around each cover thumbnails
double borderRadius = 5.0
The borderRadius param specifies the border radius of each cover thumbnail
✂ How to export video / cover images?
Since version 3.1.0, you have complete control over the video / cover image export process. The VideoEditorController's new methods, createVideoFFmpegConfig and createCoverFFmpegConfig, allow you to create your own ffmpeg configurations and export commands. This means that you can now choose your preferred ffmpeg library for iOS / Android, such as ffmpeg_kit_flutter_min, ffmpeg_kit_flutter_min_gpl, ffmpeg_kit_flutter_full_gpl, or ffmpeg_kit_flutter_full. For web platforms, you can choose ffmpeg_wasm. Alternatively, you can choose not to include any ffmpeg package to minimize your app's size, and instead delegate the exportation task to a webservice by passing the ffmpeg command to it.
Example of how to run ffmpeg command with the `ffmpeg_kit` / `ffmpeg_wasm` package