Comskip
Comskip copied to clipboard
Mac OS X C99 Build Error
After following the build from source steps in the readme (+ OS X specific libraries/ dependencies section), I'm getting the following build error on two machines, one intel and one silicon:
~/.../Comskip master ❯ make 4s
gcc -DPACKAGE_NAME=\"Comskip\" -DPACKAGE_TARNAME=\"comskip\" -DPACKAGE_VERSION=\"0.82.010\" -DPACKAGE_STRING=\"Comskip\ 0.82.010\" -DPACKAGE_BUGREPORT=\"https://github.com/erikkaashoek/Comskip/issues\" -DPACKAGE_URL=\"\" -DPACKAGE=\"comskip\" -DVERSION=\"0.82.010\" -DHAVE_LIBM=1 -DHAVE_LIBPTHREAD=1 -I. -Wall -I/usr/local/Cellar/argtable/2.13/include -I/usr/local/Cellar/ffmpeg/4.4_2/include -DPROCESS_CC -DDONATOR -g -O2 -MT comskip-comskip.o -MD -MP -MF .deps/comskip-comskip.Tpo -c -o comskip-comskip.o `test -f 'comskip.c' || echo './'`comskip.c
comskip.c:8883:9: error: implicit declaration of function 'list_codecs' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
list_codecs();
^
comskip.c:14361:44: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
frame[i].isblack = C_a;
^
comskip.c:279:18: note: expanded from macro 'C_a'
#define C_a (1<<5)
^
comskip.c:14363:44: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
frame[i].isblack = C_u; // Checked
^
comskip.c:280:18: note: expanded from macro 'C_u'
#define C_u (1<<3)
^
comskip.c:14365:44: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
frame[i].isblack = C_s;
^
comskip.c:278:18: note: expanded from macro 'C_s'
#define C_s (1<<2)
^
comskip.c:14367:44: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
frame[i].isblack = C_s; // Checked
^
comskip.c:278:18: note: expanded from macro 'C_s'
#define C_s (1<<2)
^
comskip.c:14369:44: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
frame[i].isblack = C_u;
^
comskip.c:280:18: note: expanded from macro 'C_u'
#define C_u (1<<3)
^
comskip.c:14373:40: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
frame[i].isblack = C_b;
^
comskip.c:281:18: note: expanded from macro 'C_b'
#define C_b (1<<4)
^
comskip.c:16282:12: warning: unused variable 'old_fps' [-Wunused-variable]
double old_fps = fps;
^
7 warnings and 1 error generated.
make: *** [comskip-comskip.o] Error 1
Any help would be most welcome, some gcc versioning thing?
Cheers.
You have to change line 147 to
extern void list_codecs();
That fixes the error msg so the build happens; the warning messages look relatively harmless.
@mackworth having this same issue, is there another thing to try? I get the same issue after cloning, autogen, configure, make
macmini@macserver Comskip % make
gcc -DPACKAGE_NAME=\"Comskip\" -DPACKAGE_TARNAME=\"comskip\" -DPACKAGE_VERSION=\"0.82.011\" -DPACKAGE_STRING=\"Comskip\ 0.82.011\" -DPACKAGE_BUGREPORT=\"https://github.com/erikkaashoek/Comskip/issues\" -DPACKAGE_URL=\"\" -DPACKAGE=\"comskip\" -DVERSION=\"0.82.011\" -DHAVE_LIBM=1 -DHAVE_LIBPTHREAD=1 -I. -Wall -I/usr/local/Cellar/argtable/2.13/include -I/usr/local/Cellar/ffmpeg/5.0/include -DPROCESS_CC -DDONATOR -g -O2 -MT comskip-comskip.o -MD -MP -MF .deps/comskip-comskip.Tpo -c -o comskip-comskip.o `test -f 'comskip.c' || echo './'`comskip.c
comskip.c:8876:9: error: implicit declaration of function 'list_codecs' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
list_codecs();
^
comskip.c:14354:44: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
frame[i].isblack = C_a;
^
comskip.c:279:18: note: expanded from macro 'C_a'
#define C_a (1<<5)
^
comskip.c:14356:44: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
frame[i].isblack = C_u; // Checked
^
comskip.c:280:18: note: expanded from macro 'C_u'
#define C_u (1<<3)
^
comskip.c:14358:44: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
frame[i].isblack = C_s;
^
comskip.c:278:18: note: expanded from macro 'C_s'
#define C_s (1<<2)
^
comskip.c:14360:44: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
frame[i].isblack = C_s; // Checked
^
comskip.c:278:18: note: expanded from macro 'C_s'
#define C_s (1<<2)
^
comskip.c:14362:44: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
frame[i].isblack = C_u;
^
comskip.c:280:18: note: expanded from macro 'C_u'
#define C_u (1<<3)
^
comskip.c:14366:40: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
frame[i].isblack = C_b;
^
comskip.c:281:18: note: expanded from macro 'C_b'
#define C_b (1<<4)
^
6 warnings and 1 error generated.
make: *** [comskip-comskip.o] Error 1
After changing line 147 of comskip.c to extern void list_codecs();
macmini@macserver Comskip % make
gcc -DPACKAGE_NAME=\"Comskip\" -DPACKAGE_TARNAME=\"comskip\" -DPACKAGE_VERSION=\"0.82.011\" -DPACKAGE_STRING=\"Comskip\ 0.82.011\" -DPACKAGE_BUGREPORT=\"https://github.com/erikkaashoek/Comskip/issues\" -DPACKAGE_URL=\"\" -DPACKAGE=\"comskip\" -DVERSION=\"0.82.011\" -DHAVE_LIBM=1 -DHAVE_LIBPTHREAD=1 -I. -Wall -I/usr/local/Cellar/argtable/2.13/include -I/usr/local/Cellar/ffmpeg/5.0/include -DPROCESS_CC -DDONATOR -g -O2 -MT comskip-mpeg2dec.o -MD -MP -MF .deps/comskip-mpeg2dec.Tpo -c -o comskip-mpeg2dec.o `test -f 'mpeg2dec.c' || echo './'`mpeg2dec.c
mpeg2dec.c:410:68: error: no member named 'codec' in 'struct AVStream'
int s_per_frame = (to_pts - from_pts) * (double)(is->audio_st->codec->sample_rate+1);
~~~~~~~~~~~~ ^
mpeg2dec.c:419:87: error: no member named 'codec' in 'struct AVStream'
buffer = & audio_buffer[(int)((from_pts - base_apts) * ((double)is->audio_st->codec->sample_rate+0.5) )];
~~~~~~~~~~~~ ^
mpeg2dec.c:432:72: error: no member named 'codec' in 'struct AVStream'
audio_samples -= (int)((from_pts - base_apts) * (is->audio_st->codec->sample_rate+0.5)); // incomplete frame before complete frame
~~~~~~~~~~~~ ^
mpeg2dec.c:465:71: error: no member named 'codec' in 'struct AVStream'
top_apts = base_apts + audio_samples / (double)(is->audio_st->codec->sample_rate);
~~~~~~~~~~~~ ^
mpeg2dec.c:479:9: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
if (abs(local_initial_pts) > 200)
^
mpeg2dec.c:479:9: note: use function 'fabs' instead
if (abs(local_initial_pts) > 200)
^~~
fabs
mpeg2dec.c:510:42: error: no member named 'codec' in 'struct AVStream'
if (old_sample_rate == is->audio_st->codec->sample_rate &&
~~~~~~~~~~~~ ^
mpeg2dec.c:512:52: error: no member named 'codec' in 'struct AVStream'
|| (top_apts - base_apts) * (is->audio_st->codec->sample_rate+0.5) > AUDIOBUFFER
~~~~~~~~~~~~ ^
mpeg2dec.c:514:67: error: no member named 'codec' in 'struct AVStream'
|| !ISSAME(((double)audio_samples /(double)(is->audio_st->codec->sample_rate+0.5))+ base_apts, top_apts)
~~~~~~~~~~~~ ^
mpeg2dec.c:355:30: note: expanded from macro 'ISSAME'
#define ISSAME(T1,T2) (fabs((T1) - (T2)) < 0.001)
^~
mpeg2dec.c:530:66: error: no member named 'codec' in 'struct AVStream'
if (old_sample_rate != 0 && old_sample_rate != is->audio_st->codec->sample_rate) {
~~~~~~~~~~~~ ^
mpeg2dec.c:531:95: error: no member named 'codec' in 'struct AVStream'
Debug(5, "Audio samplerate switched from %d to %d\n", old_sample_rate, is->audio_st->codec->sample_rate );
~~~~~~~~~~~~ ^
mpeg2dec.c:533:37: error: no member named 'codec' in 'struct AVStream'
old_sample_rate = is->audio_st->codec->sample_rate;
~~~~~~~~~~~~ ^
mpeg2dec.c:536:92: error: no member named 'codec' in 'struct AVStream'
if (fabs(base_apts - (is->audio_clock - ((double)audio_samples /(double)(is->audio_st->codec->sample_rate))))> 0.0001)
~~~~~~~~~~~~ ^
mpeg2dec.c:537:87: error: no member named 'codec' in 'struct AVStream'
base_apts = (is->audio_clock - ((double)audio_samples /(double)(is->audio_st->codec->sample_rate)));
~~~~~~~~~~~~ ^
mpeg2dec.c:538:48: error: no member named 'codec' in 'struct AVStream'
if (ALIGN_AC3_PACKETS && is->audio_st->codec->codec_id == AV_CODEC_ID_AC3) {
~~~~~~~~~~~~ ^
mpeg2dec.c:563:40: error: no member named 'codec' in 'struct AVStream'
for (l=0;l < is->audio_st->codec->channels;l++ )
~~~~~~~~~~~~ ^
mpeg2dec.c:571:48: error: no member named 'codec' in 'struct AVStream'
for (l=0;l < is->audio_st->codec->channels;l++ ) volume += *((fb[l])++) * 64000;
~~~~~~~~~~~~ ^
mpeg2dec.c:573:48: error: no member named 'codec' in 'struct AVStream'
for (l=0;l < is->audio_st->codec->channels;l++ ) volume += *((fb[0])++) * 64000;
~~~~~~~~~~~~ ^
mpeg2dec.c:574:62: error: no member named 'codec' in 'struct AVStream'
*audio_buffer_ptr++ = volume / is->audio_st->codec->channels;
~~~~~~~~~~~~ ^
mpeg2dec.c:575:58: error: no member named 'codec' in 'struct AVStream'
avg_volume += abs(volume / is->audio_st->codec->channels);
~~~~~~~~~~~~ ^
mpeg2dec.c:580:40: error: no member named 'codec' in 'struct AVStream'
for (l=0;l < is->audio_st->codec->channels;l++ )
~~~~~~~~~~~~ ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
1 warning and 20 errors generated.
make: *** [comskip-mpeg2dec.o] Error 1
Well, hardly an expert here, but looks like comskip.c is now compiling, and so make is moving on to mpeg2dec.c.
Why are you then getting an error no member named 'codec' in 'struct AVStream'
? Because there now isn't one. If you search for that error, you'll find this thread in OpenCV: https://github.com/opencv/opencv/issues/20147.
Looks like ffmpeg 4.4 finally removed the long-deprecated codec
entry in AVStream. Apparently you have to roll back to 4.3 (or 4.4, unclear which) to make this work.
I note that comskip just moved mpeg2dec.c to ffmpeg 4.4.1 8 days ago: https://github.com/erikkaashoek/Comskip/commit/b061aa46898c334a0a34c58c1cc5329db843cf71
There's more discussion of this here: https://github.com/erikkaashoek/Comskip/issues/142