#10710 closed defect (invalid)

Audio cracklings when decoding WAV PCM files with avcodec_receive_frame

Reported by: fabi78 Owned by:
Priority: important Component: avcodec
Version: 6.0 Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

The bug concerns FFMPEG API, not ffmpeg program.

To learn how to use FFMPEG API, I wrote a simple WAV file decoder (cf. attachment). It is inspired by tutorials online. The decoding is performed by the chain:
av_read_frame -> avcodec_send_packet -> avcodec_receive_frame

Then the content of frame->data is written without modification in an output file. When I read it with ffplay -f s16le -ac 2 -ar 44100, I hear cracklings, and when opening the file with Audacity in raw mode, I can see that some frames are "damaged" (some samples seem random).

But if I wrote the data from the packet instead of the frame (which I can do as PCM is uncompressed), replacing "fwrite( pFrame->data " by "fwrite( pPacket->data" (at line 127), everything is fine.

Have a good day.

FM


Attachments (1)

ffmpeg-decode_wav.c (3.8 KB ) - added by fabi78 12 months ago.

Download all attachments as: .zip

Change History (2)

by fabi78, 12 months ago

Attachment: ffmpeg-decode_wav.c added

comment:1 by Elon Musk, 12 months ago

Resolution: invalid
Status: newclosed

To read samples you need to use data[0] for packed sample formats.
And for planar sample formats use extended_data[X] where X is channel number.

Note: See TracTickets for help on using tickets.