Recherche avancée

Médias (10)

Mot : - Tags -/wav

Autres articles (71)

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

  • MediaSPIP version 0.1 Beta

    16 avril 2011, par

    MediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Pour avoir une installation fonctionnelle, 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 (...)

  • La file d’attente de SPIPmotion

    28 novembre 2010, par

    Une file d’attente stockée dans la base de donnée
    Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
    Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...)

Sur d’autres sites (9294)

  • Reading mp3 file using ffmpeg caues memory leaks, even after freeing it in main

    12 août 2020, par leonardltk1

    i am continuously reading mp3 files and processing them, but the memory keeps getting build up even though i freed it.

    


    At the bottom read_audio_mp3(), they are already freeing some variable.
why do i still face a memory build up and how do i deal with it ?

    


    following this code : https://rodic.fr/blog/libavcodec-tutorial-decode-audio-file/, i read mp3 using this function

    


        int read_audio_mp3(string filePath_str, const int sample_rate, 
      double** output_buffer, int &AUDIO_DURATION){
      const char* path = filePath_str.c_str();

      /* Reads the file header and stores information about the file format. */
        AVFormatContext* format = avformat_alloc_context();
        if (avformat_open_input(&format, path, NULL, NULL) != 0) {
            fprintf(stderr, "Could not open file '%s'\n", path);
            return -1;
        }

      /* Check out the stream information in the file. */
        if (avformat_find_stream_info(format, NULL) < 0) {
            fprintf(stderr, "Could not retrieve stream info from file '%s'\n", path);
            return -1;
        }

      /* find an audio stream. */
        int stream_index =- 1;
        for (unsigned i=0; inb_streams; i++) {
          if (format->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
            stream_index = i;
            break;
          }
        }
        if (stream_index == -1) {
            fprintf(stderr, "Could not retrieve audio stream from file '%s'\n", path);
            return -1;
        }
        AVStream* stream = format->streams[stream_index];

      // find & open codec
        AVCodecContext* codec = stream->codec;
        if (avcodec_open2(codec, avcodec_find_decoder(codec->codec_id), NULL) < 0) {
            fprintf(stderr, "Failed to open decoder for stream #%u in file '%s'\n", stream_index, path);
            return -1;
        }

      // prepare resampler
        struct SwrContext* swr = swr_alloc();
        av_opt_set_int(swr, "in_channel_count",  codec->channels, 0);
        av_opt_set_int(swr, "out_channel_count", 1, 0);
        av_opt_set_int(swr, "in_channel_layout",  codec->channel_layout, 0);
        av_opt_set_int(swr, "out_channel_layout", AV_CH_LAYOUT_MONO, 0);
        av_opt_set_int(swr, "in_sample_rate", codec->sample_rate, 0);
        av_opt_set_int(swr, "out_sample_rate", sample_rate, 0);
        av_opt_set_sample_fmt(swr, "in_sample_fmt",  codec->sample_fmt, 0);
        av_opt_set_sample_fmt(swr, "out_sample_fmt", AV_SAMPLE_FMT_DBL,  0);
        swr_init(swr);
        if (!swr_is_initialized(swr)) {
            fprintf(stderr, "Resampler has not been properly initialized\n");
            return -1;
        }

      /* Allocate an audio frame. */
        AVPacket packet;
        av_init_packet(&packet);
        AVFrame* frame = av_frame_alloc();
        if (!frame) {
          fprintf(stderr, "Error allocating the frame\n");
          return -1;
        }

      // iterate through frames
        *output_buffer = NULL;
        AUDIO_DURATION = 0;
        while (av_read_frame(format, &packet) >= 0) {
          // decode one frame
            int gotFrame;
            if (avcodec_decode_audio4(codec, frame, &gotFrame, &packet) < 0) {
              // free packet
                av_free_packet(&packet);
                break;
            }
            if (!gotFrame) {
              // free packet
                av_free_packet(&packet);
                continue;
            }
          // resample frames
            double* buffer;
            av_samples_alloc((uint8_t**) &buffer, NULL, 1, frame->nb_samples, AV_SAMPLE_FMT_DBL, 0);
            int frame_count = swr_convert(swr, (uint8_t**) &buffer, frame->nb_samples, (const uint8_t**) frame->data, frame->nb_samples);
          // append resampled frames to output_buffer
            *output_buffer = (double*) realloc(*output_buffer,
             (AUDIO_DURATION + frame->nb_samples) * sizeof(double));
            memcpy(*output_buffer + AUDIO_DURATION, buffer, frame_count * sizeof(double));
            AUDIO_DURATION += frame_count;
          // free buffer & packet
            av_free_packet(&packet);
            av_free( buffer );
        }

      // clean up
        av_frame_free(&frame);
        swr_free(&swr);
        avcodec_close(codec);
        avformat_free_context(format);

      return 0;
    }


    


    Main Script : MemoryLeak.cpp

    


        // imports&#xA;      #include <fstream>&#xA;      #include &#xA;      #include &#xA;      #include &#xA;      #include &#xA;      #include <iostream>&#xA;      #include <sstream>&#xA;      #include <vector>&#xA;      #include <sys></sys>time.h> &#xA;      extern "C"&#xA;      {&#xA;      #include <libavutil></libavutil>opt.h>&#xA;      #include <libavcodec></libavcodec>avcodec.h>&#xA;      #include <libavformat></libavformat>avformat.h>&#xA;      #include <libswresample></libswresample>swresample.h>&#xA;      }&#xA;      using namespace std;&#xA;&#xA;    int main (int argc, char ** argv) {&#xA;      string wavpath = argv[1];&#xA;      printf("wavpath=%s\n", wavpath.c_str());&#xA;&#xA;      printf("\n==== Params =====\n");&#xA;      // Init&#xA;        int AUDIO_DURATION;&#xA;        int sample_rate = 8000;&#xA;        av_register_all();&#xA;&#xA;      printf("\n==== Reading MP3 =====\n");&#xA;        while (true) {&#xA;            // Read mp3&#xA;              double* buffer;&#xA;              if (read_audio_mp3(wavpath, sample_rate, &amp;buffer, AUDIO_DURATION) != 0) {&#xA;                printf("Cannot read %s\n", wavpath.c_str());&#xA;                continue;&#xA;              }&#xA;&#xA;            /* &#xA;              Process the buffer for down stream tasks.&#xA;            */&#xA;&#xA;            // Freeing the buffer&#xA;            free(buffer);&#xA;        }&#xA;&#xA;      return 0 ;&#xA;    }&#xA;</vector></sstream></iostream></fstream>

    &#xA;

    Compiling

    &#xA;

        g&#x2B;&#x2B; -o ./MemoryLeak.out -Ofast -Wall -Wextra \&#xA;        -std=c&#x2B;&#x2B;11 "./MemoryLeak.cpp" \&#xA;        -lavformat -lavcodec -lavutil -lswresample&#xA;

    &#xA;

    Running, by right my input an argument wav.scp that reads text file of all the mp3s.&#xA;But for easy to replicate purpose, i only read 1 file song.mp3 in and i keep re-reading it

    &#xA;

    ./MemoryLeak.out song.mp3&#xA;

    &#xA;

    Why do i know i have memory leaks ?

    &#xA;

      &#xA;
    1. I was running up 32 jobs in parallel for 14 million files, and when i wake up in the morning, they were abruptly killed.
    2. &#xA;

    3. I run htop and i monitor the progress when i re-run it, and i saw that the VIRT & RES & Mem are continuously increasing.
    4. &#xA;

    &#xA;

    &#xA;

    Edit 1 :&#xA;My setup :

    &#xA;

    &#xA;

    ffmpeg version 2.8.15-0ubuntu0.16.04.1&#xA;built with gcc 5.4.0&#xA;

    &#xA;

  • Add metadata while converting MKV to MP3 with FFMPEG

    17 août 2020, par Elderhoard

    I am trying to convert MKV files to MP3, while adding metadata and album artwork through a batch file. I am generating a PNG through FFMPEG, then converting to MP3 while adding metadata, and finally adding the album artwork i got initially.

    &#xA;

    I have tried adding the metadata while converting to MP3 and while adding the artwork to no avail. I read something about it flushing the buffer too quickly but thought I might be able to get around it by adding it while converting it.

    &#xA;

    Individually, all parts work, but I can't get it to add the title and artist to the metadata, or at least in a place where VLC can read it. any suggestions ?

    &#xA;

    @echo off&#xA;::Extracts a PNG thumbnail &#xA;for %%A in ("*.mkv") do (ffmpeg -ss 30 -i "%%A" -qscale:v 4 -frames:v 1 "%%~nA.png")&#xA;&#xA;::Convert from MKV to MP3 and adds title and artist based on file name delimited by "-" eg Metallica - Enter Sandman.mkv&#xA;SETLOCAL ENABLEDELAYEDEXPANSION&#xA;for %%A in ("*.mkv") do (&#xA;    set filename=%%~nA&#xA;    set artist=&#xA;    set song=&#xA;    echo "!filename!"&#xA;&#xA;    for /F "tokens=1,2 delims=-" %%G in ("!filename!") do (&#xA;        set artist="%%G"&#xA;        set song="%%H"&#xA;        echo !artist!&#xA;        echo !song!&#xA;    )&#xA;&#xA;    echo !song! by !artist!&#xA;&#xA;    ffmpeg -i "%%A" -b:a 192K -id3v2_version 4 -write_id3v2 1 -metadata title="%song%" -metadata artist="%artist%" -flush_packets 0 -vn "%%~nA.mp3"&#xA;)&#xA;&#xA;::Add Artwork to MP3&#xA;for %%A in ("*.mp3") do (ffmpeg -i "%%A" -i "%%~nA.png" -map 0:0 -map 1:0 -c copy -id3v2_version 3 "UPDATED%%~nA.mp3")&#xA;

    &#xA;

  • Trouble with converting webm into mp3 with pydub in python

    15 août 2020, par rc_marty

    so basically I want to convert song what I downloaded from youtube in webm and convert to into mp3

    &#xA;

    when I wanted export song just with song.export("neco.mp3") it didn't work too

    &#xA;

    I have in workfolder ffmpeg.exe and ffprobe.exe

    &#xA;

    here is the code

    &#xA;

    from pydub import AudioSegment&#xA;&#xA;song = AudioSegment.from_file(downloaded.webm,"webm")&#xA;print("Loaded")&#xA;song.export("neco.mp3", format="mp3", bitrate="320k")&#xA;print("Converted and saved")&#xA;

    &#xA;

    here is the output of the console

    &#xA;

    Loaded&#xA;Traceback (most recent call last):&#xA;  File "e:/martan/projekty/Python/programek na pisnicky/songDownloader.py", line 188, in <module>&#xA;    song.export("neco.mp3", format="mp3", bitrate="320k")&#xA;  File "C:\Users\BIBRAIN\AppData\Local\Programs\Python\Python38\lib\site-packages\pydub\audio_segment.py", line 911, in export&#xA;    raise CouldntEncodeError(&#xA;pydub.exceptions.CouldntEncodeError: Encoding failed. ffmpeg/avlib returned error code: 1&#xA;&#xA;Command:[&#x27;ffmpeg&#x27;, &#x27;-y&#x27;, &#x27;-f&#x27;, &#x27;wav&#x27;, &#x27;-i&#x27;, &#x27;C:\\Users\\BIBRAIN\\AppData\\Local\\Temp\\tmpo20ooz_z&#x27;, &#x27;-b:a&#x27;, &#x27;320k&#x27;, &#x27;-f&#x27;, &#x27;mp3&#x27;, &#x27;C:\\Users\\BIBRAIN\\AppData\\Local\\Temp\\tmpiqpl57g7&#x27;]&#xA;&#xA;Output from ffmpeg/avlib:&#xA;&#xA;ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers&#xA;  built with gcc 10.2.1 (GCC) 20200726&#xA;  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libgsm --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf&#xA;  libavutil      56. 51.100 / 56. 51.100&#xA;  libavcodec     58. 91.100 / 58. 91.100&#xA;  libavformat    58. 45.100 / 58. 45.100&#xA;  libavdevice    58. 10.100 / 58. 10.100&#xA;  libavfilter     7. 85.100 /  7. 85.100&#xA;  libswscale      5.  7.100 /  5.  7.100&#xA;  libswresample   3.  7.100 /  3.  7.100&#xA;  libpostproc    55.  7.100 / 55.  7.100&#xA;Guessed Channel Layout for Input Stream #0.0 : stereo&#xA;Input #0, wav, from &#x27;C:\Users\BIBRAIN\AppData\Local\Temp\tmpo20ooz_z&#x27;:&#xA;  Duration: 00:03:54.71, bitrate: 3072 kb/s&#xA;    Stream #0:0: Audio: pcm_s32le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s32, 3072 kb/s&#xA;Stream mapping:&#xA;  Stream #0:0 -> #0:0 (pcm_s32le (native) -> mp3 (mp3_mf))&#xA;Press [q] to stop, [?] for help&#xA;[mp3_mf @ 00000000004686c0] could not find any MFT for the given media type&#xA;[mp3_mf @ 00000000004686c0] could not create MFT&#xA;Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height&#xA;Conversion failed!&#xA;</module>

    &#xA;

    I think it is something with codec but I have no idea what to do

    &#xA;