URLContext deprecated

Hello, I’m new here and wanted to compile on my Arch Linux system.
I get the error message:

checking for av_open_input_file in -lavformat... no
configure: error: FFMpeg avformat library not found. Please install it.

Arch Linux always has the newest packages, so I googled av_open_input_file and found it has been deprecated and is no longer included in ffmpeg.
See for example ffmpeg.zeranoe.com/forum/viewtopic.php?f=7&t=461.
The code should be changed to use avformat_open_input instead.
The last parameters to the function have changed, so just changing the name won’t work.
I only just started to find my way through the code, so I don’t know how to do it.

EDIT: I just found that my version of ffmpeg (0.11.1) can play both .bik and .smk videos, at least using ffplay. I would check if they work in VCMI, but I can’t get it to build.

EDIT 2: I got ./configure to work with the patch

diff --git a/configure.ac b/configure.ac
index c5e0332..1428d2e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -79,7 +79,7 @@ FFMPEG_LIBS=
 LIBS="$LIBS `pkg-config --libs libavcodec libavformat libavutil libswscale`"
 CFLAGS="$CFLAGS `pkg-config --cflags libavformat libswscale`"
-AC_CHECK_LIB(avformat,av_open_input_file,,AC_MSG_ERROR([FFMpeg avformat library not found. Please install it.]))
+AC_CHECK_LIB(avformat,avformat_open_input,,AC_MSG_ERROR([FFMpeg avformat library not found. Please install it.]))
 AC_CHECK_LIB(swscale,sws_getContext,,AC_MSG_ERROR([FFMpeg swscale library not found. Please install it.]))

The code already has support for the new api (avformat_open_input).

Another api that was removed from ffmpeg 0.11 is URLContext and URLProtocol. I don’t know what the replacements are. Google is not producing anything useful.

I get this error when compiling:

make[2]: Entering directory `/home/ismo/desktop/vcmi/vcmi/client'
  CXX      vcmiclient-CVideoHandler.o
CVideoHandler.cpp:587:21: error: ‘URLContext’ was not declared in this scope
CVideoHandler.cpp:587:33: error: ‘context’ was not declared in this scope
CVideoHandler.cpp:587:42: error: expected primary-expression before ‘const’
CVideoHandler.cpp:587:64: error: expected primary-expression before ‘int’
CVideoHandler.cpp:587:73: error: expression list treated as compound expression in initializer -fpermissive]
CVideoHandler.cpp:588:1: error: expected ‘,’ or ‘;’ before ‘{’ token
CVideoHandler.cpp:602:22: error: ‘URLContext’ was not declared in this scope
CVideoHandler.cpp:602:34: error: ‘h’ was not declared in this scope
CVideoHandler.cpp:603:1: error: expected ‘,’ or ‘;’ before ‘{’ token
CVideoHandler.cpp:608:21: error: ‘URLContext’ was not declared in this scope
CVideoHandler.cpp:608:33: error: ‘context’ was not declared in this scope
CVideoHandler.cpp:608:46: error: expected primary-expression before ‘*’ token
CVideoHandler.cpp:608:47: error: ‘buf’ was not declared in this scope
CVideoHandler.cpp:608:52: error: expected primary-expression before ‘int’
CVideoHandler.cpp:608:60: error: expression list treated as compound expression in initializer -fpermissive]
CVideoHandler.cpp:609:1: error: expected ‘,’ or ‘;’ before ‘{’ token
CVideoHandler.cpp:625:22: error: ‘URLContext’ was not declared in this scope
CVideoHandler.cpp:625:34: error: ‘context’ was not declared in this scope
CVideoHandler.cpp:625:48: error: expected primary-expression before ‘pos’
CVideoHandler.cpp:625:53: error: expected primary-expression before ‘int’
CVideoHandler.cpp:625:63: error: expression list treated as compound expression in initializer -fpermissive]
CVideoHandler.cpp:626:1: error: expected ‘,’ or ‘;’ before ‘{’ token
CVideoHandler.cpp:637:8: error: ‘URLProtocol’ does not name a type
CVideoHandler.cpp: In constructor ‘CVideoPlayer::CVideoPlayer()’:
CVideoHandler.cpp:666:25: error: ‘lod_protocol’ was not declared in this scope
CVideoHandler.cpp:666:59: error: ‘av_register_protocol2’ was not declared in this scope
CVideoHandler.cpp: At global scope:
CVideoHandler.cpp:587:12: warning: ‘lod_open’ defined but not used -Wunused-variable]
CVideoHandler.cpp:602:12: warning: ‘lod_close’ defined but not used -Wunused-variable]
CVideoHandler.cpp:608:12: warning: ‘lod_read’ defined but not used -Wunused-variable]
CVideoHandler.cpp:625:13: warning: ‘lod_seek’ defined but not used -Wunused-variable]
make[2]: *** [vcmiclient-CVideoHandler.o] Error 1
make[2]: Leaving directory `/home/ismo/desktop/vcmi/vcmi/client'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/ismo/desktop/vcmi/vcmi/client'
make: *** [all-recursive] Error 1

