Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#1423 closed defect (fixed)

GRASS 6.4.1 won't compile against FFmpeg 0.8

Reported by: sharpie Owned by: grass-dev@…
Priority: normal Milestone: 6.4.3
Component: Compiling Version: unspecified
Keywords: ffmpeg Cc: bain@…
CPU: Unspecified Platform: Unspecified

Description

It appears some symbols used by the GRASS interface to FFmpeg were depreciated in the latetest FFmpeg release:

/usr/bin/cc
  -I/private/tmp/homebrew-grass-6.4.1-BgUk/grass-6.4.1/dist.i386-apple-darwin10.8.0/include
  -I/usr/local/Cellar/readline/6.2.1/include
  -I/usr/local/Cellar/gettext/0.18.1.1/include  -I/usr/local/include -O3
  -march=core2 -msse4.1 -w -pipe   -arch x86_64 -I/usr/local/include  -fno-common
  -DPACKAGE=\""grasslibs"\" -I/usr/local/Cellar/gdal/1.8.1/include
  -I/usr/local/Cellar/geos/3.3.0/include   -DPACKAGE=\""grasslibs"\"
  -I/System/Library/Frameworks/OpenGL.framework/Headers
  -I/usr/local/include/libavcodec -I/usr/local/include/libavdevice
  -I/usr/local/include/libavfilter -I/usr/local/include/libavformat
  -I/usr/local/include/libavutil -I/usr/local/include/libpostproc
  -I/usr/local/include/libswscale
  -I/private/tmp/homebrew-grass-6.4.1-BgUk/grass-6.4.1/dist.i386-apple-darwin10.8.0/include
  -o OBJ.i386-apple-darwin10.8.0/gsd_img_mpeg.o -c gsd_img_mpeg.c
gsd_img_mpeg.c: In function ‘add_video_stream’:
gsd_img_mpeg.c:69: error: ‘CODEC_TYPE_VIDEO’ undeclared (first use in this function)
gsd_img_mpeg.c:69: error: (Each undeclared identifier is reported only once
gsd_img_mpeg.c:69: error: for each function it appears in.)
gsd_img_mpeg.c: In function ‘write_video_frame’:
gsd_img_mpeg.c:218: error: ‘PKT_FLAG_KEY’ undeclared (first use in this function)
make[3]: *** [OBJ.i386-apple-darwin10.8.0/gsd_img_mpeg.o] Error 1

Full build log attached.

Attachments (3)

grass_ffmpeg_install.log.tar.bz2 (73.1 KB ) - added by sharpie 13 years ago.
Build log of GRASS 6.4.1 failing to compile against FFmpeg 0.8
lib_ogsf_warnings.txt (9.7 KB ) - added by wenzeslaus 12 years ago.
Warnings wich lib/ogsf gives with -Wall
ogsf.patch (1.6 KB ) - added by neteler 12 years ago.
patch to compile with recent FFmpeg

Download all attachments as: .zip

Change History (22)

by sharpie, 13 years ago

Build log of GRASS 6.4.1 failing to compile against FFmpeg 0.8

in reply to:  description ; comment:1 by glynn, 13 years ago

Replying to sharpie:

It appears some symbols used by the GRASS interface to FFmpeg were depreciated in the latetest FFmpeg release:

See also:

http://lists.osgeo.org/pipermail/grass-dev/2011-July/055109.html

in reply to:  1 ; comment:2 by glynn, 13 years ago

Replying to glynn:

I've attached a minimal patch (attachment:ogsf.patch) to get OGSF to compile with recent FFmpeg. Can someone test that it (i.e. generating video from NVIZ) works?

in reply to:  2 comment:3 by marisn, 13 years ago

Replying to glynn:

Replying to glynn:

I've attached a minimal patch (attachment:ogsf.patch) to get OGSF to compile with recent FFmpeg. Can someone test that it (i.e. generating video from NVIZ) works?

It compiles and produces output, still there are three issues:

  • output video has problems with color. I'm not certain if it wasn't present also before. Might be related to the next point:
  • VBV buffer size not set, muxing may fail (see full message below)
    Output #0, mpeg, to 'asd':
        Stream #0:0: Video: mpeg1video (hq), yuv420p, 1021x766,
    q=2-31, 400 kb/s, 90k tbn, 25 tbc
    [mpeg @ 0x1b5f430] VBV buffer size not set, muxing may fail
    [mpeg @ 0x1b5f430] buffer underflow i=0 bufi=0 size=62369 
    
  • AVMEDIA_TYPE_VIDEO was introduced only in 2010. There might still be around older versions - needs a change in configure magic to refuse compilation with older versions

