Recherche avancée

Médias (1)

Mot : - Tags -/belgique

Autres articles (29)

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 est la première version de MediaSPIP stable.
    Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Comme pour la version précédente, 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 (...)

  • Mise à disposition des fichiers

    14 avril 2011, par

    Par défaut, lors de son initialisation, MediaSPIP ne permet pas aux visiteurs de télécharger les fichiers qu’ils soient originaux ou le résultat de leur transformation ou encodage. Il permet uniquement de les visualiser.
    Cependant, il est possible et facile d’autoriser les visiteurs à avoir accès à ces documents et ce sous différentes formes.
    Tout cela se passe dans la page de configuration du squelette. Il vous faut aller dans l’espace d’administration du canal, et choisir dans la navigation (...)

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

Sur d’autres sites (2405)

  • Trying to decode and encode audio files with the FFMPEG C API

    1er février 2023, par Giulio Iacomino

    My ultimate goal will be to split multi channel WAV files into single mono ones, after few days of experiments my plan is the sequence :

    


      

    1. Decode audio file into a frame.
    2. 


    3. Convert interleaved frame into a planar one. (in order to separate the data buffer into multiple ones)
    4. 


    5. Grab the planar frame buffers and encode each of them into a new file.
    6. 


    


    So far I'm stuck trying to convert a wav file from interleaved to a planar one, and reprint the wav file.

    


    edit :
I've turned on guard malloc and apparently the error is within the convert function

    


    Here's the code :

    


    AVCodecContext* initializeAndOpenCodecContext(AVFormatContext* formatContext, AVStream* stream){
     // grab our stream, most audio files only have one anyway
    const AVCodec* decoder = avcodec_find_decoder(stream->codecpar->codec_id);
    if (!decoder){
        std::cout << "no decoder, can't go ahead!\n";
        return nullptr;
    }
    AVCodecContext* codecContext = avcodec_alloc_context3(decoder);
    avcodec_parameters_to_context(codecContext, stream->codecpar);
    int err = avcodec_open2(codecContext, decoder, nullptr);
    if (err < 0){
        std::cout << "couldn't open codex!\n";
    }
    return codecContext;
}

void initialiseResampler(SwrContext* resampler, AVFrame* inputFrame, AVFrame* outputFrame){
    av_opt_set_chlayout(resampler, "in_channel_layout", &inputFrame->ch_layout, 0);
    av_opt_set_chlayout(resampler, "out_channel_layout", &outputFrame->ch_layout, 0);
    av_opt_set_int(resampler, "in_sample_fmt", inputFrame->format, 0);
    av_opt_set_int(resampler, "out_sample_fmt", AV_SAMPLE_FMT_FLTP, 0);
    av_opt_set_int(resampler, "in_sample_rate", inputFrame->sample_rate, 0);
    av_opt_set_int(resampler, "out_sample_rate", outputFrame->sample_rate, 0);
}

AVFrame* initialisePlanarFrame(AVFrame* frameToInit, AVFrame* inputFrame){
    //AVFrame *planar_frame = av_frame_alloc();
    frameToInit->nb_samples = inputFrame->nb_samples;
    frameToInit->ch_layout = inputFrame->ch_layout;
    frameToInit->format = AV_SAMPLE_FMT_FLTP;
    frameToInit->sample_rate = inputFrame->sample_rate;
    return nullptr;
}

