Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: ‘CODEC_TYPE_AUDIO’ undeclared #19

Open
sharp opened this issue Feb 28, 2012 · 6 comments
Open

error: ‘CODEC_TYPE_AUDIO’ undeclared #19

sharp opened this issue Feb 28, 2012 · 6 comments

Comments

@sharp
Copy link

sharp commented Feb 28, 2012

When I run make:

gcc -Wall -g live_segmenter.c -o live_segmenter -lavformat -lavcodec -lavutil -lbz2 -lm -lz -lfaac -lmp3lame -lx264 -lfaad -lpthread
live_segmenter.c: In function ‘add_output_stream’:
live_segmenter.c:70:10: error: ‘CODEC_TYPE_AUDIO’ undeclared (first use in this function)
live_segmenter.c:70:10: note: each undeclared identifier is reported only once for each function it appears in
live_segmenter.c:84:10: error: ‘CODEC_TYPE_VIDEO’ undeclared (first use in this function)
live_segmenter.c: In function ‘main’:
live_segmenter.c:149:3: warning: ‘av_open_input_file’ is deprecated (declared at /usr/local/include/libavformat/avformat.h:1090) [-Wdeprecated-declarations]
live_segmenter.c:165:3: warning: implicit declaration of function ‘guess_format’ [-Wimplicit-function-declaration]
live_segmenter.c:165:35: warning: initialization makes pointer from integer without a cast [enabled by default]
live_segmenter.c:192:12: error: ‘CODEC_TYPE_VIDEO’ undeclared (first use in this function)
live_segmenter.c:197:12: error: ‘CODEC_TYPE_AUDIO’ undeclared (first use in this function)
live_segmenter.c:208:3: warning: ‘av_set_parameters’ is deprecated (declared at /usr/local/include/libavformat/avformat.h:1434) [-Wdeprecated-declarations]
live_segmenter.c:214:3: warning: ‘dump_format’ is deprecated (declared at /usr/local/include/libavformat/avformat.h:1559) [-Wdeprecated-declarations]
live_segmenter.c:232:3: warning: ‘url_fopen’ is deprecated (declared at /usr/local/include/libavformat/avio.h:279) [-Wdeprecated-declarations]
live_segmenter.c:238:3: warning: ‘av_write_header’ is deprecated (declared at /usr/local/include/libavformat/avformat.h:1492) [-Wdeprecated-declarations]
live_segmenter.c:267:63: error: ‘PKT_FLAG_KEY’ undeclared (first use in this function)
live_segmenter.c:283:7: warning: ‘put_flush_packet’ is deprecated (declared at /usr/local/include/libavformat/avio.h:293) [-Wdeprecated-declarations]
live_segmenter.c:284:7: warning: ‘url_fclose’ is deprecated (declared at /usr/local/include/libavformat/avio.h:280) [-Wdeprecated-declarations]
live_segmenter.c:289:7: warning: ‘url_fopen’ is deprecated (declared at /usr/local/include/libavformat/avio.h:279) [-Wdeprecated-declarations]
live_segmenter.c:326:3: warning: ‘url_fclose’ is deprecated (declared at /usr/local/include/libavformat/avio.h:280) [-Wdeprecated-declarations]
make: *** [all] Error 1

@poszest16
Copy link

Same problem here.

Running: gcc 4.6.1-9ubuntu3 on Ubuntu 11.10, Kernel 3.0.0-17-server X86_64

