Recherche avancée

Médias (91)

Autres articles (67)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

  • Ecrire une actualité

    21 juin 2013, par

    Présentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
    Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
    Vous pouvez personnaliser le formulaire de création d’une actualité.
    Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)

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

Sur d’autres sites (5373)

  • Evolution #3015 : Joindre document sur article, par défaut

    25 octobre 2013, par guytarr °

    Après quelques essais de visu :
    En 1.9.x, on a une boite de formulaire pour ajouter une image, une boite de formulaire pour ajouter un document (pour ce dernier, si "autorisé" dans la configuration, oui par défaut). r9462 simplifie en ne laissant plus que la boite de formulaire "ajouter une image" par défaut.

    Dans les versions supérieures, on a toujours la boite de formulaire "ajouter une image", et elle devient "ajouter une image ou un document" si "autorisé" dans la configuration, non par défaut. Je ne sais pas quand ça a été mis en place mais c’est postérieur à r9462, et c’est à ce moment qu’il aurait fallu rétablir l’activation des documents par défaut sur les articles, puisque l’espace privé n’en est pas plus "alourdi".

    Puisqu’on a plus qu’une boite dans tous les cas, du coup la simplification initiale de r9462 combinée à l’unicité de la boite de formulaire amène plus de confusion qu’autre chose. J’ai l’impression qu’il y a eu collision dans les simplifications, l’une ne prenant pas en compte la précédente et que l’on laisse courir depuis SPIP 2.0. Me trompe-je ? Y a t-il un historien du commit dans la place ?

    Je pense qu’on peut rectifier le tir à partir de SPIP 2.0 et qu’on active par défaut à l’installation ces fichus documents. Et vive pénélope :)

  • Evolution #3015 : Joindre document sur article, par défaut

    17 octobre 2013, par guytarr °

    Samuel Delacre a écrit :

    [...] N’étant pas encore totalement rodé aux nouveautés de SPIP3, et pas encore familier aux différences "spipienne" entre images et documents, je ne pensais pas que cette option de contenu concernait les images également. Enfin les documents dans le cas présent.
    [...]

    Hello,
    En fait, ce n’est pas une nouveauté de SPIP3 mais de SPIP2.
    Si l’on regarde comment est renseignée la méta (pour les documents sur les articles) en 1.9.2 :
    http://core.spip.org/projects/spip/repository/entry/branches/spip-1.9.2/ecrire/inc/config.php#L65
    C’est à partir de SPIP 2.0 qu’elle change :
    http://core.spip.org/projects/spip/repository/entry/branches/spip-2.0/ecrire/inc/config.php#L86

    Le commit qui explique le pourquoi du comment et les tickets liés est notre cher r9462
    Bien sûr on peut défaire pour refaire puis redéfaire, il faudrait juste se mettre d’accord à un moment.

  • Decoding pcm_s16le with FFMPEG ?

    9 juin, par Davide Caresia

    i have a problem decoding a wav file using ffmpeg. I'm new to it and i'm not quite used to it.

    


    In my application i have to input the audio file and get an array of samples to work on.
I used ffmpeg to create a function that gets in input the path of the file, the position in time where to start to output the samples and the lenght of the chunk to decode in seconds.

    


    When I try to decode the file harp.wav everything runs fine, and I can plot the samples as in the image plot-harp.png

    


    The file is a WAV file encoded as : pcm_u8, 11025 Hz, 1 channels, u8, 88 kb/s

    


    The problems comes when i try to decode the file demo-unprocessed.wav.
