Recherche avancée

Médias (91)

Autres articles (53)

  • Support de tous types de médias

    10 avril 2011

    Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 est la première version de MediaSPIP stable.
    Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

  • Les tâches Cron régulières de la ferme

    1er décembre 2010, par

    La gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
    Le super Cron (gestion_mutu_super_cron)
    Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...)

Sur d’autres sites (4329)

  • 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");


    


  • ffmpeg to generate dash and HLS

    5 septembre 2017, par LaborC

    Looking for the correct way to encode a given input video in multiple bitrates and then package it for dash and HLS. I thought this is a basic task, but as it turns out, I could not find any guide on how to achieve this. So the way I do it is (but with these I get an out of sync video/audio) :

    First I split my video (mp4) into video and audio.

    ffmpeg -c:v copy -an video_na.mp4 -i source_input.mp4
    ffmpeg -c:a aac -ac 2 -async 1 -vn audio.mp4 -i source_input.mp4

    Then I encode the video with the following commands :

       ffmpeg.exe -i video_na.mp4 -an -c:v libx264 -crf 18 \
    -preset fast -profile:v high -level 4.2 -b:v 2000k -minrate 2000k \
    -maxrate 2000k -bufsize 4000k -g 96 -keyint_min 96 -sc_threshold 0 \
    -filter:v "scale='trunc(oh*a/2)*2:576'" -movflags +faststart \
    -pix_fmt yuv420p -threads 4 -f mp4 video-2000k.mp4

       ffmpeg.exe -i video_na.mp4 -an -c:v libx264 -crf 18 \
    -preset fast -profile:v high -level 4.2 -b:v 1500k -minrate 1500k \
    -maxrate 1500k -bufsize 3000k -g 96 -keyint_min 96 -sc_threshold 0 \
    -filter:v "scale='trunc(oh*a/2)*2:480'" -movflags +faststart \
    -pix_fmt yuv420p -threads 4 -f mp4 video-1500k.mp4

    After that I fragment the videos.

    mp4fragment --fragment-duration 4000 --timescale 10000 video-2000k.mp4 \
    video-2000k-f.mp4

    mp4fragment --fragment-duration 4000 --timescale 10000 video-1500k.mp4 \
    video-1500k-f.mp4

    And finally package everything together again for dash.

    mp4dash --media-prefix=out  \
         --use-segment-timeline  \
         video-2000k-f.mp4  \
         video-1500k-f.mp4  \
        --out dash

    Now there is a difference between audio and video.

    I think that the problem is with my parameters for encoding. But which one I have no idea. What am I doing wrong ?