gcc -Wall -L /usr/lib/ -g live_segmenter.c -o live_segmenter -lavformat -lavcodec -lavutil -lbz2 -lm -lz -lfaac -lmp3lame -lx264 -lfaad -lpthread 
live_segmenter.c: In function ‘add_output_stream’:
live_segmenter.c:41:3: warning: ‘av_new_stream’ is deprecated (declared at /usr/local/include/libavformat/avformat.h:1541) [-Wdeprecated-declarations]
live_segmenter.c:70:10: error: ‘CODEC_TYPE_AUDIO’ undeclared (first use in this function)
live_segmenter.c:70:10: note: each undeclared identifier is reported only once for each function it appears in
live_segmenter.c:84:10: error: ‘CODEC_TYPE_VIDEO’ undeclared (first use in this function)
live_segmenter.c: In function ‘main’:
live_segmenter.c:149:3: warning: implicit declaration of function ‘av_open_input_file’ [-Wimplicit-function-declaration]
live_segmenter.c:156:3: warning: ‘av_find_stream_info’ is deprecated (declared at /usr/local/include/libavformat/avformat.h:1341) [-Wdeprecated-declarations]
live_segmenter.c:165:3: warning: implicit declaration of function ‘guess_format’ [-Wimplicit-function-declaration]
live_segmenter.c:165:35: warning: initialization makes pointer from integer without a cast [enabled by default]
live_segmenter.c:195:12: error: ‘CODEC_TYPE_VIDEO’ undeclared (first use in this function)
live_segmenter.c:200:12: error: ‘CODEC_TYPE_AUDIO’ undeclared (first use in this function)
live_segmenter.c:211:3: warning: implicit declaration of function ‘av_set_parameters’ [-Wimplicit-function-declaration]
live_segmenter.c:217:3: warning: implicit declaration of function ‘dump_format’ [-Wimplicit-function-declaration]
live_segmenter.c:227:5: warning: ‘avcodec_open’ is deprecated (declared at /usr/local/include/libavcodec/avcodec.h:3722) [-Wdeprecated-declarations]
live_segmenter.c:240:3: warning: implicit declaration of function ‘url_fopen’ [-Wimplicit-function-declaration]
live_segmenter.c:240:55: error: ‘URL_WRONLY’ undeclared (first use in this function)
live_segmenter.c:246:3: warning: implicit declaration of function ‘av_write_header’ [-Wimplicit-function-declaration]
live_segmenter.c:308:7: warning: implicit declaration of function ‘put_flush_packet’ [-Wimplicit-function-declaration]
live_segmenter.c:309:7: warning: implicit declaration of function ‘url_fclose’ [-Wimplicit-function-declaration]
live_segmenter.c:188:13: warning: variable ‘audio_stream’ set but not used [-Wunused-but-set-variable]
make: *** [all] Error 1

@poszest16
Copy link

Fixed it. Error is a result of the script failing the include file "libavformat/avformat.h". I fixed it by copying /usr/include/libavformat to the compile root. I also had to compile executing gcc this way

gcc -v -Wall -g live_segmenter.c -o live_segmenter \
    -lavformat -lavcodec -lavutil -lvorbis -ltheora\
    -lbz2 -lm -lz -lfaac -lmp3lame

@wernerramaekers
Copy link

I am having the same problem, could you give a little more detail on how you solved it ? What did you do when you say "by copying /usr/include/libavformat to the compile root" ?
What version of libavformat did you use ?

thanks for sharing !

@poszest16
Copy link

not sure which version of libavformat I used because at first I used the version that is included with debian build of ffmpeg. Even tough my build was successful the binary gave me segmentation faults left and right. With the need to work with h264 codecs, I tried using the libavformat version that is included with the ffmpeg source downloaded when following this tutorial, http://pasindudps.blogspot.com/2011/10/compiling-installing-ffmpeg-in-ubuntu.html. I ended up with many more errors because it turns out that in latest version of libavformat they replaced CODEC_TYPE_AUDIO (On Line 55) and CODEC_TYPE_VIDEO (On Line 67) with AVMEDIA_TYPE_AUDIO and AVMEDIA_TYPE_VIDEO. Also the avcodec_open function (On Line 218) was changed to require one additional argument but you can just add NULL as the third argument. Once I updated the outdated code I was able to build a success build without the previous segmentation fault. I still have a lot to diagnose but I hope to have a working HLS soon.

I'm no C programmer but my ability to diagnose the error comes from being a excellent PHP programmer. The syntax is not that much different.

@poszest16
Copy link

I got so fed up with trouble I was getting from ffmpeg and live_segmenter that I decided to take a more conventional route and use the HLS on Wowza but that is even proving to be like pulling teeth. I have tried other encoded media with the same result. If you notice at the end of live_segmenter is the argument encoding_profile but I do not get the reason for this argument because no parameters exist for encoding profiles other then what is located in the config file that you use with the ruby script like so ruby http_streamer.rb default.yml. I must be missing something. Here is my current output of live_segmenter.

root@server:~/segmenter# ruby http_streamer.rb default.yml

