Kompilasi FFMPEG + x264 - referensi tidak terdefinisi

Saya telah mencoba mencari solusi online selama beberapa hari tetapi tidak berhasil. Saya menggunakan Ubuntu dan mencoba mengkompilasi versi stabil FFMPEG terbaru (1.0.1) dengan dukungan x264. Saya memastikan saya menghapus instalasi x264 yang ada, lalu mengunduh sumber x264 terbaru dan mengkompilasinya dengan konfigurasi berikut:

./configure --prefix=$PREFIX \
    --enable-shared \
    --enable-static \
    --disable-gpac \
    --extra-cflags=" -I$ARM_INC -fPIC -DANDROID -fpic -mthumb-interwork -ffunction-sections -funwind-tables -fno-short-enums -D__ARM_ARCH
libavcodec/libavcodec.a(libx264.o): In function `X264_frame':
/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/ffmpeg-1.0.1/libavcodec/libx264.c:159: undefined reference to `x264_picture_init'
/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/ffmpeg-1.0.1/libavcodec/libx264.c:179: undefined reference to `x264_encoder_reconfig'
/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/ffmpeg-1.0.1/libavcodec/libx264.c:190: undefined reference to `x264_encoder_encode'
/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/ffmpeg-1.0.1/libavcodec/libx264.c:196: undefined reference to `x264_encoder_delayed_frames'
libavcodec/libavcodec.a(libx264.o): In function `encode_nals':
/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/ffmpeg-1.0.1/libavcodec/libx264.c:101: undefined reference to `x264_bit_depth'
libavcodec/libavcodec.a(libx264.o): In function `X264_close':
/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/ffmpeg-1.0.1/libavcodec/libx264.c:231: undefined reference to `x264_encoder_close'
libavcodec/libavcodec.a(libx264.o): In function `X264_init':
/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/ffmpeg-1.0.1/libavcodec/libx264.c:284: undefined reference to `x264_param_default'
/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/ffmpeg-1.0.1/libavcodec/libx264.c:292: undefined reference to `x264_param_default_preset'
/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/ffmpeg-1.0.1/libavcodec/libx264.c:314: undefined reference to `x264_param_parse'
/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/ffmpeg-1.0.1/libavcodec/libx264.c:459: undefined reference to `x264_param_apply_fastfirstpass'
/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/ffmpeg-1.0.1/libavcodec/libx264.c:490: undefined reference to `x264_param_apply_profile'
/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/ffmpeg-1.0.1/libavcodec/libx264.c:533: undefined reference to `x264_encoder_open_129'
/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/ffmpeg-1.0.1/libavcodec/libx264.c:544: undefined reference to `x264_encoder_headers'
_ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -Wno-psabi -march=armv5te -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -DANDROID -Wa,--noexecstack -MMD -MP " \ --extra-ldflags=" -nostdlib -Bdynamic -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,nocopyreloc -Wl,-soname,/usr/lib/libz.so -Wl,-rpath-link=$ARM_LIB,-dynamic-linker=/system/bin/linker -L$ARM_LIB -lc -lm -ldl -lgcc" \ --cross-prefix=${ARM_PRE}- \ --disable-asm \ --host=arm-linux \ make clean make install

Semuanya berjalan dengan baik, dan saya memeriksa versi yang diinstal:

x264 -V
    x264 0.129.x
    built on Dec 27 2012, gcc: 4.6.1
    configuration: --bit-depth=8 --chroma-format=all
    x264 license: GPL version 2 or later

Saya kemudian mencoba mengkompilasi FFMPEG dengan opsi berikut:

./configure --target-os=linux \
    --enable-libx264 \
    --enable-gpl \
    --prefix=$PREFIX \
    --extra-cflags="-I/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/ffmpeg-1.0.1/android/armv7-a/include -I/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/x264 -O3 -fpic -DANDROID -DHAVE_SYS_UIO_H=1 -Dipv6mr_interface=ipv6mr_ifindex -fasm -Wno-psabi -fno-short-enums  -fno-strict-aliasing -finline-limit=300 $OPTIMIZE_CFLAGS " \
    --extra-ldflags="-Wl,-rpath-link=$PLATFORM/usr/lib -L/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/ffmpeg-1.0.1/android/armv7-a/lib -L$PLATFORM/usr/lib -nostdlib -lc -lm -ldl -llog" \
    --enable-cross-compile \
    --extra-libs="-lgcc" \
    --arch=arm \
    --cc=$PREBUILT/bin/arm-linux-androideabi-gcc \
    --cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
    --nm=$PREBUILT/bin/arm-linux-androideabi-nm \
    --sysroot=$PLATFORM \

Konfigurasi dan make clean/make install berfungsi dengan baik, tetapi ketika saya mencoba membuat file .so, perintah berikut gagal:

/home/tishu/Apps/android-ndk-r8d/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ld 
    -rpath-link=./android/armv7-a/usr/lib -L/home/tishu/Apps/android-ndk-r8d/platforms/android-14/arch-arm/usr/lib -soname libffmpeg.so -shared -nostdlib  -z,noexecstack -Bsymbolic \
    --whole-archive --no-undefined -o ./android/armv7-a/libffmpeg.so libavcodec/libavcodec.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog  \
    --warn-once \
    --dynamic-linker=/system/bin/linker /home/tishu/Apps/android-ndk-r8d/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a

Ini gagal dengan output berikut:

libavcodec/libavcodec.a(libx264.o): In function `X264_frame':
/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/ffmpeg-1.0.1/libavcodec/libx264.c:159: undefined reference to `x264_picture_init'
/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/ffmpeg-1.0.1/libavcodec/libx264.c:179: undefined reference to `x264_encoder_reconfig'
/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/ffmpeg-1.0.1/libavcodec/libx264.c:190: undefined reference to `x264_encoder_encode'
/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/ffmpeg-1.0.1/libavcodec/libx264.c:196: undefined reference to `x264_encoder_delayed_frames'
libavcodec/libavcodec.a(libx264.o): In function `encode_nals':
/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/ffmpeg-1.0.1/libavcodec/libx264.c:101: undefined reference to `x264_bit_depth'
libavcodec/libavcodec.a(libx264.o): In function `X264_close':
/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/ffmpeg-1.0.1/libavcodec/libx264.c:231: undefined reference to `x264_encoder_close'
libavcodec/libavcodec.a(libx264.o): In function `X264_init':
/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/ffmpeg-1.0.1/libavcodec/libx264.c:284: undefined reference to `x264_param_default'
/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/ffmpeg-1.0.1/libavcodec/libx264.c:292: undefined reference to `x264_param_default_preset'
/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/ffmpeg-1.0.1/libavcodec/libx264.c:314: undefined reference to `x264_param_parse'
/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/ffmpeg-1.0.1/libavcodec/libx264.c:459: undefined reference to `x264_param_apply_fastfirstpass'
/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/ffmpeg-1.0.1/libavcodec/libx264.c:490: undefined reference to `x264_param_apply_profile'
/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/ffmpeg-1.0.1/libavcodec/libx264.c:533: undefined reference to `x264_encoder_open_129'
/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/ffmpeg-1.0.1/libavcodec/libx264.c:544: undefined reference to `x264_encoder_headers'

