Recherche avancée

Médias (91)

Autres articles (61)

  • Qualité du média après traitement

    21 juin 2013, par

    Le bon réglage du logiciel qui traite les média est important pour un équilibre entre les partis ( bande passante de l’hébergeur, qualité du média pour le rédacteur et le visiteur, accessibilité pour le visiteur ). Comment régler la qualité de son média ?
    Plus la qualité du média est importante, plus la bande passante sera utilisée. Le visiteur avec une connexion internet à petit débit devra attendre plus longtemps. Inversement plus, la qualité du média est pauvre et donc le média devient dégradé voire (...)

Sur d’autres sites (3453)

  • How to save data of packet.data using ffmpeg && c language ?

    12 juin 2015, par patrick

    I’m try to build an app in c that extract audio from video and save it as audio file. I’m able to extract the audio but now the problem is how to save it. I wrote the code given below but it’s giving me an segmentation fault. Thanks in advance.

    My code is :

    AVOutputFormat* fmt = av_guess_format("mp3", NULL, NULL);;
    AVFormatContext* oc = avformat_alloc_context();
    oc->oformat = fmt;
    avio_open2(&oc->pb, "test.mp3", AVIO_FLAG_WRITE,NULL,NULL);

    AVStream* stream=NULL;
    int cnt = 0;

    while(av_read_frame(pFormatCtx, &packet)>=0) { //pFormatCtx is input file format context.
       if (packet.stream_index==audioStream) {
       int got_frame = 0;
       if (avcodec_decode_audio4(pCodecCtx, pFrame, &got_frame, &packet) < 0) {
           fprintf(stderr, "Error encoding frame\n");
                   exit(1);
           }

           if(got_frame) {
           if (av_interleaved_write_frame(oc, &packet) < 0) {
                   printf(stderr, "Error writing frame\n");
                       exit(1);
                   }
           }
       }
       av_free_packet(&packet);
       av_init_packet(&packet);
    }
  • How to save data of packet.data in ffmpeg using c language ?

    10 juin 2015, par patrick

    I’m try to build an app in c that extract audio from video and save it as audio file. I write the below code. I’m able to extract the audio but now the problem is how to save it. Thanks in advance.

    My code is :

    int main(int argc, char *argv[]) {
    AVFormatContext *pFormatCtx = NULL;
    int             i;
    AVCodecContext  *pCodecCtx = NULL;
    AVCodec         *pCodec = NULL;
    AVFrame         *pFrame = NULL;
    AVPacket        packet;

    AVDictionary    *optionsDict = NULL;

    if(argc < 2) {
    printf("Please provide a movie file\n");
    return -1;
    }
    av_register_all();
    if(avformat_open_input(&pFormatCtx, argv[1], NULL, NULL)!=0)
    return -1;

    if(avformat_find_stream_info(pFormatCtx, NULL)<0)
    return -1;

    av_dump_format(pFormatCtx, 0, argv[1], 0);

    int audioStream=-1;
    for(i=0; inb_streams; i++)
       if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO) {
           audioStream=i;
           break;
       }
    if(audioStream==-1)
    return -1;

    pCodecCtx=pFormatCtx->streams[audioStream]->codec;

    pCodec=avcodec_find_decoder(pCodecCtx->codec_id);
    if(pCodec==NULL) {
       fprintf(stderr, "Unsupported codec!\n");
       return -1; // Codec not found
    }

    if(avcodec_open2(pCodecCtx, pCodec, &optionsDict)<0)
    return -1;

    pFrame=avcodec_alloc_frame();
    packet.data = NULL;
    packet.size = 0;

    while(av_read_frame(pFormatCtx, &packet)>=0) {
       int got_frame = 0;
       int ret = avcodec_decode_audio4(pCodecCtx, pFrame, &got_frame, &packet);
       if(got_frame && packet.stream_index==audioStream) {
           //save result but how???
       }
       av_free_packet(&packet);
    }
    av_free(pFrame);
    avcodec_close(pCodecCtx);
    avformat_close_input(&pFormatCtx);
    return 0;
    }
  • ffmpeg : how to save h264 raw data as mp4 file

    15 avril 2016, par monkid

    I encode h264 data by libavcodec.
    ex.

    while (1) {
     ...
     avcodec_encode_video(pEnc->pCtx, OutBuf, ENC_OUTSIZE, pEnc->pYUVFrame);
     ...
    }

    If I directly save OutBuf data as a .264 file, it can`t be play by player. Now I want to save OutBuf

    as a mp4 file. Anyone know how to do this by ffmpeg lib ? thanks.