Recherche avancée

Médias (2)

Mot : - Tags -/documentation

Autres articles (27)

  • La sauvegarde automatique de canaux SPIP

    1er avril 2010, par

    Dans le cadre de la mise en place d’une plateforme ouverte, il est important pour les hébergeurs de pouvoir disposer de sauvegardes assez régulières pour parer à tout problème éventuel.
    Pour réaliser cette tâche on se base sur deux plugins SPIP : Saveauto qui permet une sauvegarde régulière de la base de donnée sous la forme d’un dump mysql (utilisable dans phpmyadmin) mes_fichiers_2 qui permet de réaliser une archive au format zip des données importantes du site (les documents, les éléments (...)

  • Script d’installation automatique de MediaSPIP

    25 avril 2011, par

    Afin de palier aux difficultés d’installation dues principalement aux dépendances logicielles coté serveur, un script d’installation "tout en un" en bash a été créé afin de faciliter cette étape sur un serveur doté d’une distribution Linux compatible.
    Vous devez bénéficier d’un accès SSH à votre serveur et d’un compte "root" afin de l’utiliser, ce qui permettra d’installer les dépendances. Contactez votre hébergeur si vous ne disposez pas de cela.
    La documentation de l’utilisation du script d’installation (...)

  • Automated installation script of MediaSPIP

    25 avril 2011, par

    To overcome the difficulties mainly due to the installation of server side software dependencies, an "all-in-one" installation script written in bash was created to facilitate this step on a server with a compatible Linux distribution.
    You must have access to your server via SSH and a root account to use it, which will install the dependencies. Contact your provider if you do not have that.
    The documentation of the use of this installation script is available here.
    The code of this (...)

Sur d’autres sites (2950)

  • libavformat/libavfilter transcoded audio is choppy

    9 mai 2016, par JohnnyD

    I am attempting to transcode an mp4 file into a standard format. The video seems ok but the audio is choppy (and out of sync with the video).

    My test input file has the following properties :

    Stream #0:1(eng), 0, 1/48000: Audio: aac (mp4a / 0x6134706D), 48000 Hz, 2 channels, 129 kb/s (default)

    and I’m outputing to :

    Stream #0:1, 0, 1/44100: Audio: aac (libfaac) (Main), 44100 Hz, stereo, s16, 128 kb/s

    When I construct the audio filter graph I get the following debug output :

    [in @ 0x103954380] Setting 'time_base' to value '1/48000'
    [in @ 0x103954380] Setting 'sample_rate' to value '48000'
    [in @ 0x103954380] Setting 'sample_fmt' to value 'fltp'
    [in @ 0x103954380] Setting 'channel_layout' to value '0x3'
    [in @ 0x103954380] tb:1/48000 samplefmt:fltp samplerate:48000 chlayout:0x3
    [format @ 0x10390b3e0] Setting 'sample_fmts' to value 's16'
    [format @ 0x10390b3e0] Setting 'sample_rates' to value '44100'
    [format @ 0x10390b3e0] Setting 'channel_layouts' to value '0x3'
    [format @ 0x10390b3e0] auto-inserting filter 'auto-inserted resampler 0' between the filter 'in' and the filter 'format'
    [AVFilterGraph @ 0x101f21b80] query_formats: 3 queried, 3 merged, 3 already done, 0 delayed
    [auto-inserted resampler 0 @ 0x103952bc0] ch:2 chl:stereo fmt:fltp r:48000Hz -> ch:2 chl:stereo fmt:s16 r:44100Hz

    This looks correct to me but I’m getting a lot of the following messages when I process the file...

    [libfaac @ 0x102063a00] Trying to remove 80 more samples than there are in the queue

    ...and the audio is choppy. Also I’m seeing that the sample format is the same as the original file (from ffprobe) :

    Stream #0:1(und): Audio: aac (Main) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)

    i.e. it hasn’t done the conversion from AV_SAMPLE_FMT_FLT to AV_SAMPLE_FMT_S16.

    I’m wondering if the bitrate is the cause of the problem but I can’t see any way to transform the input bitrate to the output bitrate. Any thoughts ?

  • Android merging PCM and MP3 into AAC

    4 février 2019, par kataroty

    I have a program that records user input sound as PCM (I needed to do it separately to "play" with the voice) and then I also have a custom audio track, which is in MP3 format, that I want merge with the PCM file.

    To start off I convert both of them to WAV separately, then I combine the 2 WAV files, and finally convert the result to AAC because I also need to merge the audio with video later.

    I tried merging 2 AAC files, but that did not work out for me.

    For audio conversion I am using FFmpeg-Android.

    The problem is that it takes way too long, around 1-2min to do the whole conversion and because of that I need a new way to do it all. I have looked into other libraries but this was the only one I could get to work.

    Can someone recommend something that would do the whole process faster ?

    Here is my code to merge all of the files :

    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;

       private FFtask currentTask;

       private int videoRecordingLength = 0;

       TextView extensionDownload, percentProgress;

       private static final String TAG = "FFMPEG AV Processor";

       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(TAG, "FFMPEG not supported! Cannot convert audio!");
               throw new RuntimeException("FFMPeg has to be supported");
           }
           if (!checkIfAllFilesPresent()) {
               Log.e(TAG, "All files are not set yet. Please set file first");
               throw new RuntimeException("Files are not set!");
           }

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

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

       /**
        * Prepares program
        */
       private void prepare() {
           Log.d(TAG, "Preparing everything...");
           prepareTempFiles();
       }

       /**
        * Converts PCM to wav file. Automatically create new file.
        */
       private void convertPCMToWav() {
           Log.d(TAG, "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()};
           currentTask = 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(TAG, "Convert MP3 TO Wav");

           //ffmpeg -ss 0 -t 30 -i file.mp3 file.wav
           //String[] cmd = { "-ss", "0", "-t", Integer.toString(videoRecordingLength), "-i" , backgroundMp3File.toString(), "-y", mp3towavTempFile.toString() };
           String[] cmd = {  "-i" , backgroundMp3File.toString(), "-y", mp3towavTempFile.toString() };
           currentTask = ffmpeg.execute(cmd, new ExecuteBinaryResponseHandler() {
               @Override
               public void onStart() {
                   super.onStart();
                   percentProgress.setText("Converting background audio\n"+"2/5");
                   Log.d(TAG, "Convert MP3 TO Wav");
               }
               @Override
               public void onSuccess(String message) {
                   super.onSuccess(message);
                   changeMicAudio();
               }
               @Override
               public void onFailure(String message) {
                   super.onFailure(message);
                   Log.e(TAG, "Failed to convert MP3 TO Wav");
                   onError(message);
                   throw new RuntimeException("Failed to convert MP3 TO Wav");
               }
           });
       }

       /**
        * Combines 2 wav files into one wav file. Overlays audio
        */
       private void combineWavs() {
           Log.e(TAG, "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()};
           currentTask = 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(TAG, "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()};
           currentTask = 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) {
           completed();
           if (listener != null) {
               //listener.onError(message);
           }
       }
       /**
        * Encode to AAC
        */
       private void encodeWavToAAC() {
           Log.d(TAG, "Encode Wav file 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()};
           currentTask = 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);
                   }
                   completed();
               }
               @Override
               public void onFailure(String message) {
                   super.onFailure(message);
                   onError(message);
                   encodeWavToAAC();
               }
           });
       }

       /**
        * Uninitializes class
        */
       private void completed() {
           if (listener != null) {
               listener.onFinish();
           }
           Log.d(TAG, "Process completed successfully!");
           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() {
           Log.d(TAG, "Preparing Temp files...");
           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");
       }

       /**
        * Destroys temp required files
        */
       private void destroyTempFiles() {
           Log.d(TAG, "Destroying Temp files...");
           pcmtowavTempFile.delete();
           mp3towavTempFile.delete();
           combinedwavTempFile.delete();
           volumeChangedTempFile.delete();
           Log.d(TAG, "Destroying files completed!");
       }


       /**
        * 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(TAG, "All files are not set! Set all files!");
               throw new RuntimeException("Output file is not present!");
           }
           Log.d(TAG, "All files are present!");
           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 void setVideoRecordingLength(int seconds) {
           this.videoRecordingLength = seconds;
       }

       /**
        * Quits current processing ffmpeg task
        */
       public void killCurrentTask() {
           if (currentTask != null) {
               currentTask.killRunningProcess();
           }
       }

       public interface AudioProcessorListener {
           void onStart();
           void onSuccess(File output);
           void onError(String message);
           void onFinish();
       }
    }
  • avformat/matroskadec : Compactify structure

    17 mai 2019, par Andreas Rheinhardt
    avformat/matroskadec : Compactify structure
    

    Matroska EBML IDs can be only four bytes long maximally, so it is
    natural to use uint32_t for them. By doing this and rearranging the
    elements of the MatroskaLevel1Element structure, one can reduce the size
    of said structure.

    Notice that this field is not read via the generic reading process for
    EBML_UINT, so one is not forced to use an uint64_t for it.

    Signed-off-by : Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
    Signed-off-by : Michael Niedermayer <michael@niedermayer.cc>

    • [DH] libavformat/matroskadec.c