Opened 8 years ago

Closed 14 months ago

#5781 closed enhancement (fixed)

Improve documentation and examples for AVCodecParameters related functions

Reported by: patacca Owned by:
Priority: wish Component: documentation
Version: git-master Keywords:
Cc: Max Kellermann, James Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
Bug previously opened on mpd bug tracker: https://bugs.musicpd.org/view.php?id=4564 (see cirrus's comment https://bugs.musicpd.org/view.php?id=4564#c10084)

When decoding a m4a file avcodec_send_packet fails if the AVCodecContext instance is created via avcodec_alloc_context3.

How to reproduce:
See mpd code:
http://git.musicpd.org/cgit/master/mpd.git/commit/?id=8825393660b95664141ce818089359e1edd612a3
http://git.musicpd.org/cgit/master/mpd.git/tree/src/decoder/plugins/FfmpegDecoderPlugin.cxx?h=v0.19.x#n497

Change History (9)

comment:1 by James, 8 years ago

Looks like they are not copying codec parameters from the AVStream.AVCodecParameters struct to the avcodec_alloc_context3 allocated context before calling avcodec_open2.
The function avcodec_parameters_to_context should be used for this purpose.

Can't really test but it could be the source of the problem.

comment:2 by Pritam Baral, 8 years ago

I can confirm that jamrial's suggestion works.

in reply to:  2 comment:3 by James, 8 years ago

Resolution: invalid
Status: newclosed

Replying to pritambaral:

I can confirm that jamrial's suggestion works.

Could you report this to MPD's developers, then?

Thanks for testing.

comment:4 by Max Kellermann, 8 years ago

jamrial, I can't find documentation on this requirement in the FFmpeg API documentation. Quite contrary, none of the code samples has this call.

I'm not quite happy with the situation. I closed the bug report on the MPD bug tracker as an apparent FFmpeg bug, because I couldn't find anything that's wrong with MPD.

This looks like a secret trick, but it shouldn't be secret. Did I miss something?

in reply to:  4 comment:5 by James, 8 years ago

Component: undetermineddocumentation
Resolution: invalid
Status: closedreopened
Type: defectenhancement

Replying to cirrus:

jamrial, I can't find documentation on this requirement in the FFmpeg API documentation. Quite contrary, none of the code samples has this call.

If you check ffplay.c and ffprobe.c you'll see this in action (ffmpeg.c has yet to be updated to this API).

Similarly, i recently pushed a patch for the demuxing_decoding example as commit bba6a03b2816d805d44bce4f9701a71f7d3f8dad.

I'm not quite happy with the situation. I closed the bug report on the MPD bug tracker as an apparent FFmpeg bug, because I couldn't find anything that's wrong with MPD.

This looks like a secret trick, but it shouldn't be secret. Did I miss something?

No, you didn't. The doxygen documentation in avcodec.h for avcodec_open2() doesn't mention it because an input AVStream is not required unless you're demuxing with libavformat.
I agree it should be mentioned somewhere, though.

Basically, since AVStream.AVCodecContext (which has all the stream's parameters already filled) shouldn't be used anymore, the manually allocated AVCodecContext needs to be filled with said parameters in some way, and as its doxy states that's what the above function does.

Last edited 8 years ago by James (previous) (diff)

comment:6 by James, 8 years ago

Cc: Max Kellermann James added
Summary: avcodec_send_packet() fails with m4a files when AVCodecContext is created with avcodec_alloc_context3()Improve documentation and examples for AVCodecParameters related functions

comment:7 by Carl Eugen Hoyos, 8 years ago

Priority: normalwish

comment:8 by Stefano Sabatini, 14 months ago

Fixed in dcf963f4906fa59.

comment:9 by Stefano Sabatini, 14 months ago

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.