stepmania / stepmania

Advanced rhythm game for Windows, Linux and OS X. Designed for both home and arcade use.
https://www.stepmania.com/
1.89k stars 449 forks source link

Does not build with FFmpeg 5.0 #2175

Open brad0 opened 2 years ago

brad0 commented 2 years ago

Does not build with FFmpeg 5.0.

/home/brad/tmp/ffmpeg-ports/ports/pobj/stepmania-5.0.12/stepmania-5.0.12/src/arch/MovieTexture/MovieTexture_FFMpeg.h:51:43: error: no member named 'codec' in 'avcodec::AVStream'
        int GetWidth() const { return m_pStream->codec->width; }
                                      ~~~~~~~~~  ^
/home/brad/tmp/ffmpeg-ports/ports/pobj/stepmania-5.0.12/stepmania-5.0.12/src/arch/MovieTexture/MovieTexture_FFMpeg.h:52:44: error: no member named 'codec' in 'avcodec::AVStream'
        int GetHeight() const { return m_pStream->codec->height; }
                                       ~~~~~~~~~  ^
/home/brad/tmp/ffmpeg-ports/ports/pobj/stepmania-5.0.12/stepmania-5.0.12/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp:124:12: error: no type named 'av_free_packet' in namespace 'avcodec'
                avcodec::av_free_packet( &m_Packet );
                ~~~~~~~~~^
/home/brad/tmp/ffmpeg-ports/ports/pobj/stepmania-5.0.12/stepmania-5.0.12/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp:124:29: error: declaration of reference variable 'm_Packet' requires an initializer
                avcodec::av_free_packet( &m_Packet );
                                          ^~~~~~~~
/home/brad/tmp/ffmpeg-ports/ports/pobj/stepmania-5.0.12/stepmania-5.0.12/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp:159:12: error: no type named 'av_free_packet' in namespace 'avcodec'
                avcodec::av_free_packet( &m_Packet );
                ~~~~~~~~~^
/home/brad/tmp/ffmpeg-ports/ports/pobj/stepmania-5.0.12/stepmania-5.0.12/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp:159:29: error: declaration of reference variable 'm_Packet' requires an initializer
                avcodec::av_free_packet( &m_Packet );
                                          ^~~~~~~~
/home/brad/tmp/ffmpeg-ports/ports/pobj/stepmania-5.0.12/stepmania-5.0.12/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp:224:13: error: no type named 'av_free_packet' in namespace 'avcodec'
                        avcodec::av_free_packet( &m_Packet );
                        ~~~~~~~~~^
/home/brad/tmp/ffmpeg-ports/ports/pobj/stepmania-5.0.12/stepmania-5.0.12/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp:224:30: error: declaration of reference variable 'm_Packet' requires an initializer
                        avcodec::av_free_packet( &m_Packet );
                                                  ^~~~~~~~
/home/brad/tmp/ffmpeg-ports/ports/pobj/stepmania-5.0.12/stepmania-5.0.12/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp:245:12: error: no type named 'av_free_packet' in namespace 'avcodec'
                avcodec::av_free_packet( &m_Packet );
                ~~~~~~~~~^
/home/brad/tmp/ffmpeg-ports/ports/pobj/stepmania-5.0.12/stepmania-5.0.12/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp:245:29: error: declaration of reference variable 'm_Packet' requires an initializer
                avcodec::av_free_packet( &m_Packet );
                                          ^~~~~~~~
/home/brad/tmp/ffmpeg-ports/ports/pobj/stepmania-5.0.12/stepmania-5.0.12/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp:268:16: error: no member named 'codec' in 'avcodec::AVStream'
                        (m_pStream->codec->frame_number % 2) == 0;
                         ~~~~~~~~~  ^
/home/brad/tmp/ffmpeg-ports/ports/pobj/stepmania-5.0.12/stepmania-5.0.12/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp:275:16: error: no member named 'codec' in 'avcodec::AVStream'
                                m_pStream->codec,
                                ~~~~~~~~~  ^