int main() {
    AVCodecContext *codingContext= NULL;
    const AVCodec *codec;
    codec = avcodec_find_encoder(AV_CODEC_ID_PCM_F32LE);
    codingContext = avcodec_alloc_context3(codec);
    codingContext->bit_rate = 16000;
    codingContext->sample_fmt = AV_SAMPLE_FMT_FLT;
    codingContext->sample_rate = 48000;
    codingContext->ch_layout.nb_channels = 2;
    codingContext->ch_layout.order = (AVChannelOrder)0;
    uint8_t **buffer_ = NULL;
    AVFrame* planar_frame = NULL;
    
    // open input
    AVFormatContext* formatContext = nullptr;
    int err = avformat_open_input(&formatContext, "/Users/tonytorm/Desktop/drum kits/DECAP - Drums That Knock Vol. 9/Kicks/Brash Full Metal Kick.wav", nullptr, nullptr);
    if (err < 0){
        fprintf(stderr, "Unable to open file!\n");
        return;
    }

    // find audio stream
    err = avformat_find_stream_info(formatContext, nullptr);
    if (err > 0){
        fprintf(stderr, "Unable to retrieve stream info!\n");
        return;
    }
    
    int index = av_find_best_stream(formatContext, AVMEDIA_TYPE_AUDIO, -1, -1, nullptr, 0);
    if (index < 0){
        std::cout<<  "coudn't find audio stream in this file" << '\n';
    }
    AVStream* stream = formatContext->streams[index];
    
    auto fileName = "/Users/tonytorm/Desktop/newFile.wav";
    FILE* newFile = fopen(fileName, "w+");
    
    // find right codec and open it
    if (auto openCodecContext = initializeAndOpenCodecContext(formatContext, stream)){
        AVPacket* packet = av_packet_alloc();
        AVFrame* frame = av_frame_alloc();
        AVFrame* planar_frame = av_frame_alloc();
        SwrContext *avr = swr_alloc();  //audio resampling context
        AVChannelLayout monoChannelLayout{(AVChannelOrder)0};
        monoChannelLayout.nb_channels = 2;
        

        while (!av_read_frame(formatContext, packet)){
            if (packet->stream_index != stream->index) continue;  // we only care about audio
            int ret = avcodec_send_packet(openCodecContext, packet);
            if ( ret < 0) {
                if (ret != AVERROR(EAGAIN)){   // if error is actual error not EAGAIN
                    std::cout << "can't do shit\n";
                    return;
                }
            }
            while (int bret = avcodec_receive_frame(openCodecContext, frame) == 0){
                initialisePlanarFrame(planar_frame, frame);
                
   
                
                int buffer_size_in = av_samples_get_buffer_size(nullptr,
                                                                frame->ch_layout.nb_channels,
                                                                frame->nb_samples,
                                                                (AVSampleFormat)frame->format,
                                                                0);
                int buffer_size_out = buffer_size_in/frame->ch_layout.nb_channels;

                //planar_frame->linesize[0] = buffer_size_out;
                
                int ret = av_samples_alloc(planar_frame->data,
                                           NULL,
                                           planar_frame->ch_layout.nb_channels,
                                           planar_frame->nb_samples,
                                           AV_SAMPLE_FMT_FLTP,
                                           0);
                
                initialiseResampler(avr, frame, planar_frame);
                if (int errRet = swr_init(avr) < 0) {
                    fprintf(stderr, "Failed to initialize the resampling context\n");
                }

                if (ret < 0){
                    char error_message[AV_ERROR_MAX_STRING_SIZE];
                    av_strerror(ret, error_message, AV_ERROR_MAX_STRING_SIZE);
                    fprintf(stderr, "Error allocating sample buffer: %s\n", error_message);
                    return -1;
                }
                
                int samples_converted = swr_convert(avr,
                                                    planar_frame->data,
                                                    buffer_size_out,
                                                    (const uint8_t **)frame->data,
                                                    buffer_size_in);
                if (samples_converted < 0) {
                    // handle error
                    std::cout << "error in conversion\n";
                    return;
                }
                if (avcodec_open2(codingContext, codec, NULL) < 0) {
                    std::cout << "can't encode!\n";
                    return;
                }
                AVPacket* nu_packet = av_packet_alloc();
                while (int copy = avcodec_send_frame(codingContext, planar_frame) != 0){
                    if (copy == AVERROR(EAGAIN) || copy == AVERROR_EOF){
                        std::cout << "can't encode file\n";
                        return;
                    }
                    if (avcodec_receive_packet(codingContext, nu_packet) >=0){
                        fwrite(nu_packet->data, 4, nu_packet->size, newFile);
                        //av_write_frame(avc, nu_packet);
                    }
                }
                av_freep(planar_frame->data);
                av_frame_unref(frame);
                av_frame_unref(planar_frame);
            }
//            av_packet_free(&packet);
//            av_packet_free(&nu_packet);
        }
        swr_free(&avr);
        avcodec_free_context(&codingContext);
        
    }
    fclose(newFile);
}


    


    I know i should write a header to the new wave file but for now I'm just trying to write the raw audio data. I'm getting always the same error but in different parts of the code (randomly), sometimes the code even compiles (writing the raw audio data, but filling it with some rubbish as well, i end up with a data file that is thrice the original one, sometimes i end up with a slightly smaller file - i guess the raw audio without the headers), results are basically random.

    


    Here are some of the functions that trigger the error :

    


    int ret = av_samples_alloc(); //(this the most common one)
swr_convert()
av_freep();


    


    the error is :

    


    main(64155,0x101b5d5c0) malloc: Incorrect checksum for freed object 0x106802600: probably modified after being freed.
