Recherche avancée

Médias (1)

Mot : - Tags -/MediaSPIP 0.2

Autres articles (8)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

  • Formulaire personnalisable

    21 juin 2013, par

    Cette page présente les champs disponibles dans le formulaire de publication d’un média et il indique les différents champs qu’on peut ajouter. Formulaire de création d’un Media
    Dans le cas d’un document de type média, les champs proposés par défaut sont : Texte Activer/Désactiver le forum ( on peut désactiver l’invite au commentaire pour chaque article ) Licence Ajout/suppression d’auteurs Tags
    On peut modifier ce formulaire dans la partie :
    Administration > Configuration des masques de formulaire. (...)

  • Ecrire une actualité

    21 juin 2013, par

    Présentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
    Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
    Vous pouvez personnaliser le formulaire de création d’une actualité.
    Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)

Sur d’autres sites (2042)

  • Cutting whatsapp shared videos using FFMPEG

    2 août 2015, par Bhuvnesh Varma

    I am using hiteshsondhi88/ffmpeg-android library to time or cut videos.I have added below dependency.

    compile 'com.github.hiteshsondhi88.libffmpeg:FFmpegAndroid:0.2.5'

    I am using below command

    execFFmpegCommand("-i " + path + " -ss " + startMs / 1000 + " -to " + endMs / 1000 + " -strict -2 -async 1 " + dest.getAbsolutePath());

    to cut or trim videos.

    private void execFFmpegCommand(final String command) {
           try {
               ffmpeg.execute(command, new ExecuteBinaryResponseHandler() {
                   @Override
                   public void onFailure(String s) {
                       Log.e("Preview", "FAILED with output : " + s);
                   }

                   @Override
                   public void onSuccess(String s) {
                       Log.e("Preview", "SUCCESS with output : " + s);
                   }

                   @Override
                   public void onProgress(String s) {
                       Log.e("Preview", "Started command : ffmpeg " + command);
                       Log.e("Preview", "progress : " + s);
                   }

                   @Override
                   public void onStart() {
                       Log.e("Preview", "Started command : ffmpeg " + command);

                   }

                   @Override
                   public void onFinish() {
                       Log.e("Preview", "Finished command : ffmpeg " + command);



                   }
               });
           } catch (FFmpegCommandAlreadyRunningException e) {
               // do nothing for now
           }
       }

    Its working for most videos but for some videos its NOT working especially for videos that are shared from whatssapp.It gives below error..I am using Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_MOVIES ) for storage of videos.

    FAILED with output : WARNING: linker: files/ffmpeg has text relocations. This is wasting memory and prevents security hardening. Please fix.
       ffmpeg version n2.4.2 Copyright (c) 2000-2014 the FFmpeg developers
       built on Oct  7 2014 15:11:41 with gcc 4.8 (GCC)
       configuration: --target-os=linux --cross-prefix=/home/sb/Source-Code/ffmpeg-android/toolchain-android/bin/i686-linux-android- --arch=x86 --cpu=i686 --enable-runtime-cpudetect --sysroot=/home/sb/Source-Code/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/sb/Source-Code/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/sb/Source-Code/ffmpeg-android/build/x86 --extra-cflags='-I/home/sb/Source-Code/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all -march=i686' --extra-ldflags='-L/home/sb/Source-Code/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=
       libavutil      54.  7.100 / 54.  7.100
       libavcodec     56.  1.100 / 56.  1.100
       libavformat    56.  4.101 / 56.  4.101
       libavdevice    56.  0.100 / 56.  0.100
       libavfilter     5.  1.100 /  5.  1.100
       libswscale      3.  0.100 /  3.  0.100
       libswresample   1.  1.100 /  1.  1.100
       libpostproc    53.  0.100 / 53.  0.100
       /storage/emulated/0/1: No such file or directory
  • Fast video compression like Whatsapp

    5 août 2015, par Douglas Anunciação

    I need to speed up video compression in my Android app. I’m using FFMPEG and it takes 3 minutes to compress 80MB video. Does anyone knows a better solution ?

    The command I’m using is :

    /data/data/com.moymer/app_bin/ffmpeg -y -i /storage/emulated/0/DCIM/Camera/VID_20150803_164811363.mp4 -s 640x352 -r 25 -vcodec mpeg4 -ac 1 -preset ultrafast -strict -2 /storage/emulated/0/DCIM/Camera/compressed_video.mp4

    I’m running this command using FFMPEG for Android from this github repo : https://github.com/guardianproject/android-ffmpeg-java

    The code to use FFMPEG in my project is inside an AsyncTask and is copied below :

       @Override
       protected Object doInBackground(Object... params) {

           ItemRoloDeCamera compressedVideo = new ItemRoloDeCamera();

           File videoInputFile = new File(video.getSdcardPath());

           File videoFolderFile = videoInputFile.getParentFile();

           File videoOutputFile = new File(videoFolderFile, "video_comprimido_moymer.mp4");

           if (videoFolderFile.exists())
               android.util.Log.e("COMPRESS VIDEO UTILS", "video folder exist");
           else
               android.util.Log.e("COMPRESS VIDEO UTILS", "video folder DON'T exist");

           if (videoInputFile.exists())
               android.util.Log.e("COMPRESS VIDEO UTILS", "video input file exist");
           else
               android.util.Log.e("COMPRESS VIDEO UTILS", "video input file DON'T exist");

           if (videoOutputFile.exists())
               android.util.Log.e("COMPRESS VIDEO UTILS", "video output file exist");
           else
               android.util.Log.e("COMPRESS VIDEO UTILS", "video output file DON'T exist");

           FfmpegController ffmpegController;

           try {

               ffmpegController = new FfmpegController(context, videoFolderFile);

               Clip clipIn = new Clip(videoInputFile.getAbsolutePath());

               ffmpegController.getInfo(clipIn, new ShellUtils.ShellCallback() {
                   @Override
                   public void shellOut(String shellLine) {
                       videoInfo.add(shellLine);
                   }

                   @Override
                   public void processComplete(int exitValue) {
                       videoInfo.add(String.valueOf(exitValue));
                   }
               });

               int rotate = getRotateMetadata();

               Clip clipOut = new Clip(videoOutputFile.getAbsolutePath());
               clipOut.videoFps = "24";
               clipOut.videoBitrate = 512;
               clipOut.audioChannels = 1;
               clipOut.width = 640;
               clipOut.height = 352;

               if (rotate == 90)
                   clipOut.videoFilter = "transpose=1";
               else if (rotate == 180)
                   clipOut.videoFilter = "transpose=1,transpose=1";
               else if (rotate == 270)
                   clipOut.videoFilter = "transpose=1,transpose=1,transpose=1";

               millisDuration = getVideoDuration(videoInputFile.getAbsolutePath());

               float secondsDuration = millisDuration / 1000f;

               clipOut.duration = secondsDuration;

               ffmpegController.processVideo(clipIn, clipOut, true, new ShellUtils.ShellCallback() {
                   @Override
                   public void shellOut(String shellLine) {

                       android.util.Log.e("COMPRESS VIDEO UTILS", "shellOut - " + shellLine);

                       float percentage = getTimeMetadata(shellLine);

                       if (percentage >= 0f)
                           publishProgress(percentage);

                   }

                   @Override
                   public void processComplete(int exitValue) {
                       android.util.Log.e("COMPRESS VIDEO UTILS", "proccess complete - " + exitValue);
                   }
               });


           } catch (IOException e) {
               e.printStackTrace();
           } catch (Exception e) {
               e.printStackTrace();
           } finally {

               if (videoOutputFile.exists()) {

                   android.util.Log.e("COMPRESS VIDEO UTILS", "finished ffmpeg ---> video output file exist");

                   compressedVideo.setSdcardPath(videoOutputFile.getAbsolutePath());

                   return compressedVideo;

               } else
                   android.util.Log.e("COMPRESS VIDEO UTILS", "finished ffmpeg ---> video output file DON'T exist");

           }

           return compressedVideo;

       }

       private float getTimeMetadata(String shellLine) {

           float percentage = -1;

           if (shellLine.contains("time=")) {

               String[] timeLine = shellLine.split("=");

               String time = timeLine[5];
               time = time.replace("bitrate", "");
               time = time.trim();

    //            String source = "00:10:17";
               String[] tokens = time.split(":");
               int secondsToMs = (int) (Float.parseFloat(tokens[2]) * 1000);
               int minutesToMs = Integer.parseInt(tokens[1]) * 60000;
               int hoursToMs = Integer.parseInt(tokens[0]) * 3600000;
               long timeInMillis = secondsToMs + minutesToMs + hoursToMs;

               percentage = (timeInMillis * 100.0f) / millisDuration;

           }

           return percentage;

       }

       private int getRotateMetadata() {

           int rotate = 0;

           String durationString = "";

           for (String shellLine : videoInfo) {

               if (shellLine.contains("rotate")) {

                   //rotate          : 270

                   String[] rotateLine = shellLine.split(":");

                   rotate = Integer.parseInt(rotateLine[1].trim());

               }

           }

           return rotate;

       }

       public static long getVideoDuration(String videoPath) {

           MediaMetadataRetriever retriever = new MediaMetadataRetriever();

           retriever.setDataSource(videoPath);

           String time = retriever
                   .extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);

           long timeInmillisec = Long.parseLong(time);

           return timeInmillisec;

       }

    The only change I made in the processVideo method was to add the following lines when building the commmand :

    cmd.add("-preset");
    cmd.add("ultrafast");
  • Fast video compression like Whatsapp

    11 juin 2021, par Douglas Anunciação

    I need to speed up video compression in my Android app. I'm using FFMPEG and it takes 3 minutes to compress 80MB video. Does anyone knows a better solution ?

    



    The command I'm using is :

    



    /data/data/com.moymer/app_bin/ffmpeg -y -i /storage/emulated/0/DCIM/Camera/VID_20150803_164811363.mp4 -s 640x352 -r 25 -vcodec mpeg4 -ac 1 -preset ultrafast -strict -2 /storage/emulated/0/DCIM/Camera/compressed_video.mp4


    



    I'm running this command using FFMPEG for Android from this github repo : https://github.com/guardianproject/android-ffmpeg-java

    



    The code to use FFMPEG in my project is inside an AsyncTask and is copied below :

    



    @Override
