ffmpeg-libav-tutorial icon indicating copy to clipboard operation
ffmpeg-libav-tutorial copied to clipboard

cannot make

Open luoyanghero opened this issue 7 years ago • 12 comments

I use centos7. I use yum installed the following pakages:

sudo yum install ffmpeg.x86_64 ffmpeg-debuginfo.x86_64 ffmpeg-devel.x86_64 ffmpeg-libs.x86_64

and I can run ffmpeg. But when I make your 0_helllo_word.c, show me the following error:

gcc -g -Wall -o build/hello_world -lavformat -lavcodec -lswscale -lz 0_hello_world.c
&& ./build/hello_world small_bunny_1080p_60fps.mp4 0_hello_world.c:14:32: fatal error: libavcodec/avcodec.h: No such file or directory

So what environment do I need prepare before I run your make?

luoyanghero avatar Jan 21 '18 15:01 luoyanghero

@luoyanghero I don't have a CentOS7 in here to test but you could be using docker as well.

leandromoreira avatar Jan 21 '18 16:01 leandromoreira

I ran into this problem on Ubuntu 16.04 as well. Make sure that the correct version (I think >= 3.1) libavcodec-dev and its dependencies are installed.

mutaphore avatar Jan 21 '18 18:01 mutaphore

Now I use ubuntu 16.04, but the default apt reposity is 2.8.11. I goto the ffmpeg official web, and try to download all .deb pakages of 3.4.1 version (proposed for ubuntu 18.04). Install failed.

need: ########### libavcodec57:amd64 depends on libmp3lame0 (>= 3.100); however: but ubuntu 16.04 is: ########### libmp3lame0/xenial,now 3.99.5+repack1-9build1 amd64 [installed,automatic]

So how do you install ffmpeg 3.x in ubuntu 16.04?

luoyanghero avatar Jan 22 '18 06:01 luoyanghero

@luoyanghero you can try to build the latest version from source https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu

leandromoreira avatar Jan 22 '18 08:01 leandromoreira

@luoyanghero @mutaphore Build ffmpeg from source, only install dependencies from apt. It's much more easier than you think.

halfelf avatar Jan 23 '18 03:01 halfelf

FFMPEG update every 3 month. It make my CentOS env too complex. I am trying to use a docker-ffmpeg image. https://github.com/jrottenberg/ffmpeg But now I only know how to use the docker-ffmpeg, still not know how to use it for develop ffmpeg.(This image seems no c-language-make tools)

luoyanghero avatar Jan 26 '18 09:01 luoyanghero

@luoyanghero If the environment is a trouble, building it from source is moreover a better choice, even including building dependencies. By specifying prefix, there won't be anything mess with other local libs or binaries. And normally no need to build it for every release, except there is some new feature really needed.

halfelf avatar Jan 27 '18 03:01 halfelf

@halfelf I found docker is a good tool. I want to learn how to use it and use for develop. Some examples of docker dev is for java/web dev, for ffmpeg dev is very few. I'm puzzle that I didn't find the ffmpeg dev example of using docker, or there is nobody using docker for ffmpeg dev. I'm trying to find the results.

luoyanghero avatar Jan 27 '18 03:01 luoyanghero

Now I use ubuntu to build a ffmpeg341 env. Run ffmpeg is OK. But when I compile hello_word. Show the follow error:

luoy@TTlyN:~/w/ffmpeg/ffmpeg-libav-tutorial-master$ make
gcc -g -Wall -o build/hello_world -lz 0_hello_world.c \
-I/opt/ffmpeg/include -L/opt/ffmpeg/lib -std=c99  \
-lavformat -lavcodec -lswscale  
/usr/bin/ld: /tmp/ccItrnl8.o: undefined reference to symbol 'av_frame_free@@LIBAVUTIL_55'
/opt/ffmpeg/lib//libavutil.so.55: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:6: recipe for target 'hello_world' failed
make: *** [hello_world] Error 1

luoyanghero avatar Feb 12 '18 14:02 luoyanghero

I try to run my compiled ffmpeg, it is OK.