It outputs a series of samples that has no sense. It outputs a serie of samples plotted as the image graph1-demo.jpg shows.

    


    The file is a WAV file encoded as : pcm_s16le, 44100 Hz, 1 channels, s16, 705 kb/s

    


    IDK where the problem in my code is, I already checked the code before and after the decoding with FFMPEG, and it works absolutely fine.

    


    Here is the code for the dataReader.cpp :

    


    /* Start by including the necessary */&#xA;#include "dataReader.h"&#xA;#include <cstdlib>&#xA;#include <iostream>&#xA;#include <fstream>&#xA;&#xA;#ifdef __cplusplus&#xA;extern "C" {&#xA;#endif&#xA;    #include <libavcodec></libavcodec>avcodec.h> &#xA;    #include <libavformat></libavformat>avformat.h>&#xA;    #include <libavutil></libavutil>avutil.h>&#xA;#ifdef __cplusplus &#xA;}&#xA;#endif&#xA;&#xA;using namespace std;&#xA;&#xA;/* initialization function for audioChunk */&#xA;audioChunk::audioChunk(){&#xA;    data=NULL;&#xA;    size=0;&#xA;    bitrate=0;&#xA;}&#xA;&#xA;/* function to get back chunk lenght in seconds */&#xA;int audioChunk::getTimeLenght(){&#xA;    return size/bitrate;&#xA;}&#xA;&#xA;/* initialization function for audioChunk_dNorm */&#xA;audioChunk_dNorm::audioChunk_dNorm(){&#xA;    data=NULL;&#xA;    size=0;&#xA;    bitrate=0;&#xA;}&#xA;&#xA;/* function to get back chunk lenght in seconds */&#xA;int audioChunk_dNorm::getTimeLenght(){&#xA;    return size/bitrate;&#xA;}&#xA;&#xA;/* function to normalize audioChunk into audioChunk_dNorm */&#xA;void audioChunk_dNorm::fillAudioChunk(audioChunk* cnk){&#xA;&#xA;    size=cnk->size;&#xA;    bitrate=cnk->bitrate;&#xA;&#xA;    double min=cnk->data[0];&#xA;    double max=cnk->data[0];&#xA;&#xA;    for(int i=0;isize;i&#x2B;&#x2B;){&#xA;        if(*(cnk->data&#x2B;i)>max) max=*(cnk->data&#x2B;i);&#xA;        else if(*(cnk->data&#x2B;i)data&#x2B;i);&#xA;    }&#xA;&#xA;    data=new double[size];&#xA;&#xA;    for(int i=0;i/data[i]=cnk->data[i]&#x2B;256*data[i&#x2B;1];&#xA;        if(data[i]!=255) data[i]=2*((cnk->data[i])-(max-min)/2)/(max-min);&#xA;        else data[i]=0;&#xA;    }&#xA;    cout&lt;&lt;"bitrate "&lt;* inizialize audioChunk */&#xA;    audioChunk output;&#xA;&#xA;    /* Check input times */&#xA;    if((start_time&lt;0)||(lenght&lt;0)) {&#xA;        cout&lt;&lt;"Input times should be positive";&#xA;        return output;&#xA;    }&#xA;&#xA;    /* Start FFmpeg */&#xA;    av_register_all();&#xA;&#xA;    /* Initialize the frame to read the data and verify memory allocation */&#xA;    AVFrame* frame = av_frame_alloc();&#xA;    if (!frame)&#xA;    {&#xA;        cout &lt;&lt; "Error allocating the frame" &lt;&lt; endl;&#xA;        return output;&#xA;    }&#xA;&#xA;    /* Initialization of the Context, to open the file */&#xA;    AVFormatContext* formatContext = NULL;&#xA;    /* Opening the file, and check if it has opened */&#xA;    if (avformat_open_input(&amp;formatContext, path_name, NULL, NULL) != 0)&#xA;    {&#xA;        av_frame_free(&amp;frame);&#xA;        cout &lt;&lt; "Error opening the file" &lt;&lt; endl;&#xA;        return output;&#xA;    }&#xA;&#xA;    /* Find the stream info, if not found, exit */&#xA;    if (avformat_find_stream_info(formatContext, NULL) &lt; 0)&#xA;    {&#xA;        av_frame_free(&amp;frame);&#xA;        avformat_close_input(&amp;formatContext);&#xA;        cout &lt;&lt; "Error finding the stream info" &lt;&lt; endl;&#xA;        return output;&#xA;    }&#xA;&#xA;    /* Check inputs to verify time input */&#xA;    if(start_time>(formatContext->duration/1000000)){&#xA;        cout&lt;&lt; "Error, start_time is over file duration"&lt;* Chunk = number of samples to output */&#xA;    long long int chunk = ((formatContext->bit_rate)*lenght/8);&#xA;    /* Start = address of sample where start to read */&#xA;    long long int start = ((formatContext->bit_rate)*start_time/8);&#xA;    /* Tot_sampl = number of the samples in the file */&#xA;    long long int tot_sampl = (formatContext->bit_rate)*(formatContext->duration)/8000000;&#xA;&#xA;    /* Set the lenght of chunk to avoid segfault and to read all the file */&#xA;    if (start&#x2B;chunk>tot_sampl) {chunk = tot_sampl-start;}&#xA;    if (lenght==0) {start = 0; chunk = tot_sampl;}&#xA;&#xA;    /* initialize the array to output */&#xA;    output.data = new unsigned char[chunk];&#xA;    output.bitrate = formatContext->bit_rate;&#xA;    output.size=chunk;&#xA;&#xA;    av_dump_format(formatContext,0,NULL,0);&#xA;    cout&lt;* Find the audio Stream, if no audio stream are found, clean and exit */&#xA;    AVCodec* cdc = NULL;&#xA;    int streamIndex = av_find_best_stream(formatContext, AVMEDIA_TYPE_AUDIO, -1, -1, &amp;cdc, 0);&#xA;    if (streamIndex &lt; 0)&#xA;    {&#xA;        av_frame_free(&amp;frame);&#xA;        avformat_close_input(&amp;formatContext);&#xA;        cout &lt;&lt; "Could not find any audio stream in the file" &lt;&lt; endl;&#xA;        return output;&#xA;    }&#xA;&#xA;    /* Open the audio stream to read data  in audioStream */&#xA;    AVStream* audioStream = formatContext->streams[streamIndex];&#xA;&#xA;    /* Initialize the codec context */&#xA;    AVCodecContext* codecContext = audioStream->codec;&#xA;    codecContext->codec = cdc;&#xA;    /* Open the codec, and verify if it has opened */&#xA;    if (avcodec_open2(codecContext, codecContext->codec, NULL) != 0)&#xA;    {&#xA;        av_frame_free(&amp;frame);&#xA;        avformat_close_input(&amp;formatContext);&#xA;        cout &lt;&lt; "Couldn&#x27;t open the context with the decoder" &lt;&lt; endl;&#xA;        return output;&#xA;    }&#xA;&#xA;    /* Initialize buffer to store compressed packets */&#xA;    AVPacket readingPacket;&#xA;    av_init_packet(&amp;readingPacket);&#xA;&#xA;&#xA;    int j=0;&#xA;    int count = 0; &#xA;&#xA;    while(av_read_frame(formatContext, &amp;readingPacket)==0){&#xA;        if((count&#x2B;readingPacket.size)>start){&#xA;            if(readingPacket.stream_index == audioStream->index){&#xA;&#xA;                AVPacket decodingPacket = readingPacket;&#xA;&#xA;                // Audio packets can have multiple audio frames in a single packet&#xA;                while (decodingPacket.size > 0){&#xA;                    // Try to decode the packet into a frame&#xA;                    // Some frames rely on multiple packets, so we have to make sure the frame is finished before&#xA;                    // we can use it&#xA;                    int gotFrame = 0;&#xA;                    int result = avcodec_decode_audio4(codecContext, frame, &amp;gotFrame, &amp;decodingPacket);&#xA;&#xA;                    count &#x2B;= result;&#xA;&#xA;                    if (result >= 0 &amp;&amp; gotFrame)&#xA;                    {&#xA;                        decodingPacket.size -= result;&#xA;                        decodingPacket.data &#x2B;= result;&#xA;                        int a;&#xA;&#xA;                        for(int i=0;idata[0][i];&#xA;&#xA;                            j&#x2B;&#x2B;;&#xA;                            if(j>=chunk) break;&#xA;                        }&#xA;&#xA;                        // We now have a fully decoded audio frame&#xA;                    }&#xA;                    else&#xA;                    {&#xA;                        decodingPacket.size = 0;&#xA;                        decodingPacket.data = NULL;&#xA;                    }&#xA;                    if(j>=chunk) break;&#xA;                }&#xA;            }              &#xA;        }else count&#x2B;=readingPacket.size;&#xA;&#xA;        // To prevent memory leak, must free packet.&#xA;        av_free_packet(&amp;readingPacket);&#xA;        if(j>=chunk) break;&#xA;    }&#xA;&#xA;    // Some codecs will cause frames to be buffered up in the decoding process. If the CODEC_CAP_DELAY flag&#xA;    // is set, there can be buffered up frames that need to be flushed, so we&#x27;ll do that&#xA;    if (codecContext->codec->capabilities &amp; CODEC_CAP_DELAY)&#xA;    {&#xA;        av_init_packet(&amp;readingPacket);&#xA;        // Decode all the remaining frames in the buffer, until the end is reached&#xA;        int gotFrame = 0;&#xA;        int a;&#xA;        int result=avcodec_decode_audio4(codecContext, frame, &amp;gotFrame, &amp;readingPacket);&#xA;        while (result >= 0 &amp;&amp; gotFrame)&#xA;        {&#xA;            // We now have a fully decoded audio frame&#xA;            for(int i=0;idata[0][i];&#xA;&#xA;                j&#x2B;&#x2B;;&#xA;                if(j>=chunk) break;&#xA;            }&#xA;            if(j>=chunk) break;&#xA;        }&#xA;    }&#xA;&#xA;    // Clean up!&#xA;    av_free(frame);&#xA;    avcodec_close(codecContext);&#xA;    avformat_close_input(&amp;formatContext);&#xA;&#xA;    cout&lt;&lt;"Ended Reading, "&lt;code></fstream></iostream></cstdlib>

    &#xA;

    Here is the dataReader.h

    &#xA;

    /* &#xA; * File:   dataReader.h&#xA; * Author: davide&#xA; *&#xA; * Created on 27 luglio 2015, 11.11&#xA; */&#xA;&#xA;#ifndef DATAREADER_H&#xA;#define DATAREADER_H&#xA;&#xA;/* function that reads a file and outputs an array of samples&#xA; * @ path_name = the path of the file to read&#xA; * @ start_time = the position where to start the data reading, 0 = start&#xA; *                the time is in seconds, it can hold to 10e-6 seconds&#xA; * @ lenght = the lenght of the frame to extract the data, &#xA; *            0 = read all the file (do not use with big files)&#xA; *            if lenght > of file duration, it reads through the end of file.&#xA; *            the time is in seconds, it can hold to 10e-6 seconds  &#xA; */&#xA;&#xA;#include &#xA;&#xA;class audioChunk{&#xA;public:&#xA;    uint8_t *data;&#xA;    unsigned int size;&#xA;    int bitrate;&#xA;    int getTimeLenght();&#xA;    audioChunk();&#xA;};&#xA;&#xA;class audioChunk_dNorm{&#xA;public:&#xA;    double* data;&#xA;    unsigned int size;&#xA;    int bitrate;&#xA;    int getTimeLenght();&#xA;    void fillAudioChunk(audioChunk* cnk);&#xA;    audioChunk_dNorm();&#xA;};&#xA;&#xA;audioChunk readData(const char* path_name, const double start_time, const double lenght);&#xA;&#xA;#endif  /* DATAREADER_H */&#xA;

    &#xA;

    And finally there is the main.cpp of the application.

    &#xA;

    /* &#xA; * File:   main.cpp&#xA; * Author: davide&#xA; *&#xA; * Created on 28 luglio 2015, 17.04&#xA; */&#xA;&#xA;#include <cstdlib>&#xA;#include "dataReader.h"&#xA;#include "transforms.h"&#xA;#include "tognuplot.h"&#xA;#include <fstream>&#xA;#include <iostream>&#xA;&#xA;using namespace std;&#xA;&#xA;/*&#xA; * &#xA; */&#xA;int main(int argc, char** argv) {&#xA;&#xA;    audioChunk *chunk1=new audioChunk;&#xA;&#xA;    audioChunk_dNorm *normChunk1=new audioChunk_dNorm;&#xA;&#xA;    *chunk1=readData("./audio/demo-unprocessed.wav",0,1);&#xA;&#xA;    normChunk1->fillAudioChunk(chunk1);&#xA;&#xA;    ofstream file1;&#xA;    file1.open("./file/2wave.txt", std::ofstream::trunc);&#xA;    if(file1.is_open()) {&#xA;        for(int i=0;isize;i&#x2B;&#x2B;) {&#xA;            int a=chunk1->data[i];&#xA;            file1&lt;code></iostream></fstream></cstdlib>

    &#xA;

    I can't understand why the outputs goes like this. Is it possible that the decoder can't convert the samples (pcm_16le, 16bits) into FFMPEG AVFrame.data, that stores the samples ad uint8_t ? And if it is it is there some way to make FFMPEG work for audio files that stores samples at more than 8 bits ?

    &#xA;

    The file graph1-demo_good.jpg is how the samples should be, extracted with a working LIBSNDFILE application that I made.

    &#xA;

    EDIT : Seems like the program can't convert the decoded data, couples of little endian bytes stored in a couple of uint8_t unsigned char, into the destination format (that i set as unsigned char[]), because it stores the bits as little-endian 16 bytes. So the data into audioChunk.data is right, but I have to read it not as an unsigned char, but as a couple of little-endian bytes.

    &#xA;