Recherche avancée

Médias (0)

Mot : - Tags -/performance

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (112)

  • Mise à jour de la version 0.1 vers 0.2

    24 juin 2013, par

    Explications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
    Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

  • Les autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

Sur d’autres sites (11560)

  • Révision 19837 : Correction et amélioration dans l’importation d’une sauvegarde :

    24 août 2012, par esj@rezo.net

    le test final de nécessité de reconnexion était faux, le résultat de auth_retrouve_login n’étant pas un tableau ; corrigé, ce test apparaît peu utile car l’étape finale étant provoquée par une redirection, il y a eu à l’entrée une vérification du cookie qui a provoqué un renouvellement de session qui a (...)

  • Call bash function in Java

    16 mai 2023, par ilie alexandru

    I have been using Java with bash in order to make some things easier, some examples :

    


    From the main class to call a subclass in order to use bash commands :

    


    Main classs :

    


        //Checking if the server already has the user or not
    CheckUser checkUser = new CheckUser();
    int checuser= checkUser.CheckUserMethod(user);
    if( 1 != checuser) { // Yoda notation

        //Making the directory for the user
        File userDirectory = new File(this.directory);
        userDirectory.mkdir();
    }


    


    The class that will call the ".sh" file :

    


    public class CheckUser {

protected int CheckUserMethod(String user){
    try {

        Process p = Runtime.getRuntime().exec(new String[]{"bash", "-c", "cd ~/Final-Year-Spring/src/main/java/query && ./checkuser.sh " + user});
        BufferedReader srdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
        String s =srdInput.readLine();
        if(s==null){
            return 0;
        }else {
            return Integer.parseInt(s);
        }
    }catch (Exception e){
        throw new RuntimeException(e);
    }
}


    


    


    The bash file :

    


    #!/bin/bash

# shellcheck disable=SC2237
if ! [ -z "$1" ]
then
  cd ~/Final-Year-Spring/maps/ && find "$1" -maxdepth 0 -type d -printf 1
fi


    


    Now you have a context.

    


    I am trying to call a bash file that will execute a ffmpeg command. For instance, the same command when I am using the terminal :

    


    ffmpeg -ss 00:00:00.75 -to 00:00:00.93 -i ~/IdeaProjects/Final-Year-Spring/datassets/Alex/check/5535415699068794046/00009.mp4 -ss 00:00:01.71 -to 00:00:01.82 -i ~/IdeaProjects/Final-Year-Spring/datassets/Alex/check/5535415699068794046/00009.mp4 ~/IdeaProjects/Final-Year-Spring/maps/output.mp4S


    


    Also a screenshot with the command in the cli :

    


    enter image description here

    


    The result of the cli command :

    


    enter image description here

    


    Now I am trying to do the same thing for multiple videos using Java and Bash.

    


    The class that will create the input and the time :

    


    public String CreateNewVideoMethod()

    


    ArrayList<string> arrayList = new ArrayList&lt;>();&#xA;&#xA;MainSearch mainSearch = new MainSearch(this.array, this.search);&#xA;HashMap>>> map = new HashMap&lt;>();&#xA;        map = mainSearch.SearchInVideous();&#xA;&#xA;&#xA;HashMap>> file = new HashMap&lt;>();&#xA;file=map.get(this.array.get(1));&#xA;&#xA;file.forEach((k,v)->{&#xA;    StringBuilder stringBuilder = new StringBuilder(this.defaultpth);&#xA;    stringBuilder.append("/")&#xA;            .append(this.array.get(0))&#xA;            .append("/")&#xA;            .append(this.array.get(1))&#xA;            .append("/")&#xA;            .append(k)&#xA;            .append("/")&#xA;            .append("InfoVideo.txt");&#xA;&#xA;    GetVideoPath getVideoPath = new GetVideoPath();&#xA;    String videoPath = getVideoPath.GetVideoPathMethod(stringBuilder);&#xA;&#xA;    v.forEach((k1,v1)->{ // iterate though the words&#xA;        v1.forEach((k2,v2)->{ // iterate though the times&#xA;&#xA;            String doubleAsStringForKey = String.valueOf(k2);&#xA;            String[] arr = doubleAsStringForKey.split("\\.");&#xA;&#xA;            String doubleASStringForValue = String.valueOf(v2);&#xA;            String[] arr2 = doubleASStringForValue.split("\\.");&#xA;&#xA;            if(k2>10){&#xA;&#xA;                StringBuilder stringBuilder1 = new StringBuilder();&#xA;                stringBuilder1.append(" -ss ")&#xA;                        .append("00:00:")&#xA;                        .append(arr[0])&#xA;                        .append(".")&#xA;                        .append(arr[1])&#xA;                        .append(" -to ")&#xA;                        .append(" 00:00:")&#xA;                        .append(arr2[0])&#xA;                        .append(".")&#xA;                        .append(arr2[1])&#xA;                        .append(" -i ")&#xA;                        .append(videoPath);&#xA;                arrayList.add(String.valueOf(stringBuilder1));&#xA;            }&#xA;                else{&#xA;&#xA;                    StringBuilder stringBuilder1 = new StringBuilder();&#xA;                    stringBuilder1.append(" -ss ")&#xA;                            .append("00:00:0")&#xA;                            .append(arr[0])&#xA;                            .append(".")&#xA;                            .append(arr[1])&#xA;                            .append(" -to ")&#xA;                            .append("00:00:0")&#xA;                            .append(arr2[0])&#xA;                            .append(".")&#xA;                            .append(arr2[1])&#xA;                            .append(" -i ")&#xA;                            .append(videoPath);&#xA;                    arrayList.add(String.valueOf(stringBuilder1));&#xA;                }&#xA;&#xA;        });&#xA;    });&#xA;&#xA;});&#xA;&#xA;BashFIleForCreatingNewVideo bashFIleForCreatingNewVideo = new BashFIleForCreatingNewVideo();&#xA;bashFIleForCreatingNewVideo.BashFileForCreatingNewVideo(arrayList);&#xA;</string>

    &#xA;

    The class that must call the ".sh" file :

    &#xA;

    public class BashFIleForCreatingNewVideo {&#xA;&#xA;    protected String BashFileForCreatingNewVideo(ArrayList<string> arrayList){&#xA;        try {&#xA;&#xA;        StringBuilder stringBuilder = new StringBuilder();&#xA;&#xA;        for(String str : arrayList){&#xA;            stringBuilder.append(str);&#xA;        }&#xA;        Process p = Runtime.getRuntime().exec(new String[]{"bash", "-c", "cd ~/IdeaProjects/Final-Year-Spring/src/main/java/com/FinalYearProjectServer/Get_Requests/CreateNewVideo &amp;&amp; ./createNewVideo.sh ", String.valueOf(stringBuilder), String.valueOf(arrayList.size()-1), "./maps/outputstream.mp4"});&#xA;        BufferedReader srdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));&#xA;        String s =srdInput.readLine();&#xA;&#xA;        if(s==null){&#xA;            return "Error";&#xA;        }else {&#xA;            System.out.println(s);&#xA;            return s;&#xA;        }&#xA;&#xA;        } catch (IOException e) {&#xA;            throw new RuntimeException(e);&#xA;        }&#xA;&#xA;    }&#xA;}&#xA;</string>

    &#xA;

    The script file :

    &#xA;

    #!/bin/bash&#xA;&#xA;arr=( "$@" )&#xA;&#xA;echo "${arr[*]}"&#xA;&#xA;ffmpeg "${arr[0]}" -filter_complex concat=n="${arr[1]}":v=1:a=1 "${arr[2]}"&#xA;

    &#xA;

    What is passed to the script, small exaple, this is a string :

    &#xA;

     -ss 00:00:00.75 -to 00:00:00.93 -i ~/IdeaProjects/Final-Year-Spring/datassets/Alex/check/5535415699068794046/00009.mp4 -ss 00:00:01.71 -to 00:00:01.82 -i ~/IdeaProjects/Final-Year-Spring/datassets/Alex/check/5535415699068794046/00009.mp4 -ss 00:00:00.09 -to 00:00:00.34 -i ~/IdeaProjects/Final-Year-Spring/datassets/Alex/check/5535415699068794046/00027.mp4&#xA;

    &#xA;

    The next parameter is the number of videos that must concatenate and the last parameter is where the output must be.

    &#xA;

    My problem is the Bash file is not executing even the echo command or doing something. Do you have any suggestion, because I thing is about the way of how I am passing the array to the Bash file.

    &#xA;

    Ok so I am trying to use ProcessBuilder :

    &#xA;

            String[] command = {"bash","ffmpeg", String.valueOf(stringBuilder), "-filter_complex concat=n="&#x2B;String.valueOf(arrayList.size()-1)&#x2B;":v=1:a=1", "~/IdeaProjects/Final-Year-Spring/maps/output1.mp4"};&#xA;        ProcessBuilder p = new ProcessBuilder(command);&#xA;        Process p2 = p.start();&#xA;        BufferedReader srdInput;&#xA;        srdInput = new BufferedReader(new InputStreamReader(p2.getInputStream()));&#xA;        String s =srdInput.readLine();&#xA;

    &#xA;

  • merge multiple ffmpeg commands into one line to make the whole process faster

    8 septembre 2020, par user1hjgjhgjhggjhg

    I want to merge multiple commands into one so that whole processing time would be fastest. What I am doing so far is

    &#xA;

      &#xA;
    1. A video file is uploaded from a webform and and server upload into a temp directory.

      &#xA;

       if (move_uploaded_file($_FILES[$param][&#x27;tmp_name&#x27;], $filePath)) {&#xA;&#xA;&#xA;       return $filePath;&#xA;     }&#xA;

      &#xA;

    2. &#xA;

    3. add black borders around the video(through ffmpeg command) - video uploads again to a directory

      &#xA;

      $command_new = "ffmpeg -i $filePath -vf &#x27;scale=720:1280:force_original_aspect_ratio=decrease,pad=720:1280:(ow-iw)/2:(oh-ih)/2,setsar=1&#x27; $video_file";&#xA;    exec($command_new);&#xA;

      &#xA;

    4. &#xA;

    5. optimizing the video(ffmpeg command) - video uploads again to a directory

      &#xA;

        $cmd_new = "ffmpeg -i $video_file -c:v libx264 -crf 28 $optimizeResultFile";&#xA;

      &#xA;

    6. &#xA;

    7. merging the uploaded file with the existing video file present in the database into one and uploading that file into directory(through ffmpeg command)

      &#xA;

             $command_new = "ffmpeg -i $optimizeResultFile   -i $second_video_path   -filter_complex &#x27;[0:v]pad=iw*2:ih[int];[int][1:v]overlay=W/2:0[vid]&#x27;   -map [vid]   -c:v libx264   -crf 23   -preset veryfast $videomerge";&#xA;

      &#xA;

    8. &#xA;

    9. //add custom sound in that final merged video

      &#xA;

             $cmd_new = "ffmpeg -i $videomerge -i $audio -c:v copy -c:a aac -shortest -map 0:v:0 -map 1:a:0 $with_new_audio";&#xA;

      &#xA;

    10. &#xA;

    &#xA;

    Is it possible to do all at one command and not in multiple commands. This process takes 1 min to upload a final file. want to make it faster

    &#xA;