export LD_LIBRARY_PATH=/opt/ffmpeg/lib/ /opt/ffmpeg/bin/ffmpeg -i "/home/luoy/Videos/芳华.2017.TC720P独家高清中字.mp4" -ss 00:00:00 -t 00:00:01 -f image2 -y "./2_%04d.bmp" ffmpeg version 3.4.1 Copyright (c) 2000-2017 the FFmpeg developers built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.6) 20160609 configuration: --enable-debug --enable-doc --disable-ffplay --enable-shared --enable-avresample --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-gpl --enable-libass --enable-libfreetype --enable-libvidstab --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx265 --enable-libxvid --enable-libx264 --enable-nonfree --enable-openssl --enable-libfdk_aac --enable-postproc --enable-small --enable-version3 --extra-cflags=-I/opt/ffmpeg/include --extra-ldflags=-L/opt/ffmpeg/lib --extra-libs=-ldl --prefix=/opt/ffmpeg libavutil 55. 78.100 / 55. 78.100 libavcodec 57.107.100 / 57.107.100 libavformat 57. 83.100 / 57. 83.100 libavdevice 57. 10.100 / 57. 10.100 libavfilter 6.107.100 / 6.107.100 libavresample 3. 7. 0 / 3. 7. 0 libswscale 4. 8.100 / 4. 8.100 libswresample 2. 9.100 / 2. 9.100 libpostproc 54. 7.100 / 54. 7.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/luoy/Videos/芳华.2017.TC720P独家高清中字.mp4': Metadata: major_brand : isom minor_version : 1 compatible_brands: isomavc1 creation_time : 2017-12-15T16:28:00.000000Z encoder : Lite MP4 Tool v2.3 Duration: 02:09:09.24, start: 0.000000, bitrate: 1587 kb/s Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p, 1280x720, 1456 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default) Metadata: creation_time : 2017-12-15T16:28:00.000000Z handler_name : Imported with GPAC 0.4.6-DEV (internal rev. 5) Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default) Metadata: creation_time : 2017-12-15T16:28:45.000000Z handler_name : GPAC ISO Audio Handler Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> bmp (native)) Press [q] to stop, [?] for help Output #0, image2, to './2_%04d.bmp': Metadata: major_brand : isom minor_version : 1 compatible_brands: isomavc1 encoder : Lavf57.83.100 Stream #0:0(und): Video: bmp, bgr24, 1280x720, q=2-31, 200 kb/s, 23.98 fps, 23.98 tbn, 23.98 tbc (default) Metadata: creation_time : 2017-12-15T16:28:00.000000Z handler_name : Imported with GPAC 0.4.6-DEV (internal rev. 5) encoder : Lavc57.107.100 bmp frame= 24 fps=0.0 q=-0.0 Lsize=N/A time=00:00:01.00 bitrate=N/A dup=1 drop=0 speed= 5.6x
video:64801kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

Now I write a simple code.

#include "libavcodec/avcodec.h" #include "libavformat/avformat.h" #include <stdio.h> #include <stdarg.h> #include <stdlib.h> #include <string.h> #include <inttypes.h> #include <errno.h> #include <stddef.h> #include "libavutil/error.h"

int main(int argc, const char *argv[]) { av_register_all();

int response = 0; char *pchar; // pchar = av_err2str(response);

return 0; }

Use the follow command for make, it's OK.

gcc -g -Wall -o build/hello_world -lz 0_hello_world.c
-lavformat -lavcodec -lswscale
-I/opt/ffmpeg/include -L/opt/ffmpeg/lib

But I use the "av_err2str" function, uncomment this line: 'pchar = av_err2str(response);' compile show the following error:

gcc -g -Wall -o build/hello_world -lz 0_hello_world.c
-lavformat -lavcodec -lswscale
-I/opt/ffmpeg/include -L/opt/ffmpeg/lib 0_hello_world.c: In function ‘main’: 0_hello_world.c:16:9: warning: variable ‘pchar’ set but not used [-Wunused-but-set-variable] char *pchar; ^ /usr/bin/ld: /tmp/ccgJJ9CV.o: undefined reference to symbol 'av_strerror@@LIBAVUTIL_55' /opt/ffmpeg/lib/libavutil.so.55: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status Makefile:10: recipe for target 'hello_world' failed make: *** [hello_world] Error 1

As I know "av_register_all" use the "libavformat/avformat.h" header; "av_err2str" use the "libavutil/error.h" header. Both the two headers I have included, why "av_err2str" is not OK? I guess this is my environment not OK, How can I find the error? I have checked my LD_LIBRARY_PATH, it is OK.

$ echo $LD_LIBRARY_PATH /opt/ffmpeg/lib:

luoyanghero avatar Feb 15 '18 03:02 luoyanghero

@luoyanghero and everybody I did a docker image, now we should use the same development/running environment.

leandromoreira avatar Nov 05 '18 00:11 leandromoreira

Can you check to see if we can close this?

leandromoreira avatar Nov 05 '18 00:11 leandromoreira