Recherche avancée

Médias (2)

Mot : - Tags -/documentation

Autres articles (51)

Sur d’autres sites (8296)

  • Flutter Animated Thumbnails

    2 septembre 2020, par user433575

    I'm using the camera package to record videos and want to have animated thumbnails. I don't see any packages other than ffmpeg which might be able to do it but I'm stuck.

    


    I need to capture videos using the camera package, save them to mp4 and generate webp animated images from it. Any help or suggestions greatly appreciated.

    


    Here's some of my code :

    


        static Future<string> getThumb(videoPath, width, height) async {&#xA;assert(File(videoPath).existsSync());&#xA;&#xA;final String outPath = &#x27;$videoPath.webp&#x27;;&#xA;final arguments =&#xA;    &#x27;-y -i $videoPath -vcodec webp -loop 0 -pix_fmt yuv420p $outPath&#x27;;&#xA;&#xA;    &#xA;final int rc = await _encoder.execute(arguments);&#xA;assert(rc == 0);&#xA;assert(File(outPath).existsSync());&#xA;&#xA;return outPath;&#xA;</string>

    &#xA;

    }

    &#xA;

    Thanks

    &#xA;

  • Trying to merge two videos from my photo roll with Flutter ffmpeg without success

    4 avril 2023, par Stéphane de Luca

    My goal is to merge too video I pick from my photo roll.&#xA;My code starts as follows :

    &#xA;

    // videos[0] contains: "content://media/external/video/media/2779"&#xA; final v1 = await videos[0].getMediaUrl();&#xA;    if (v1 == null) return;&#xA;    final v1Path = await LecleFlutterAbsolutePath.getAbsolutePath(uri: v1);&#xA;

    &#xA;

    But printing v1Pathgive a path with jpeg extension :&#xA;/data/user/0/com.example.shokaze/cache/OutputFile_1669939088711.jpeg&#x27; which I though would have bear mp4` as it is a video.

    &#xA;

    Why is it so ?

    &#xA;

    Another question I have is how can I make a relevant path so that the ffmpeg video appears in my roll after its creation ? Should I do the following and provide outputPathto the code ?

    &#xA;

    The command it executes is :&#xA;-i /data/user/0/com.example.shokaze/cache/OutputFile_1669940421875.jpeg -i /data/user/0/com.example.shokaze/cache/OutputFile_1669940428723.jpeg -filter_complex &#x27;[0:0][1:0]concat=n=2:v=1:a=0[out]&#x27; -map &#x27;[out]&#x27; /data/user/0/com.example.shokaze/app_flutter/output.mp4

    &#xA;

    And I get an error :&#xA;I/flutter (30190): error 1

    &#xA;

    My code is as follows :

    &#xA;

        String output = "content://media/external/video/media/output";&#xA;    final outputPath = await LecleFlutterAbsolutePath.getAbsolutePath(uri: output);&#xA;    if (outputPath == null) return;&#xA;

    &#xA;

    The full code is as follows :

    &#xA;

    // Makes the final video by merging all videos from the mixing table&#xA;  void makeFinalVideo() async {&#xA;    if (videos.length &lt; 2) return;&#xA;&#xA;    final v1 = await videos[0].getMediaUrl();&#xA;    if (v1 == null) return;&#xA;    final v1Path = await LecleFlutterAbsolutePath.getAbsolutePath(uri: v1);&#xA;    if (v1Path == null) return;&#xA;    //String v1 = "";&#xA;    final v2 = await videos[1].getMediaUrl();&#xA;    if (v2 == null) return;&#xA;    final v2Path = await LecleFlutterAbsolutePath.getAbsolutePath(uri: v2);&#xA;    if (v2Path == null) return;&#xA;    String output = "content://media/external/video/media/output";&#xA;    final outputPath = "";&#xA;    // await LecleFlutterAbsolutePath.getAbsolutePath(uri: output);&#xA;    // if (outputPath == null) return;&#xA;&#xA;    Video.merge(v1Path, v2Path, outputPath);&#xA;  }&#xA;&#xA;&#xA;&#xA;class Video {&#xA;  /// Merges the video [v1] with [v2] as [output] video located in app doc path&#xA;  static void merge(String v1, String v2, String output) async {&#xA;    final appDocDir = await getApplicationDocumentsDirectory();&#xA;&#xA;    //final appDir = await syspaths.getApplicationDocumentsDirectory();&#xA;    String rawDocumentPath = appDocDir.path;&#xA;    final outputPath = &#x27;$rawDocumentPath/output.mp4&#x27;;&#xA;&#xA;    final command =&#xA;        &#x27;-i $v1 -i $v2 -filter_complex \&#x27;[0:0][1:0]concat=n=2:v=1:a=0[out]\&#x27; -map \&#x27;[out]\&#x27; $outputPath&#x27;;&#xA;    //await execute(command);&#xA;    try {&#xA;      final r = await FFmpegKit.execute(command);&#xA;&#xA;      //.then((rc) => print("FFmpeg process exited with rc $rc"));&#xA;      print("Result: $r");&#xA;    } catch (e) {&#xA;      print("Exception: $e");&#xA;    }&#xA;  }&#xA;}&#xA;

    &#xA;

  • ffmpeg boxblur filter takes too long

    12 juin 2020, par Prashant_Sarin

    I am using below command to blur a video but it is very slow. Can anyone please help if i can improve the speed somehow.

    &#xA;&#xA;

    "ffmpeg -i $inputPath -lavfi [0:v]split=2[original][copy];[copy]scale=ih*16/9:-1,crop=h=iw*9/16,boxblur=luma_radius=50:chroma_radius=25:luma_power=2[blurred];[blurred][original]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2[final] -map [final] -map a:0 -g 2 -preset ultrafast $outputPath -y"&#xA;

    &#xA;