ffmpeg for development, libavutil error

For the developers that use FFmpeg in their software.
Post Reply
youngluoyang
Posts: 2
Joined: Thu Feb 15, 2018 3:12 am

ffmpeg for development, libavutil error

Post by youngluoyang » Thu Feb 15, 2018 3:18 am

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

Code: Select all

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.

Code: Select all

#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.

Code: Select all

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:

Code: Select all

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 '[email protected]@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.

Code: Select all

$ echo $LD_LIBRARY_PATH 
/opt/ffmpeg/lib:

youngluoyang
Posts: 2
Joined: Thu Feb 15, 2018 3:12 am

Re: ffmpeg for development, libavutil error

Post by youngluoyang » Wed Feb 21, 2018 11:39 am

:roll:

Post Reply