Recherche avancée

Médias (0)

Mot : - Tags -/protocoles

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

Autres articles (75)

  • 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 (...)

  • Le profil des utilisateurs

    12 avril 2011, par

    Chaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
    L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)

  • Configurer la prise en compte des langues

    15 novembre 2010, par

    Accéder à la configuration et ajouter des langues prises en compte
    Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
    De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
    Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...)

Sur d’autres sites (6176)

  • FFmpeg Processes keep running even after finishAndRemoveTask()

    9 octobre 2018, par kataroty

    I have a program that gets Audio files and converts them using Bravobit FFmpeg Bravobit FFmpeg github.

    It works as intended until someone minimizes screen during the convertion process. I am trying to fix that but so far I have not been successful.

    This part is in the Main Activity that creates and starts my AudioProcessor :

    AudioProcessor ac = new AudioProcessor(getApplicationContext(), PostNewActivity.this);
                   ac.setBackgroundMp3File(backgroundAudio);
                   ac.setMicPcmFile(micOutputPCM);
                   ac.setOutputFile(tempOutFile);
                   ac.setListener(new AudioProcessor.AudioProcessorListener() {
                       public void onStart() {
                           Log.d("Audioprocessor", "Audioprocessor is successful");
                       }

                       public void onSuccess(File output) {
                           Log.d("Audioprocessor", "Audioprocessor is successful");
                           goToPublishView();
                       }

                       public void onError(String message) {
                           System.out.println("Audioprocessor: " + message);

                       }

                       public void onFinish() {
                           Log.d("Audioprocessor", "Audioprocessor is finshed");
                      }


                   });

                   try {
                       if (tempOutFile.exists()) {
                           tempOutFile.delete();
                       }
                       ac.process();
                   } catch (Exception ex) {
                       System.out.println("Processing failed!");
                       ex.printStackTrace();
                   }

    And here is the AudioProcessor itself :

    public class AudioProcessor {

       private Context context;
       private FFmpeg ffmpeg;
       private AudioProcessorListener listener;

       private File micPcmFile;
       private File backgroundMp3File;

       private File pcmtowavTempFile;
       private File mp3towavTempFile;
       private File combinedwavTempFile;

       private File outputFile;
       private File volumeChangedTempFile;

       TextView extensionDownload, percentProgress;


       public AudioProcessor(Context context, Activity activity) {
           ffmpeg = null;
           ffmpeg = FFmpeg.getInstance(context);
           percentProgress = activity.findViewById(R.id.percentProgress);
           percentProgress.setSingleLine(false);
           this.context = context;
           prepare();
       }

       /**
        * Program main method. Starts running program
        * @throws Exception
        */
       public void process() throws Exception {
           if (!ffmpeg.isSupported()) {
               Log.e("AudioProcessor", "FFMPEG not supported! Cannot convert audio!");
               throw new Exception("FFMPeg has to be supported");
           }
           if (!checkIfAllFilesPresent()) {
               Log.e("AudioProcessor", "All files are not set yet. Please set file first");
               throw new Exception("Files are not set!");
           }

           Log.e("AudioProcessor", "Start processing audio");
           listener.onStart();



           Handler handler = new Handler();
           handler.postDelayed(new Runnable() {
               @Override
               public void run() {
                   convertPCMToWav();
               }
           }, 200);
       }

       /**
        * Prepares program
        */
       private void prepare() {
           prepareTempFiles();
       }

       /**
        * Converts PCM to wav file. Automatically create new file.
        */
       private void convertPCMToWav() {
           Log.e("AudioProcessor", "Convert PCM TO Wav");
           //ffmpeg -f s16le -ar 44.1k -ac 2 -i file.pcm file.wav
           String[] cmd = { "-f" , "s16le", "-ar", "44.1k", "-i", micPcmFile.toString(), "-y", pcmtowavTempFile.toString()};
           ffmpeg.execute(cmd, new ExecuteBinaryResponseHandler() {

               @Override
               public void onStart() {
                   super.onStart();
                   percentProgress.setVisibility(View.VISIBLE);
                   percentProgress.setText("Converting your recording\n"+"1/5");
               }

               @Override
               public void onSuccess(String message) {
                   super.onSuccess(message);
                   convertMP3ToWav();
               }
               @Override
               public void onFailure(String message) {
                   super.onFailure(message);
                   onError(message);
                   convertPCMToWav();
               }
           });
       }

       /**
        * Converts mp3 file to wav file.
        * Automatically creates Wav file
        */
       private void convertMP3ToWav() {
           Log.e("AudioProcessor", "Convert MP3 TO Wav");

           //ffmpeg -i file.mp3 file.wav
           String[] cmd = { "-i" , backgroundMp3File.toString(), "-y", mp3towavTempFile.toString() };
           ffmpeg.execute(cmd, new ExecuteBinaryResponseHandler() {
               @Override
               public void onStart() {
                   super.onStart();
                   percentProgress.setText("Converting background audio\n"+"2/5");
                   Log.e("AudioProcessor", "Starging convertgf MP3 TO Wav");
               }

               @Override
               public void onSuccess(String message) {
                   super.onSuccess(message);
                   changeMicAudio();
               }
               @Override
               public void onFailure(String message) {
                   super.onFailure(message);
                   Log.e("AudioProcessor", "Failed to convert MP3 TO Wav");
                   //onError(message);
                   throw new RuntimeException("Failed to convert MP3 TO Wav");
                   //convertMP3ToWav();
               }
           });
       }

       /**
        * Combines 2 wav files into one wav file. Overlays audio
        */
       private void combineWavs() {
           Log.e("AudioProcessor", "Combine wavs");
           //ffmpeg -i C:\Users\VR1\Desktop\_mp3.wav -i C:\Users\VR1\Desktop\_pcm.wav -filter_complex amix=inputs=2:duration=first:dropout_transition=3 C:\Users\VR1\Desktop\out.wav

           String[] cmd = { "-i" , pcmtowavTempFile.toString(), "-i", volumeChangedTempFile.toString(), "-filter_complex", "amix=inputs=2:duration=first:dropout_transition=3", "-y",combinedwavTempFile.toString()};
           ffmpeg.execute(cmd, new ExecuteBinaryResponseHandler() {

               @Override
               public void onStart() {
                   super.onStart();
                   percentProgress.setText("Combining the two audio files\n"+"4/5");
               }

               @Override
               public void onSuccess(String message) {
                   super.onSuccess(message);
                   encodeWavToAAC();

               }
               @Override
               public void onFailure(String message) {
                   super.onFailure(message);
                   onError(message);
               }
           });
       }

       private void changeMicAudio(){
           Log.e("AudioProcessor", "Change audio volume");
           //ffmpeg -i input.wav -filter:a "volume=1.5" output.wav

           String[] cmdy = { "-i", mp3towavTempFile.toString(),  "-af", "volume=0.9", "-y",volumeChangedTempFile.toString()};
           ffmpeg.execute(cmdy, new ExecuteBinaryResponseHandler() {

               @Override
               public void onStart() {
                   super.onStart();
                   percentProgress.setText("Normalizing volume\n"+"3/5");
               }

               @Override
               public void onSuccess(String message) {
                   combineWavs();
                   super.onSuccess(message);
               }
               @Override
               public void onFailure(String message) {
                   super.onFailure(message);
                   Log.e("AudioProcessor", message);
               }
           });
       }


       /**
        * Do something on error. Releases program data (deletes files)
        * @param message
        */
       private void onError(String message) {
           release();
           if (listener != null) {
               //listener.onError(message);
           }
       }
       /**
        * Encode to AAC
        */
       private void encodeWavToAAC() {
           Log.e("AudioProcessor", "Encode to AAC");
           //ffmpeg -i file.wav -c:a aac -b:a 128k -f adts output.m4a
           String[] cmd = { "-i" , combinedwavTempFile.toString(), "-c:a", "aac", "-b:a", "128k", "-f", "adts", "-y",outputFile.toString()};
           ffmpeg.execute(cmd, new ExecuteBinaryResponseHandler() {

               @Override
               public void onStart() {
                   super.onStart();
                   percentProgress.setText("Normalizing volume\n"+"3/5");
               }

               @Override
               public void onSuccess(String message) {
                   super.onSuccess(message);
                   if (listener != null) {
                       listener.onSuccess(outputFile);
                   }
                   release();
               }
               @Override
               public void onFailure(String message) {
                   super.onFailure(message);
                   onError(message);
                   encodeWavToAAC();
               }
           });
       }

       /**
        * Uninitializes class
        */
       private void release() {
           if (listener != null) {
               listener.onFinish();
           }
           destroyTempFiles();
       }

       /**
        * Prepares temp required files by deleteing them if they exsist.
        * Files cannot exists before ffmpeg actions. FFMpeg automatically creates those files.
        */
       private void prepareTempFiles() {
           pcmtowavTempFile = new File(context.getFilesDir()+ Common.TEMP_LOCAL_DIR + "/" + "_pcm.wav");
           mp3towavTempFile = new File(context.getFilesDir()+ Common.TEMP_LOCAL_DIR + "/" + "_mp3.wav");
           combinedwavTempFile = new File(context.getFilesDir()+ Common.TEMP_LOCAL_DIR + "/" + "_combined.wav");
           volumeChangedTempFile = new File(context.getFilesDir()+ Common.TEMP_LOCAL_DIR + "/" + "_volumeChanged.wav");

           destroyTempFiles();
       }

       /**
        * Destroys temp required files
        */
       private void destroyTempFiles() {

           pcmtowavTempFile.delete();
           mp3towavTempFile.delete();
           combinedwavTempFile.delete();
           volumeChangedTempFile.delete();
       }

       /**
        * Checks if all files are set, so we can process them
        * @return - all files ready
        */
       private boolean checkIfAllFilesPresent() {
           if(micPcmFile == null || backgroundMp3File == null || outputFile == null) {
               Log.e("AudioProcessor", "All files are not set! Set all files!");
               return false;
           }
           return true;
       }

       public void setOutputFile(File outputFile) {
           this.outputFile = outputFile;
       }

       public void setListener(AudioProcessorListener listener) {
           this.listener = listener;
       }

       public void setMicPcmFile(File micPcmFile) {


           this.micPcmFile = micPcmFile;
       }

       public void setBackgroundMp3File(File backgroundMp3File) {
           this.backgroundMp3File = backgroundMp3File;
       }


       public interface AudioProcessorListener {
           void onStart();
           void onSuccess(File output);
           void onError(String message);
           void onFinish();
       }
    }

    How I am usually testing it and getting the crashes is letting the AudioProcessor get to the 2nd method, which is convertMP3ToWav() and then close the application. When I start it back up again and start processing the files the application crashes.

    I have tried many ways and I thought about throwing the application back to start when it is minimized with this code in the Main Activity

    @Override
    protected void onUserLeaveHint()
    {
       if (Build.VERSION.SDK_INT >= 21) {
           finishAndRemoveTask();
       } else {
           finish();
       }
    }

    I thought that it would stop everything but it still kept crashing. After doing some debugging I found that even when I minimize the app and do the finishAndRemoveTask() the AudioProcessor is still working and it still does all of the ffmpeg commands and even calls the onSuccess()/onFinish() methods.

    How can I completely stop everything or at least stop and clear the AudioProcessor when the application is minimized ?

  • tf.contrib.ffmpeg.decode_audio replacement ?

    27 juin 2019, par Imran Paruk

    In the tensorflow docs, it stated that tf.contrib.ffmpeg.decode_audio is depreciated, however it does not state what it’s replacement is...

    THIS FUNCTION IS DEPRECATED. It will be removed after 2018-09-04. Instructions for updating : This will be deleted and should not be used.

    Here is the link : https://www.tensorflow.org/api_docs/python/tf/contrib/ffmpeg/decode_audio

  • ffmpy error while running run command in python

    26 novembre 2018, par Harini
    import ffmpy
    ff = ffmpy.FFmpeg(executable='C:\\ffmpeg\\bin\\ffmpeg.exe', inputs={'speech.mp3': None},outputs={'speech1.wav': None})
    ff.run()
    print(json.dumps(beyond_verbal(outputs)))
    sys.exit(0)

    Below is the error while running the above code.
    FFRuntimeError : C:\ffmpeg\bin\ffmpeg.exe -i speech.mp3 speech1.wav exited with status 1