I, [2012-04-11T15:57:47.651494 #14965]  INFO -- : HTTP Streamer started
I, [2012-04-11T15:57:47.652130 #14965]  INFO -- : Transfer thread started
I, [2012-04-11T15:57:47.652310 #14965]  INFO -- : Encoding thread started
D, [2012-04-11T15:57:47.652477 #14965] DEBUG -- : Executing: ffmpeg -i /var/www/streaming/media_test.mp4 -f mpegts -acodec libfaac -ac 1 -vcodec libx264 -s 320x240 -level 30 - | ./live_segmenter 10 /tmp media_default default
D, [2012-04-11T15:57:48.261210 #14965] DEBUG -- : Encoder default: ffmpeg version git-2012-04-04-a4e359a Copyright (c) 2000-2012 the FFmpeg developers
  built on Apr  4 2012 00:37:36 with gcc 4.6.1
  configuration: --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab
  libavutil      51. 44.100 / 51. 44.100
  libavcodec     54. 12.100 / 54. 12.100
  libavformat    54.  3.100 / 54.  3.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 66.101 /  2. 66.101
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 10.100 /  0. 10.100
  libpostproc    52.  0.100 / 52.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/var/www/streaming/media_test.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isom
    creation_time   : 2010-08-29 13:58:19
    encoder         : mp4creator 1.6
  Duration: 00:24:09.96, start: 0.000000, bitrate: 1490 kb/s
    Stream #0:0(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, s16, 61 kb/s
    Metadata:
      creation_time   : 2010-08-29 13:58:19
      handler_name    : 
    Stream #0:1(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 1350 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Metadata:
      creation_time   : 2010-08-29 13:58:20
      handler_name    : 
    Stream #0:2(eng): Data: none (rtp  / 0x20707472)
    Metadata:
      creation_time   : 2010-08-29 13:58:49
      handler_name    : 
    Stream #0:3(eng): Data: none (rtp  / 0x20707472)
    Metadata:
      creation_time   : 2010-08-29 13:58:51
      handler_name    : 
[buffer @ 0x1aa9300] w:1280 h:720 pixfmt:yuv420p tb:1/1000000 sar:0/1 sws_param:flags=2
[scale @ 0x1ad5ea0] w:1280 h:720 fmt:yuv420p sar:0/1 -> w:320 h:240 fmt:yuv420p sar:0/1 flags:0x4
[libx264 @ 0x1b6a900] using cpu capabilities: MMX2 SSE2 SSE3 Cache64
[libx264 @ 0x1b6a900] profile High, level 3.0
[mpegts @ 0x1ad7300] muxrate VBR, pcr every 2 pkts, sdt every 200, pat/pmt every 40 pkts
Output #0, mpegts, to 'pipe:':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isom
    creation_time   : 2010-08-29 13:58:19
    encoder         : Lavf54.3.100
    Stream #0:0(eng): Video: h264, yuv420p, 320x240, q=-1--1, 90k tbn, 25 tbc
    Metadata:
      creation_time   : 2010-08-29 13:58:20
      handler_name    : 
    Stream #0:1(eng): Audio: aac, 48000 Hz, 1 channels, s16, 128 kb/s
    Metadata:
      creation_time   : 2010-08-29 13:58:19
      handler_name    : 
Stream mapping:
  Stream #0:1 -> #0:0 (h264 -> libx264)
  Stream #0:0 -> #0:1 (aac -> libfaac)
Press [q] to stop, [?] for help
frame=   46 fps=0.0 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits/s dup=2 drop=0    
E, [2012-04-11T15:57:50.766651 #14965] ERROR -- : Encoder default: [mpegts @ 0x16d2260] max_analyze_duration reached
[mpegts @ 0x16d2260] Estimating duration from bitrate, this may be inaccurate
Output #0, mpegts, to 'media_default':
[mpegts @ 0x184e5e0] no streams
Segmenter error: Could not write mpegts header to first output file

D, [2012-04-11T15:57:50.767067 #14965] DEBUG -- : Return code from default: 0
I, [2012-04-11T15:57:50.767177 #14965]  INFO -- : Encoding thread terminated
I, [2012-04-11T15:57:50.767375 #14965]  INFO -- : Transfer initiated with value = *quit*
I, [2012-04-11T15:57:50.767480 #14965]  INFO -- : Transfer thread terminated
I, [2012-04-11T15:57:50.767622 #14965]  INFO -- : HTTP Streamer terminated```

@gzq413
Copy link

gzq413 commented Jul 22, 2012

live_segmenter.c:41:3: warning: ‘av_new_stream’ is deprecated (declared at /usr/local/include/libavformat/avformat.h:1541) [-Wdeprecated-declarations]

open the file /usr/local/include/libavformat/avformat.h
in the line 1541 :
#if FF_API_NEW_STREAM
attribute_deprecated
AVStream *av_new_stream(AVFormatContext *s, int id);
#endif

then correct it like this :

#if FF_API_NEW_STREAM
//attribute_deprecated
AVStream *av_new_stream(AVFormatContext *s, int id);
#endif
then the warning will disapper!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants