[Libav-user] Encoding pcm_s32le

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Libav-user] Encoding pcm_s32le

יוסף אלון
I am trying to encode a file to pcm s32le.
I use the decodeing_encodeing.c example but I always recieve the folowing Error:
[pcm_s32le @ 0x11d0e00] Specified sample format 48000 is invalid or not supported
Could not open codec

The function is (Its not all the function, I marked what I have changed in yellow:

static void audio_encode_example(const char *filename)
{
    AVCodec *codec;
    AVCodecContext *c= NULL;
    AVFrame *frame;
    AVPacket pkt;
    int i, j, k, ret, got_output;
    int buffer_size;
    FILE *f;
    uint16_t *samples;
    float t, tincr;

    printf("Encode audio file %s\n", filename);

    /* find the Wav encoder */
    codec = avcodec_find_encoder(AV_CODEC_ID_PCM_S32LE);
    if (!codec) {
        fprintf(stderr, "Codec not found\n");
        exit(1);
    }

    c = avcodec_alloc_context3(codec);
    if (!c) {
        fprintf(stderr, "Could not allocate audio codec context\n");
        exit(1);
    }

    /* put sample parameters */
    c->bit_rate = 64000;
    /* check that the encoder supports S32LE pcm input */
    c->sample_fmt =  AV_SAMPLE_FMT_S32;
    if (!check_sample_fmt(codec, c->sample_fmt)) {
        fprintf(stderr, "Encoder does not support sample format %s",
                av_get_sample_fmt_name(c->sample_fmt));
        exit(1);
    }
    printf("\n");
   
    /* select other audio parameters supported by the encoder */
    c->sample_rate    = select_sample_rate(codec);
    c->channel_layout = select_channel_layout(codec);
    c->channels       = av_get_channel_layout_nb_channels(c->channel_layout);
   
    /* open it */
    if (avcodec_open2(c, codec, NULL) < 0) {
        fprintf(stderr, "Could not open codec\n");
        exit(1);
    }

The error is from avcodec_open2.
Allso with the original example It didnt worked for me (With AV_CODEC_ID_MP2 and AV_SAMPLE_FMT_S16) and said the same error.

--
Yosef Alon

_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Encoding pcm_s32le

avcoder
On Sun, Apr 9, 2017 at 2:17 PM, יוסף אלון <[hidden email]> wrote:
> I am trying to encode a file to pcm s32le.
> I use the decodeing_encodeing.c example but I always recieve the folowing
> Error:
> [pcm_s32le @ 0x11d0e00] Specified sample format 48000 is invalid or not
> supported
> Could not open codec

The error message is very strange.

It seems that the FFmpeg library and header files do not match.
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Encoding pcm_s32le

יוסף אלון
What can I check or do?

2017-04-09 10:02 GMT+03:00 Geek.Song <[hidden email]>:
On Sun, Apr 9, 2017 at 2:17 PM, יוסף אלון <[hidden email]> wrote:
> I am trying to encode a file to pcm s32le.
> I use the decodeing_encodeing.c example but I always recieve the folowing
> Error:
> [pcm_s32le @ 0x11d0e00] Specified sample format 48000 is invalid or not
> supported
> Could not open codec

The error message is very strange.

It seems that the FFmpeg library and header files do not match.
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user



--
בברכה, יוסף אלון
050-4916740

_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Loading...