/home/brad/tmp/ffmpeg-ports/ports/pobj/stepmania-5.0.12/stepmania-5.0.12/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp:274:22: error: no member named 'avcodec_decode_video2' in namespace 'avcodec'
                int len = avcodec::avcodec_decode_video2(
                          ~~~~~~~~~^
/home/brad/tmp/ffmpeg-ports/ports/pobj/stepmania-5.0.12/stepmania-5.0.12/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp:336:11: error: no type named 'AVPicture' in namespace 'avcodec'
        avcodec::AVPicture pict;
        ~~~~~~~~~^
/home/brad/tmp/ffmpeg-ports/ports/pobj/stepmania-5.0.12/stepmania-5.0.12/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp:347:41: error: no member named 'codec' in 'avcodec::AVStream'
                                GetWidth(), GetHeight(), m_pStream->codec->pix_fmt,
                                                         ~~~~~~~~~  ^
/home/brad/tmp/ffmpeg-ports/ports/pobj/stepmania-5.0.12/stepmania-5.0.12/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp:352:113: error: no member named 'codec' in 'avcodec::AVStream'
                        LOG->Warn("Cannot initialize sws conversion context for (%d,%d) %d->%d", GetWidth(), GetHeight(), m_pStream->codec->pix_fmt, m_AVTexfmt);
                                                                                                                          ~~~~~~~~~  ^
/home/brad/tmp/ffmpeg-ports/ports/pobj/stepmania-5.0.12/stepmania-5.0.12/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp:387:11: error: no member named 'avcodec_register_all' in namespace 'avcodec'
        avcodec::avcodec_register_all();
        ~~~~~~~~~^
/home/brad/tmp/ffmpeg-ports/ports/pobj/stepmania-5.0.12/stepmania-5.0.12/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp:388:11: error: no member named 'av_register_all' in namespace 'avcodec'
        avcodec::av_register_all();
        ~~~~~~~~~^
/home/brad/tmp/ffmpeg-ports/ports/pobj/stepmania-5.0.12/stepmania-5.0.12/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp:448:17: error: no member named 'codec' in 'avcodec::AVStream'
        if( m_pStream->codec->codec_id == avcodec::AV_CODEC_ID_NONE )
            ~~~~~~~~~  ^
goeranu commented 2 years ago

I also hit this when trying to build the current head (commit a1984e4f6519b1376ac030d8c6b11c3aff1dcae6) for Fedora 36. With the following patch I could build it. I'm not at all sure this is the correct way to fix things though, so I only mention it here as a comment rather than making a PR.

--- ./src/CMakeData-arch.cmake~ 2022-03-25 17:31:58.000000000 +0100
+++ ./src/CMakeData-arch.cmake  2022-04-10 13:26:14.000000000 +0200
@@ -105,6 +105,7 @@
                 "arch/MovieTexture/MovieTexture_FFMpeg.cpp")
     list(APPEND SMDATA_ARCH_MOVIE_TEXTURE_HPP
                 "arch/MovieTexture/MovieTexture_FFMpeg.h")
+    add_compile_definitions(FF_API_NEXT)
   endif()
 endif()

--- ./src/arch/MovieTexture/MovieTexture_FFMpeg.h~      2022-03-25 17:31:58.000000000 +0100
+++ ./src/arch/MovieTexture/MovieTexture_FFMpeg.h       2022-04-10 13:09:01.000000000 +0200
@@ -13,6 +13,7 @@
        #include <libavformat/avformat.h>
        #include <libswscale/swscale.h>
        #include <libavutil/pixdesc.h>
+       #include <libavcodec/avcodec.h>

        #if LIBAVCODEC_VERSION_MAJOR >= 58
        #define av_free_packet av_packet_unref
--- ./src/arch/MovieTexture/MovieTexture_FFMpeg.cpp~    2022-03-25 17:31:58.000000000 +0100
+++ ./src/arch/MovieTexture/MovieTexture_FFMpeg.cpp     2022-04-10 13:32:11.000000000 +0200
@@ -494,7 +494,7 @@
    if( m_pStreamCodec->codec )
        avcodec::avcodec_close( m_pStreamCodec );

-   avcodec::AVCodec *pCodec = avcodec::avcodec_find_decoder( m_pStreamCodec->codec_id );
+   const avcodec::AVCodec *pCodec = avcodec::avcodec_find_decoder( m_pStreamCodec->codec_id );
    if( pCodec == nullptr )
        return ssprintf( "Couldn't find decoder %i", m_pStreamCodec->codec_id );
jhonny-oliveira commented 2 years ago

Hi!

I also had to apply @goeranu's patch to be able to build with system FFMPEG 5.x (default on Ubuntu Kinetic (22.10)).

I also tested it afterwards and everything seemed to be fine.

brad0 commented 1 year ago

I created a PR that allows building against current releases and newer releases of FFmpeg.

https://github.com/stepmania/stepmania/pull/2247

brad0 commented 1 year ago

Any feedback would be welcome.