I changed the title because the real problem is URLContext, av_open_input_file has already been fixed, except the bug in configure.

Thanks for report, should be fixed in rev 2832.
Problem was with ffmpeg detection - code should be fine.

We do have some deprecation issues with ffmpeg but I want to avoid fixing it right now - too many changes and we have to support old versions as well (e.g. Debian).

Yes. It finally can! :slight_smile:

Since it may take some time to fix the ffmpeg code, is there a way to compile without video support?

Yes but right now it is used only for 64-bit Windows. Should be easy to change.

Url protocol removal is a bit problematic. It does have replacement (avioContext) but it requires quite large amount of changes and not yet available in Debian Squeeze and Ubuntu Natty (they still use ffmpeg 0.5).
I’ll start working on replacement but not sure when I’ll finish it. One or two weeks I think.

Why can 64-bit Windows not use ffmpeg?

I would suggest removing the current Windows player and using ffmpeg instead.
The build could check if ffmpeg is available and if not use the empty player.
This would make the code simpler, because only three players are needed: empty, old ffmpeg and new ffmpeg.

Try rev 2833 - VCMI should use empty video player if av_register_protocol is missing.

I found out about full bink support only a few weeks ago. Before this switching to ffmpeg was not an option - it could not play half of H3 video files.
I’ve already proposed this switch to Tow (project leader and Windows user) so if there won’t be OS-specific issues Windows player will be removed at some point.

I’d wish everything was that simple… Because right now we need ffmpeg 0.5, 0.6, 0.7 … 0.11 players - just look on amount of “if version” checks in client/CVideoPlayer.cpp. Those API changes are quite common in ffmpeg and most distros are not as fast in updating as Arch or Gentoo.

Thanks, the new revision works. I can compile and play the game!

Check rev 2836 - video player should compile without any warnings, all video should work.

It compiles well. The 3DO logo is played when starting the game but there is no sound in the logo. ffplay has sound in the logo. The video in the tavern plays. The videos before campaign maps don’t play (should they?). The game always crashes when combat ends with

terminate called after throwing an instance of 'std::runtime_error'
  what():  Decompression error!


I would post the logs but I can’t find them. Where are they on Linux?

Intro videos before campaigns are not implemented. Only campaign selection icons should be animated.

Was this crash present before video player update? You can find logs in ~/.vcmi directory but I don’t think that there will be something useful.

There is nothing in the logs. It does not crash with revision 2834. The crash happens when you win the battle. I will try losing now.

EDIT 2: It does not crash when you lose the battle. The problem seems to be with WIN3.BIK. It plays fine using ffplay.

EDIT: I suggest removing these files from the svn tree because they can be generated using autoreconf -i:


They make the logs messy because changing configure.ac also changes configure for example. Running autoreconf does not take long. I think that a Windows build does not need these files.

There shouldn’t be any decompression at all in video player.
Ah. Found it. Bug with detecting size of last entry in video archive.

That practive was started long time ago. In such way users don’t need to install autotools (one dependency less).
Switching to CMake is probably a better solution. After next release I’m going to replace autotools with cmake in readme’s and will remove autotools completely after one more release.

Great stuff! The videos work now in r2837.