Versi x264 yang dicari (129) adalah versi yang berhasil diinstal dan dikompilasi dengan --eanable-shared. Jelas semua kompilasi baik-baik saja ketika saya tidak menyertakan libx64.

Pertanyaan: Bagaimana cara menentukan jalur penyertaan untuk perintah terakhir? Saya mencoba menambahkan jalur ke $PATH dan juga menambahkan ini sebagai argumen tetapi tidak berhasil: -I/home/tishu/Workspaces/ffmpeg/ffmpeg/jni/x264

Terima kasih


person tishu    schedule 29.12.2012    source sumber
comment
Beberapa penggalian lebih lanjut tentang cara kerja ld melakukan pekerjaan: network-theory.co .uk/docs/gccintro/gccintro_95.html - Saya baru saja menambahkan libx64.a ke daftar file yang akan ditautkan dan sekarang berfungsi   -  person tishu    schedule 29.12.2012
comment
Pesan undefined reference dapat menunjukkan bahwa Anda mungkin menginstal dua versi x264 berbeda secara bersamaan.   -  person llogan    schedule 29.12.2012
comment
Jika Anda membuat x264 untuk ARM dengan benar, Anda tidak akan dapat menjalankannya untuk menerima eksposur kedua. Entah Anda gagal menghapus instalasi versi x86, atau telah membangunnya kembali. Bagaimanapun, Anda mungkin dapat memperbaiki build ffmpeg Anda hanya dengan menambahkan /home/tishu/Workspaces/ffmpeg/ffmpeg/jni/x264/libx264.so ke --extra-ldflags=   -  person Alex Cohn    schedule 31.12.2012
comment
Hai Tishu :) Saya mencoba memutar file .ts dari aplikasi Android. Untuk ini saya telah menggunakan perpustakaan FFmpeg dari github. com/appunite/AndroidFFmpeg. Saya telah berhasil mengkompilasi & menjalankan aplikasi contoh dengan sukses. Tetapi aplikasi tidak dapat memutar file .ts. Bisakah Anda membimbing saya apa yang harus saya lakukan untuk memutar file .ts. Terima kasih   -  person Arun Badole    schedule 31.12.2012


Jawaban (1)


Untuk pengikut (bahkan bukan android tetapi pesan serupa),

/.../mingw-w64-i686/lib/gcc/.../i686-w64-mingw32/bin/ld: 
libavcodec/libavcodec.a(libx264.o):libx264.c:(.text+0x3c): 
undefined reference to `x264_bit_depth'
: undefined reference to `x264_encoder_open_152'

tampaknya konstanta ini "dihapus" pada awal tahun 2017, lihat https://trac.ffmpeg.org/ticket/6966 dan https://trac.ffmpeg.org/ticket/6932

perbaikan: perbarui ffmpeg, atau unduh libx264...atau apalah...

meskipun saat ini seharusnya juga mendukung libx264 versi lama...

person rogerdpack    schedule 06.02.2019