2011-11-09 3 views
0

Je n'arrive pas à faire fonctionner le FFMpeg avec la bibliothèque. Chaque fois que j'essaye de convertir le fichier asf en wmv. Je reçois la question suivante à l'heure de l'exécution:Le convertisseur WMV échoue FFMpeg

[WMV1 @ 0x81ee000] erreur, le code de tranche était de 2 [WMV1 @ 0x81ee000] tête endommagé

Ce mon code:

static void audio_decode_example(const char *outfilename, const char *filename) 
{ 
    AVCodec *codec; 
    AVCodecContext *c= NULL; 
    int out_size, len, in_size; 
    FILE *f, *outfile; 
    uint8_t *outbuf; 
    uint8_t inbuf[AUDIO_INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; 
    AVPacket avpkt; 

    av_init_packet(&avpkt); 

    printf("Audio decoding\n"); 

    /* find the mpeg audio decoder */ 
    codec = avcodec_find_decoder(CODEC_ID_WMV1); 
    if (!codec) { 
     fprintf(stderr, "codec not found\n"); 
     return; 
    } 

    c= avcodec_alloc_context2(CODEC_TYPE_AUDIO); 

    /* open it */ 
    if (avcodec_open(c, codec) < 0) { 
     fprintf(stderr, "could not open codec\n"); 
     return; 
    } 

    outbuf = malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE); 
    f = fopen(filename, "rb"); 
    if (!f) { 
     fprintf(stderr, "could not open %s\n", filename); 
     return; 
    } 
    outfile = fopen(outfilename, "wb"); 
    if (!outfile) { 
     av_free(c); 
     return; 
    } 

    /* decode until eof */ 
    avpkt.data = inbuf; 
    len = avpkt.size = fread(inbuf, 1, INBUF_SIZE, f); 
    NSLog(@"%d", avpkt.size); 

    while (avpkt.size > 0) { 
     out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE; 
    len = avcodec_decode_audio2(c, (short *)outbuf, &out_size, inbuf,len);// avpkt.size); 
    NSLog(@"%d", len); 
    if (len < 0) { 
     fprintf(stderr, "Error while decoding\n"); 
     fclose(outfile); 
     return; 
    } 
    if (out_size > 0) { 
     /* if a frame has been decoded, output it */ 
     fwrite(outbuf, 1, out_size, outfile); 
    } 
    avpkt.size -= len; 
    avpkt.data += len; 
    if (avpkt.size < AUDIO_REFILL_THRESH) { 
     /* Refill the input buffer, to avoid trying to decode 
     * incomplete frames. Instead of this, one could also use 
     * a parser, or use a proper container format through 
     * libavformat. */ 
     memmove(inbuf, avpkt.data, avpkt.size); 
     avpkt.data = inbuf; 
     len = fread(avpkt.data + avpkt.size, 1, 
        INBUF_SIZE - avpkt.size, f); 
     if (len > 0) 
      avpkt.size += len; 
    } 
} 

fclose(outfile); 
fclose(f); 
free(outbuf); 
avcodec_close(c); 
av_free(c); 
} 

J'ai essayé les utilitaires de ligne de commande et il a réussi à convertir le fichier. Toute aide serait utile.

+0

où avez-vous écrit cette méthode dans votre code, je ne peux pas écrire sur le fichier c objectif – Swati

Répondre

0

Faites l'erreur d'ouvrir le mauvais fichier