Recherche avancée

Médias (91)

Autres articles (104)

  • Encoding and processing into web-friendly formats

    13 avril 2011, par

    MediaSPIP automatically converts uploaded files to internet-compatible formats.
    Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
    Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
    Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
    All uploaded files are stored online in their original format, so you can (...)

  • Gestion de la ferme

    2 mars 2010, par

    La ferme est gérée dans son ensemble par des "super admins".
    Certains réglages peuvent être fais afin de réguler les besoins des différents canaux.
    Dans un premier temps il utilise le plugin "Gestion de mutualisation"

  • ANNEXE : Les plugins utilisés spécifiquement pour la ferme

    5 mars 2010, par

    Le site central/maître de la ferme a besoin d’utiliser plusieurs plugins supplémentaires vis à vis des canaux pour son bon fonctionnement. le plugin Gestion de la mutualisation ; le plugin inscription3 pour gérer les inscriptions et les demandes de création d’instance de mutualisation dès l’inscription des utilisateurs ; le plugin verifier qui fournit une API de vérification des champs (utilisé par inscription3) ; le plugin champs extras v2 nécessité par inscription3 (...)

Sur d’autres sites (10875)

  • 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 ?

  • Evolution #3973 : Brancher inc/distant recuperer_url() sur une librairie récente

    8 octobre 2018, par b b

    Super, il faudrait peut-être commencer par un travail de recensement des librairies disponibles pour ça ? (je peux m’y coller)

  • FFMpeg : h.264 to h.264 with the same quality and bitrate

    6 octobre 2018, par Vasya

    I have a some mp4 video file with 1 video stream, encoded in h.264 and with bitrate XYZ kb/s, for example, let’s have a name xxx.mp4 (not a home video, just a film). Its frames looks like some video data and two horizontal black strips on top and bottom side. On one of those strips there is some text, like "Our XXX super videos". I want to draw a black box on those text with dratext filter. Obviously, that processed video must be with almost same bitrate and same file size. But which options I must put in ffmpeg.exe to do so ? CRF 0 ? CRF 18 ? b:v XYZ ? Two-pass ? VBV with crf 23 -maxrate XYZ -bufsize 2M ?
    I want get video data without any losses in comprasion with original mp4 file.