http://git.videolan.org/?p=ffmpeg.git;a=commit;f=libavcodec/avcodec.h;h=72415b2adb2c25f95ceede49001bb97ed9247

comment:4 by neteler, 12 years ago

Component: DefaultCompiling
Milestone: 6.4.3

Report from grass-dev, 11-July-2012: The patch solves this compilation problem on Ubuntu (12.04).

in reply to:  4 ; comment:5 by wenzeslaus, 12 years ago

I used this patch on Ubuntu 12.04 (32bit) too. But with this compiler flags I can not compile it.

export CFLAGS="-ggdb -Wall -Werror-implicit-function-declaration"

Removing -Werror-implicit-function-declaration solved the problem but I suppose it is not the solution. I also get some -Wdeprecated-declaration warnings.

by wenzeslaus, 12 years ago

Attachment: lib_ogsf_warnings.txt added

Warnings wich lib/ogsf gives with -Wall

in reply to:  5 ; comment:6 by glynn, 12 years ago

Replying to wenzeslaus:

Removing -Werror-implicit-function-declaration solved the problem but I suppose it is not the solution. I also get some -Wdeprecated-declaration warnings.

I don't have this problem with ffmpeg 0.10.3. There, av_rescale_q is declared in libavutil/mathematics.h, which is included by <avutil.h>.

Also, your warnings show a couple of significant issues with gvld.c:

gvld.c: In function ‘gvld_isosurf’:
gvld.c:351:29: warning: operation on ‘*(pos + (unsigned int)((unsigned int)i * 4u))’ may be undefined [-Wsequence-point]
gvld.c:351:29: warning: operation on ‘*(pos + (unsigned int)((unsigned int)i * 4u))’ may be undefined [-Wsequence-point]

The code in question is:

    if (check_color[i])
	curcolor[i] =
	    (READ() & 0xff) | ((READ() & 0xff) << 8) |
	    ((READ() & 0xff) << 16);

where the READ() macro is defined as:

#define READ() gvl_read_char(pos[i]++, gvl->isosurf[i]->data)

