패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.0.1

ffmpeg_helper

Windows 플랫폼에서 설정을 지원하는 Flutter용 FFmpeg 명령어 도우미.

AndroidiOSmacOSWindowsLinux
30일 다운로드
104
좋아요
27
Pub 점수
140

패키지 설치

flutter pub add ffmpeg_helper

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

ffmpeg_helper는 Flutter 애플리케이션에서 FFmpeg 명령어를 사용하는 것을 간소화하는 Flutter 패키지로, FFmpeg 작업을 실행하기 위한 사용하기 쉬운 인터페이스를 제공합니다. Windows에서 FFmpeg를 설정하는 내장 지원을 포함하여 Android, iOS, macOS, Windows, Linux 등 여러 플랫폼에서 접근 가능합니다. 복잡한 명령줄 상호작용을 간단한 Dart 메서드로 추상화하여, 개발자가 비디오 변환, 자르기, 병합과 같은 멀티미디어 처리 작업을 최소한의 노력으로 수행할 수 있도록 합니다. 외부 서버에 의존하지 않고 디바이스에서 미디어 조작이 필요한 앱에 적합합니다.

사용 사례

  • 비디오 형식 변환
  • 비디오에서 오디오 추출
  • 비디오 자르기 및 병합
  • 기기 내 미디어 처리
  • 크로스 플랫폼 멀티미디어 앱

주요 기능

  • 내장된 Windows 설정 지원
  • 플랫폼에 관계없는 FFmpeg 통합
  • FFmpeg 명령어용 간단한 Dart API
  • Android, iOS, macOS, Windows 및 Linux를 지원합니다
  • 간편한 구성 및 실행

적합한 대상

  • 다중미디어 앱을 개발하는 개발자
  • 기기 내 동영상 편집이 필요한 앱
  • 크로스플랫폼 미디어 처리 도구
  • FFmpeg를 사용한 교육 또는 프로토타이핑 프로젝트
  • 빠른 FFmpeg 통합을 원하는 팀

고려 사항

  • 대상 장치에 적절한 FFmpeg 설치가 필요합니다
  • FFmpeg 바이너리로 인해 앱 크기가 증가할 수 있습니다
  • Windows 설치에는 추가 구성 단계가 필요합니다
  • 기본 사용법을 넘어서는 문서가 제한적
  • 저사양 기기에서의 성능에 미치는 잠재적 영향

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Buy Me A Coffee

ffmpeg_helper

FFmpeg commands helper for flutter with support for setup on windows platform. Create thumbnail and run ffprobe on all platforms except WEB. This uses ffmpeg_kit_flutter_min_gpl package for android/ios/macos Info was taken from ffmpeg_cli and recreated it as that project was stale.

// Initialize in main
  await FFMpegHelper.instance.initialize(); // This is a singleton instance
  // FFMpegHelper ffmpeg = FFMpegHelpe.instance; // use like this
  runApp(const MyApp());
// Command builder
// Use prebuilt args and filters or create custom ones
final FFMpegCommand cliCommand = FFMpegCommand(
  inputs: [
    FFMpegInput.asset(selectedFile!.path),
  ],
  args: [
    const LogLevelArgument(LogLevel.info),
    const OverwriteArgument(),
    const TrimArgument(
      start: Duration(seconds: 0),
      end: Duration(seconds: 10),
    ),
  ],
  filterGraph: FilterGraph(
    chains: [
      FilterChain(
        inputs: [],
        filters: [
          ScaleFilter(
            height: 300,
            width: -2,
          ),
        ],
        outputs: [],
      ),
    ],
  ),
  outputFilepath: path.join(appDocDir.path, "ffmpegtest.mp4"),
);
FFMpegHelperSession session = await ffmpeg.runAsync(
  cliCommand,
  statisticsCallback: (Statistics statistics) {
    print('bitrate: ${statistics.getBitrate()}');
  },
);

Thumbnail creator

// use ffmpeg.getThumbnailFileAsync() to get session
Future<FFMpegHelperSession> getThumbnailFileAsync({
  required String videoPath,
  required Duration fromDuration,
  required String outputPath,
  String? ffmpegPath,
  FilterGraph? filterGraph,
  int qualityPercentage = 100,
  Function(Statistics statistics)? statisticsCallback,
  Function(File? outputFile)? onComplete,
  FFMpegConfigurator? ffMpegConfigurator,
})
// use ffmpeg.getThumbnailFileSync() to get thumbnail file
Future<File?> getThumbnailFileSync({
  required String videoPath,
  required Duration fromDuration,
  required String outputPath,
  String? ffmpegPath,
  FilterGraph? filterGraph,
  int qualityPercentage = 100,
  Function(Statistics statistics)? statisticsCallback,
  Function(File? outputFile)? onComplete,
  FFMpegConfigurator? ffMpegConfigurator,
})

Run FFMpeg and get session so that user can cancel it later.

Future<FFMpegHelperSession> runAsync(
  FFMpegCommand command, {
  Function(Statistics statistics)? statisticsCallback,
  Function(File? outputFile)? onComplete,
  Function(Log)? logCallback,
})

Run FFMpeg as future.

Future<File?> runSync(
  FFMpegCommand command, {
  Function(Statistics statistics)? statisticsCallback,
})

Run ffprobe

Future<MediaInformation?> runProbe(String filePath)

Setup FFMPEG for Linux

sudo apt-get install ffmpeg
OR
sudo snap install ffmpeg
depends on linux distro

Setup FFMPEG for windows

Future<void> downloadFFMpeg() async {
    if (Platform.isWindows) {
      bool success = await ffmpeg.setupFFMpegOnWindows(
        onProgress: (FFMpegProgress progress) {
          downloadProgress.value = progress;
        },
      );
      setState(() {
        ffmpegPresent = success;
      });
    } else if (Platform.isLinux) {
      // show dialog box
      await Dialogs.materialDialog(
          color: Colors.white,
          msg:
              'FFmpeg installation required by user.\nsudo apt-get install ffmpeg\nsudo snap install ffmpeg',
          title: 'Install FFMpeg',
          context: context,
          actions: [
            IconsButton(
              onPressed: () {
                Navigator.of(context).pop();
              },
              text: 'Ok',
              iconData: Icons.done,
              color: Colors.blue,
              textStyle: const TextStyle(color: Colors.white),
              iconColor: Colors.white,
            ),
          ]);
    }
  }
// check setup progress on windows
// On windows if ffmpeg is not present it will download official zip file and extract on doc directory of app.
SizedBox(
  width: 300,
  child: ValueListenableBuilder(
    valueListenable: downloadProgress,
    builder: (BuildContext context, FFMpegProgress value, _) {
      //print(value.downloaded / value.fileSize);
      double? prog;
      if ((value.downloaded != 0) && (value.fileSize != 0)) {
        prog = value.downloaded / value.fileSize;
      } else {
        prog = 0;
      }
      if (value.phase == FFMpegProgressPhase.decompressing) {
        prog = null;
      }
      if (value.phase == FFMpegProgressPhase.inactive) {
        return const SizedBox.shrink();
      }
      return Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          Text(value.phase.name),
          const SizedBox(height: 5),
          LinearProgressIndicator(value: prog),
        ],
      );
    },
  ),
),

카테고리

의존성

의존성 목록 7 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.