protected Object doInBackground(Object... params) {

    ItemRoloDeCamera compressedVideo = new ItemRoloDeCamera();

    File videoInputFile = new File(video.getSdcardPath());

    File videoFolderFile = videoInputFile.getParentFile();

    File videoOutputFile = new File(videoFolderFile, "video_comprimido_moymer.mp4");

    if (videoFolderFile.exists())
        android.util.Log.e("COMPRESS VIDEO UTILS", "video folder exist");
    else
        android.util.Log.e("COMPRESS VIDEO UTILS", "video folder DON'T exist");

    if (videoInputFile.exists())
        android.util.Log.e("COMPRESS VIDEO UTILS", "video input file exist");
    else
        android.util.Log.e("COMPRESS VIDEO UTILS", "video input file DON'T exist");

    if (videoOutputFile.exists())
        android.util.Log.e("COMPRESS VIDEO UTILS", "video output file exist");
    else
        android.util.Log.e("COMPRESS VIDEO UTILS", "video output file DON'T exist");

    FfmpegController ffmpegController;

    try {

        ffmpegController = new FfmpegController(context, videoFolderFile);

        Clip clipIn = new Clip(videoInputFile.getAbsolutePath());

        ffmpegController.getInfo(clipIn, new ShellUtils.ShellCallback() {
            @Override
            public void shellOut(String shellLine) {
                videoInfo.add(shellLine);
            }

            @Override
            public void processComplete(int exitValue) {
                videoInfo.add(String.valueOf(exitValue));
            }
        });

        int rotate = getRotateMetadata();

        Clip clipOut = new Clip(videoOutputFile.getAbsolutePath());
        clipOut.videoFps = "24";
        clipOut.videoBitrate = 512;
        clipOut.audioChannels = 1;
        clipOut.width = 640;
        clipOut.height = 352;

        if (rotate == 90)
            clipOut.videoFilter = "transpose=1";
        else if (rotate == 180)
            clipOut.videoFilter = "transpose=1,transpose=1";
        else if (rotate == 270)
            clipOut.videoFilter = "transpose=1,transpose=1,transpose=1";

        millisDuration = getVideoDuration(videoInputFile.getAbsolutePath());

        float secondsDuration = millisDuration / 1000f;

        clipOut.duration = secondsDuration;

        ffmpegController.processVideo(clipIn, clipOut, true, new ShellUtils.ShellCallback() {
            @Override
            public void shellOut(String shellLine) {

                android.util.Log.e("COMPRESS VIDEO UTILS", "shellOut - " + shellLine);

                float percentage = getTimeMetadata(shellLine);

                if (percentage >= 0f)
                    publishProgress(percentage);

            }

            @Override
            public void processComplete(int exitValue) {
                android.util.Log.e("COMPRESS VIDEO UTILS", "proccess complete - " + exitValue);
            }
        });


    } catch (IOException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {

        if (videoOutputFile.exists()) {

            android.util.Log.e("COMPRESS VIDEO UTILS", "finished ffmpeg ---> video output file exist");

            compressedVideo.setSdcardPath(videoOutputFile.getAbsolutePath());

            return compressedVideo;

        } else
            android.util.Log.e("COMPRESS VIDEO UTILS", "finished ffmpeg ---> video output file DON'T exist");

    }

    return compressedVideo;

}

private float getTimeMetadata(String shellLine) {

    float percentage = -1;

    if (shellLine.contains("time=")) {

        String[] timeLine = shellLine.split("=");

        String time = timeLine[5];
        time = time.replace("bitrate", "");
        time = time.trim();

    //            String source = "00:10:17";
        String[] tokens = time.split(":");
        int secondsToMs = (int) (Float.parseFloat(tokens[2]) * 1000);
        int minutesToMs = Integer.parseInt(tokens[1]) * 60000;
        int hoursToMs = Integer.parseInt(tokens[0]) * 3600000;
        long timeInMillis = secondsToMs + minutesToMs + hoursToMs;

        percentage = (timeInMillis * 100.0f) / millisDuration;

    }

    return percentage;

}

private int getRotateMetadata() {

    int rotate = 0;

    String durationString = "";

    for (String shellLine : videoInfo) {

        if (shellLine.contains("rotate")) {

            //rotate          : 270

            String[] rotateLine = shellLine.split(":");

            rotate = Integer.parseInt(rotateLine[1].trim());

        }

    }

    return rotate;

}

public static long getVideoDuration(String videoPath) {

    MediaMetadataRetriever retriever = new MediaMetadataRetriever();

    retriever.setDataSource(videoPath);

    String time = retriever
            .extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);

    long timeInmillisec = Long.parseLong(time);

    return timeInmillisec;

}


    



    The only change I made in the processVideo method was to add the following lines when building the commmand :

    



    cmd.add("-preset");
cmd.add("ultrafast");