The problem is that, in an expression such as "A | B", if A and B have side-effects, the C standard doesn't specify the order in which those side-effects occur. I suspect that the code was written on the assumption of left-to-right evaluation, in which case it should read e.g.:

    if (check_color[i]) {
        unsigned r = READ();
        unsigned g = READ();
        unsigned b = READ();
	curcolor[i] =
	    (r & 0xff) | ((r & 0xff) << 8) |
	    ((r & 0xff) << 16);

There's another bug on line 367:

	gsd_set_material(1, 1, ksh[i], kem[i],
			 (int)curcolor);

This should probably have been:

	gsd_set_material(1, 1, ksh[i], kem[i],
			 curcolor[i]);

in reply to:  6 comment:7 by annakrat, 12 years ago

Replying to glynn:

Patch applied in r52391, r52392, r52393.

Thanks,

Anna

by neteler, 12 years ago

Attachment: ogsf.patch added

patch to compile with recent FFmpeg

in reply to:  2 comment:8 by neteler, 12 years ago

Replying to glynn:

Replying to glynn:

I've attached a minimal patch (attachment:ogsf.patch) to get OGSF to compile with recent FFmpeg. Can someone test that it (i.e. generating video from NVIZ) works?

I have tried using FFMPEG 0.10 on Fedora 17/64bit:

Vector map <wiggle_lines@neteler> loaded (7 features)
WARNING: Unable to deduce output format from file extension: using MPEG
Output #0, mpeg, to 'ciao':
    Stream #0:0: Video: mpeg1video (hq), yuv420p, 625x768, q=2-31, 400 kb/s, 90k tbn, 25 tbc
[mpeg @ 0x2613880] VBV buffer size not set, muxing may fail
[mpeg @ 0x2613880] buffer underflow i=0 bufi=0 size=67651
[mpeg @ 0x2613880] buffer underflow i=0 bufi=2005 size=67651
[mpeg @ 0x2613880] buffer underflow i=0 bufi=4046 size=67651
...
[mpeg @ 0x2613880] buffer underflow i=0 bufi=67460 size=68000

But it generated the MPEG:

file testfilm.mpg
testfilm.mpg: MPEG sequence, v1, system multiplex

and VLC plays it.

comment:9 by neteler, 12 years ago

Glynn, should the patch be submitted?

in reply to:  9 comment:10 by glynn, 12 years ago

Replying to neteler:

Glynn, should the patch be submitted?

It depends upon whether you're more concerned about the patch not working with older versions of FFMPEG or the lack of a patch not working with newer versions.

It wouldn't be hard to add some #defines, provided that we could figure out the correct version check. E.g.

#if OLD_FFMPEG
#define AVMEDIA_TYPE_VIDEO CODEC_TYPE_VIDEO
#define AV_PKT_FLAG_KEY PKT_FLAG_KEY
#define av_guess_format guess_format
#define avformat_alloc_context av_alloc_format_context
#endif

comment:11 by neteler, 12 years ago

Milestone: 6.4.36.4.4
Priority: criticalnormal

Patch applied to GRASS 6.4 (r52978), 6.5 (r52979), and 7 (r52980).

Keeping opened for potential conditionalizing for older FFMPEG versions.

comment:12 by hamish, 12 years ago

Keywords: ffmpeg added

see also #303 and #1353

comment:13 by hamish, 12 years ago

see also "Re: error building recent grass-svn versions"

http://thread.gmane.org/gmane.comp.gis.grass.user/46489

in reply to:  11 comment:14 by hamish, 12 years ago

Replying to neteler:

Patch applied to GRASS 6.4 (r52978), 6.5 (r52979), and 7 (r52980).

Keeping opened for potential conditionalizing for older FFMPEG versions.

see r53856, r53884, but as per comment:13, apparently more tuning still needed.

Hamish

comment:15 by hamish, 12 years ago

Cc: bain@… added

hopefully fixed in devbr6 and trunk in r56626-9.

tested on debian/squeeze, ubuntu 10.04, and ubuntu/12.04.

Hamish

comment:16 by hamish, 12 years ago

suggested build flags on debian/ubuntus:

 --with-ffmpeg \
 --with-ffmpeg-includes="/usr/include/libavcodec /usr/include/libavformat /usr/include/libswscale /usr/include/libavutil"

in reply to:  16 comment:17 by Nikos Alexandris, 12 years ago

Replying to hamish:

suggested build flags on debian/ubuntus:

 --with-ffmpeg \
 --with-ffmpeg-includes="/usr/include/libavcodec /usr/include/libavformat /usr/include/libswscale /usr/include/libavutil"

Using the (complete) suggested "sentence" for ffmpeg, leads to an error-free compilation of the latest grass_trunk

g.version -rb
GRASS 7.0.svn (2013)

./configure  --with-cxx --with-proj-share=/usr/local/share/proj/ --with-geos=/usr/local/bin/geos-config --with-motif --with-tcltk-includes=/usr/include/tcl8.5/ --with-cairo --with-opengl-libs=/usr/include/GL --with-python=yes --with-python=/usr/bin/python2.7-config --with-wxwidgets --with-ffmpeg=yes '--with-ffmpeg-includes=/usr/include/libavcodec /usr/include/libavformat /usr/include/libswscale /usr/include/libavutil' --with-freetype=yes --with-freetype-includes=/usr/include/freetype2/ --with-odbc=yes --with-mysql=yes --with-mysql-includes=/usr/include/mysql --with-sqlite=yes --with-postgres=yes --with-postgresql=yes --with-postgres-includes=/usr/include/postgresql --with-openmp --with-pthread --with-readline --with-nls --enable-largefile=yes --with-netcdf
libgis Revision: 56211 
libgis Date: 2013-05-12 14:07:51 +0300 (Sun, 12 May 2013)

comment:18 by hamish, 12 years ago

Milestone: 6.4.46.4.3
Resolution: fixed
Status: newclosed

Nikos wrote: (ML)

Ubuntu 13.04

there is still some trouble working around mathematics.h not being included, but that's libav's bug not ours.

backported to relbr64 in r56737. reopen if further adjustments are needed, and if you're updating to a newer version of the API, please leave some conditionals to support the older ones..

Hamish

ps- using --with-ffmpeg and --with-tcltk-includes in trunk is not needed, since ffmpeg was only used with tcl/tk NVIZ and tcl/tk code is removed in trunk.

in reply to:  18 comment:19 by Nikos Alexandris, 12 years ago

Replying to hamish:

ps- using --with-ffmpeg and --with-tcltk-includes in trunk is not needed, since ffmpeg was only used with tcl/tk NVIZ and tcl/tk code is removed in trunk.

Right! Removed --with-ffmpeg. The "--with-tcltk-includes" was not by intention there.

Note: See TracTickets for help on using tickets.