Recherche avancée

Médias (91)

Autres articles (40)

  • Selection of projects using MediaSPIP

    2 mai 2011, par

    The examples below are representative elements of MediaSPIP specific uses for specific projects.
    MediaSPIP farm @ Infini
    The non profit organizationInfini develops hospitality activities, internet access point, training, realizing innovative projects in the field of information and communication technologies and Communication, and hosting of websites. It plays a unique and prominent role in the Brest (France) area, at the national level, among the half-dozen such association. Its members (...)

  • Sélection de projets utilisant MediaSPIP

    29 avril 2011, par

    Les exemples cités ci-dessous sont des éléments représentatifs d’usages spécifiques de MediaSPIP pour certains projets.
    Vous pensez avoir un site "remarquable" réalisé avec MediaSPIP ? Faites le nous savoir ici.
    Ferme MediaSPIP @ Infini
    L’Association Infini développe des activités d’accueil, de point d’accès internet, de formation, de conduite de projets innovants dans le domaine des Technologies de l’Information et de la Communication, et l’hébergement de sites. Elle joue en la matière un rôle unique (...)

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

  • Why does menconder fps rate does not work ?

    27 février 2016, par ACR

    I’m using mencoder to create a video out of some .png files. The problem is that the frame rate doesn’t change, regardless of the -fps flag. The output video has different time lengths (in their properties), but the video’s size and speed are always the same (regardless of the FPS chosen).

    I just want to create a shorted video by using higher FPS rates. In short, a "time-lapse" of my original set of images. What am I doing wrong with mencoder ? I’m using the following command :

    mencoder mf://./IMG/images*.png -mf w=800:h=600:fps=20:type=png -ovc copy -oac copy -o video.avi
  • Why menconder fps rate does not work ?

    2 mars 2016, par ACR

    I’m using mencoder to create a video out of some .png files. The problem is that the frame rate doesn’t change, regardless of the -fps flag. The output video has different time lengths (in their properties), but the video’s size and speed are always the same (regardless of the FPS chosen).

    I just want to create a shorted video by using higher FPS rates. In short, a "time-lapse" of my original set of images. What am I doing wrong with mencoder ? I’m using the following command :

    mencoder mf://./IMG/images*.png -mf w=800:h=600:fps=20:type=png -ovc copy -oac copy -o video.avi
  • FFMPEG MP3 decode and encode audio distortion

    5 avril 2016, par user3450380

    I’m trying to make a program that successfully decodes MP3 to PCM. To test this I’ve been re-encoding to MP3 to see if the audio matches up. The problem is when I play the re-encoded audio the songs are 30 seconds shorter than the original and at a noticeably higher pitch. However, if I decode and encode this new audio (the distorted one I just encoded), I get the exact same audio. The only thing I can think of is maybe I’m missing something in the header ? Thanks for any help ! Sorry for the weird code blocks, the trying to tab to make code blocks skipped across the web page.

    #define AUDIO_INBUF_SIZE 20480
    #define AUDIO_REFILL_THRESH 4096
    #define STD_SAMPLE_RATE 44100


    //check if given sample format is accepted by given codec
    static int check_sample_format(AVCodec* avco, enum AVSampleFormat sample_fmt)

    {

    const enum AVSampleFormat* p = avco->sample_fmts;

    while(*p != AV_SAMPLE_FMT_NONE)
    {
       if(*p == sample_fmt)
       {
           return 1;
       }
       p++;
    }
    return 0;
    }

    //if no sample rates in codec, selects the standard rate of 44100.

    //otherwise, highest suported sample rate is chosen
    static int select_sample_rate(AVCodec* avco)

    {

    const int* p;
    int best_sample_rate = 0;

    if(!(avco->supported_samplerates))
    {
       return STD_SAMPLE_RATE;
    }

    p = avco->supported_samplerates;

    while(*p)
    {
       best_sample_rate = FFMAX(*p, best_sample_rate);
       p++;
    }

    return best_sample_rate;
    }

    //select layout with the highest channel count

    static int select_channel_layout(AVCodec* codec)

    {

    const uint64_t* p;
    uint64_t best_ch_layout = 0;
    int best_nb_channels = 0;

    if(!codec->channel_layouts)
    {
       return AV_CH_LAYOUT_STEREO;
    }

    p = codec->channel_layouts;
    while(*p)
    {
       int nb_channels = av_get_channel_layout_nb_channels(*p);

       if(nb_channels > best_nb_channels)
       {
           best_ch_layout = *p;
           best_nb_channels = nb_channels;
       }
       p++;
    }
    return best_ch_layout;

    }

    static int file_format_check(AVFormatContext* pFormatCtx, const char* song_path, FILE* infile)

    {

    AVCodecContext* codecCtx = NULL;
    AVCodec* inputCodec = NULL;
    int audioStreamIndex, i = 0;

    //open audio file
    if(avformat_open_input(&pFormatCtx, song_path, NULL, NULL) != 0)
    {
       return -1;
    }

    //open binary file for reading
    infile = fopen(song_path, "rb");


    if(!infile)
    {
       fprintf(stderr, "Input file not opened!");
       return -1;
    }


    if(avformat_find_stream_info(pFormatCtx, NULL))
    {
       fprintf(stderr, "Stream info not found!");
       return -1;
    }

    //dumps info about format context to standard error
    av_dump_format(pFormatCtx, 0, /*argv[1]*/0, 0);

    //find audio stream
    for(i = 0; i < pFormatCtx->nb_streams; i++){
       if(pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
       {
           audioStreamIndex = i;
           printf("Audio Stream Found!\n");
           break;
       }
    }

    if(audioStreamIndex == -1)
    {
       return -1;
    }

    //set codec context pointer to codec context of audio stream
    codecCtx = pFormatCtx->streams[audioStreamIndex]->codec;
    //find decodeder for audio stream
    inputCodec = avcodec_find_decoder(codecCtx->codec_id);
    if (inputCodec == NULL)
    {
       fprintf(stderr, "Unsupported codec!\n");
       return -1;
    }

    //open codec
    if(avcodec_open2(codecCtx, inputCodec, NULL) < 0)
    {
       fprintf(stderr, "Codec could not be opened!");
       return -1;
    }


    return audioStreamIndex;

    }

    int main(int argc, const char * argv[])
    {

    //refister all available file formats and codecs
    av_register_all();

    FILE *infile, *outfile;
    int i, len, ret, audioStreamIndex = -1;
    const char* song_path = "/Users/timothyrice/Dropbox/audio-experimentation/audio_playground/audio_playground/Monsters.mp3";
    const char* new_format_path = "/Users/timothyrice/Dropbox/audio-experimentation/audio_playground/audio_playground/new_audio.mp3";


    AVFormatContext* inputFormat = avformat_alloc_context();
    AVFormatContext* outputFormat = avformat_alloc_context();

    AVCodecContext* decodeCodecCtx;
    AVPacket decodingPacket;
    AVFrame* decodedFrame = NULL;

    AVCodec* encodeCodec = NULL;
    AVCodecContext* encodeCodecCtx = NULL;
    AVPacket encodingPacket;


    audioStreamIndex = file_format_check(inputFormat, song_path, infile);

    if(audioStreamIndex < 0)
    {
       return -1;
    }

    av_init_packet(&decodingPacket);

    //allocate frame
    if(!decodedFrame)
    {
       if(!(decodedFrame = av_frame_alloc()))
       {
           fprintf(stderr, "Could not allocate audio frame\n");
           return -1;
       }

    }

    //set decoding codec context to audio stream index's codec
    decodeCodecCtx = inputFormat->streams[audioStreamIndex]->codec;

    //set up encoding audio codec
    encodeCodec = avcodec_find_encoder(AV_CODEC_ID_MP3);
    if(!encodeCodec)
    {
       fprintf(stderr, "Could not find encoder codec!\n");
       return -1;
    }
    encodeCodecCtx = avcodec_alloc_context3(encodeCodec);

    encodeCodecCtx->bit_rate = decodeCodecCtx->bit_rate;
    encodeCodecCtx->sample_fmt = decodeCodecCtx->sample_fmt;
    encodeCodecCtx->frame_size = decodeCodecCtx->frame_size;

    if(!check_sample_format(encodeCodec, encodeCodecCtx->sample_fmt))
    {
       fprintf(stderr, "Sample format %s not supported by encoding codec!\n", av_get_sample_fmt_name(encodeCodecCtx->sample_fmt));
       return -1;
    }

    //encoder codec context setup
    encodeCodecCtx->sample_rate = select_sample_rate(encodeCodec);
    encodeCodecCtx->channel_layout = select_channel_layout(encodeCodec);
    encodeCodecCtx->channels = av_get_channel_layout_nb_channels(encodeCodecCtx->channel_layout);

    if(avcodec_open2(encodeCodecCtx, encodeCodec, 0) < 0)
    {
       fprintf(stderr, "Could not open encoder codec\n");
       return -1;
    }

    outfile = fopen(new_format_path, "wb");

    if(!outfile)
    {
       fprintf(stderr, "Output file not opened!\n");
       return -1;
    }

    //printf("Outside function format-duration = %lld\n", inputFormat->duration);
    int c = 0, sum = 0;// max = 0;
    while (av_read_frame(inputFormat, &decodingPacket) == 0)
    {
       //CHECK LATER:# of samples decoded = # encoded?
       //PLANAR????

       int ch, got_frame, got_packet = 0;
       int j = 0;
       //printf("Frame #%d\n", ++c);

       //make sure stream indexes match, rarely necessary but can prevent a crash
       if(decodingPacket.stream_index == audioStreamIndex)
       {

           int bl = 0; //temporary to see performance of while loop

           while (decodingPacket.size > 0) {
               got_frame = 0;

               if(bl++ > 1)
               {
                   printf("while loop repeat!!!!\n\n\n");
               }

               //decodes next frame from stream inside decodingPacket and stores it in decodedFrame
               //len < 0 if the decoding didn't work
               len = avcodec_decode_audio4(decodeCodecCtx, decodedFrame, &got_frame, &decodingPacket);



               if(got_frame && len >= 0)
               {


                   ret = avcodec_encode_audio2(encodeCodecCtx, &encodingPacket, decodedFrame, &got_packet);

                   if(ret < 0)
                   {
                       fprintf(stderr, "Error encoding raw audio frame!\n");
                       return -1;
                   }


                   if(got_packet)
                   {

                       fwrite(encodingPacket.data, 1, encodingPacket.size, outfile);
                       av_free_packet(&encodingPacket);


                       //if encoder needs to be flushed
                       if(encodeCodecCtx->codec->capabilities == CODEC_CAP_DELAY)
                       {
                           av_init_packet(&encodingPacket);

                           got_frame = 0;
                           while(avcodec_encode_audio2(encodeCodecCtx, &encodingPacket, NULL, &got_packet) >= 0 && got_frame)
                           {
                               fwrite(encodingPacket.data, 1, encodingPacket.size, outfile);
                               av_free_packet(&encodingPacket);
                           }
                       }
                   }


                   //if decoder needs to be flushed
                   if(decodeCodecCtx->codec->capabilities == CODEC_CAP_DELAY)
                   {
                       av_init_packet(&decodingPacket);

                       got_frame = 0;
                       while(avcodec_decode_audio4(decodeCodecCtx, decodedFrame, &got_frame, &decodingPacket) >= 0 && got_frame)
                       {
                           av_free_packet(&decodingPacket);
                       }
                   }
               }
               else
               {
                   fprintf(stderr, "Error while decoding\n");
                   return -1;

               }

           decodingPacket.size -= len;
           decodingPacket.data += len;
           decodingPacket.dts = AV_NOPTS_VALUE;
           decodingPacket.pts = AV_NOPTS_VALUE;

           }

           av_free_packet(&decodingPacket);
       }

    }


    //open audio file
    if(avformat_open_input(&outputFormat, new_format_path, NULL, NULL) != 0)
    {
       return -1;
    }

    //open binary file for reading
    outfile = fopen(new_format_path, "rb");


    if(!outfile)
    {
       fprintf(stderr, "Input file not opened!");
       return -1;
    }


    if(avformat_find_stream_info(outputFormat, NULL))
    {
       fprintf(stderr, "Stream info not found!");
       return -1;
    }

    //dumps info about format context to standard error
    av_dump_format(outputFormat, 0, /*argv[1]*/0, 0);

    fclose(infile);
    fclose(outfile);

    avcodec_close(decodeCodecCtx);
    av_free(decodeCodecCtx);
    av_frame_free(&decodedFrame);




    return 0;

    }