Opened 12 months ago
Closed 12 months ago
#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)
Change History (2)
by , 12 months ago
Attachment: | ffmpeg-decode_wav.c added |
---|
comment:1 by , 12 months ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
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.