Corrupt value: 0x0
main(64155,0x101b5d5c0) malloc: *** set a breakpoint in malloc_error_break to debug */


    


  • OpenShift — installing ffmpeg

    2 juillet 2016, par aweeeezy

    I’m new to deploying web apps — I just started looking into hosting plans yesterday morning when I settled on OpenShift. I have my app running, but it depends on node-youtube-dl which returns this error when trying to download a video from a link :

    Error: Command failed: WARNING: m_djk1RQ2Ew: writing DASH m4a. Only some players support this container. Install ffmpeg or avconv to fix this automatically.
    ERROR: ffprobe or avprobe not found. Please install one.

    So I searched around for awhile and kept returning to the same list instructions for how to install ffmpeg on OpenShift :

    cd $OPENSHIFT_DATA_DIR
    mkdir bin
    wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
    wget http://ffmpeg.org/releases/ffmpeg-2.0.1.tar.gz

    tar -xvf yasm-1.2.0.tar.gz
    cd yasm-1.2.0
    ./configure --prefix=$OPENSHIFT_DATA_DIR/bin --bindir=$OPENSHIFT_DATA_DIR/bin
    make
    make install
    export PATH=$OPENSHIFT_DATA_DIR/bin:$PATH

    cd $OPENSHIFT_DATA_DIR
    tar -xvf ffmpeg-2.0.1.tar.gz
    cd ffmpeg-2.0.1
    ./configure --prefix=$OPENSHIFT_DATA_DIR/bin --bindir=$OPENSHIFT_DATA_DIR/bin
    make
    make install

    Now my ~/app-root/data has ffprobe in it as well as some other codec related things, but node-youtube-dl still returns the same error saying I don’t have the necessary codecs installed. Here’s a listing of the contents of my data directory on OpenShift :

    -rwxr-xr-x.  1  11024048 Jul  2 01:51 ffmpeg
    -rwxr-xr-x.  1  10967408 Jul  2 01:51 ffprobe
    -rwxr-xr-x.  1  10611184 Jul  2 01:51 ffserver
    drwx------. 10      4096 Jul  2 01:51 include
    drwx------.  3      4096 Jul  2 01:51 lib
    drwx------.  4        29 Jul  2 01:51 share
    -rwxr-xr-x.  1   2116650 Jul  2 01:15 vsyasm
    -rwxr-xr-x.  1   2115479 Jul  2 01:15 yasm
    -rwxr-xr-x.  1   2102821 Jul  2 01:15 ytasm

    I really want OpenShift to work because it’s the last step to finishing off this one app before I move onto new projects — I don’t want to switch to paid hosting that will allow me to install stuff because I won’t be ready to determine an appropriate plan until a few months from now. That leaves me with trying to get ffmpeg to compile properly on OpenShift...so either a) I’m ignorant and it has long since been determined to be impossible by the OpenShift community or b) I’m ignorant and there’s a simple thing I’m doing wrong when building my codec libraries.

    Anybody out there know what’s wrong or had success installing these codecs before ? I’d greatly appreciate some guidance !

  • Creating an ffmpeg html/php form process and need ffmpeg technical feedback

    7 juin 2016, par dave

    I have decided to create an input form for ffmpeg to go with my video uploader.

    This is for my video uploader plugin for a social site software. Users have told me that they want technical options for videos so they can choose the specific options they want including thumbnail options.

    I have been reading the ffmpeg docs most of the morning as well as watching some videos and i have come up with a rough draft of my form. The videos uploaded will more than likely be non gaming, personal and hobby videos.

    The goal here is to have a form that is easy enough for the non technical user, but technical for those that want the options. So i do plan to have a checkbox which allows the non technical user to skip the technical settings. This will result in a generic ffmpeg command with default settings. If they choose to use the technical specs then it will create a more specific ffmpeg command stream.

    here is what i have so far in the draft.

    select max size options ’50MB’,’100MB’,’200MB’,’500MB’,’650MB’,’750MB’,’1GB’,’2GB’,’3GB’

    input for thumbcapture in seconds maxlength 2 size 2

    input for video in ’mpg’,’wma’,’mov’,’flv’,’mp4’,’avi’,’qt’,’wmv’,’rm’

    option for video size ’200x100’,’320x240’,’560x315’,’640x360’,’853x480’,’1280x720’ not sure if i want to offer a custom slot or not.

    my thought here is that if they do not want the tech version of the form then the codecs will be b:v copy b:a copy (if that is the smart way to do it) or just left out and let ffmpeg decide what is best.

    ===== this is the technical part of the form =======

    select for acodec options copy, mp3, mp1, mp2, dnet, 28_8, wmav2, alac, cook

    select for vcodec option copy, ffv1, ms-cram, mpeg-4, rv40, wmv, xvid, mov, qt, avchd

    select for bitrate audio 32k, 64k, 128k

    select for bitrate video 1000k, 1200k, 1500k

    select for sampling rate 22050, 44100

    input for crf(mp4 out only) size 2 maxlength 2 minval 2 maxval 49

    input for avi quantanizer (avi out only) size 2 maxlength 2 minval 2 maxval 49

    ===== end technical form =====================

    select for video out ’avi’,’mp4’,’flv’

    that is what i have so far. How does that combination on the technical side look to you ffmpeg pros ?

    Any suggestions ? :)