On Wed, 30 Aug 2023 15:39:08 +0200 Denis Gottardello <i...@denisgottardello.it> wrote:
> Hi. When I try to compile the following line of code > > av_channel_layout_copy(&c->ch_layout, > &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO); > > taken from mux.c example I obtain the error: > > /home/denis/Cpp/ffmpeg-6.0/libavutil/channel_layout.h:362: *error: > taking address of rvalue [-fpermissive]* > ../../ffmpeg-6.0/libavutil/channel_layout.h:362:5: error: taking > address of rvalue [-fpermissive] 362 | { .order = > AV_CHANNEL_ORDER_NATIVE, .nb_channels = (nb), .u = { .mask = (m) }} | > > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../../ffmpeg-6.0/libavutil/channel_layout.h:369:45: note: in > expansion of macro ‘AV_CHANNEL_LAYOUT_MASK’ 369 | #define > AV_CHANNEL_LAYOUT_STEREO AV_CHANNEL_LAYOUT_MASK(2, > AV_CH_LAYOUT_STEREO) | > ^~~~~~~~~~~~~~~~~~~~~~ ../ffmpegTest/main.cpp:157:65: note: in > expansion of macro ‘AV_CHANNEL_LAYOUT_STEREO’ 157 | > av_channel_layout_copy(&c->ch_layout, > &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO); | > ^~~~~~~~~~~~~~~~~~~~~~~~ > > How can I translate it to work in Windows, Linux and Mac? > Something like this? > > AVChannelLayout a= AV_CHANNEL_LAYOUT_STEREO; > av_channel_layout_copy(&c->ch_layout, &a); > If you're assigning one of the standard layouts you should be able to just do c->ch_layout = AV_CHANNEL_LAYOUT_STEREO; At least, assuming that the AVCodecContext has just been allocated (like it is in mux.c). If you had an existing channel layout set, you'd want to do a copy since that will free any custom channel layout data for you. From your output it looks like you're compiling as C++, and some of the code in mux.c is valid C code, but not valid C++ code (such as taking the address of an rvalue). _______________________________________________ Libav-user mailing list Libav-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/libav-user To unsubscribe, visit link above, or email libav-user-requ...@ffmpeg.org with subject "unsubscribe".