Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 22nd June 2022, 01:57   #21  |  Link
qyot27
...?
 
qyot27's Avatar
 
Join Date: Nov 2005
Location: Florida
Posts: 1,355
Try using make clean before building FFmpeg (or even make distclean, and then re-run configure as well, if you have to, add --enable-pic to the FFmpeg configure step). The recompile with -fPIC message sometimes just happens, but other times it's because some part of the configuration changed to include a new external library that was built with fPIC but the main FFmpeg was not.
qyot27 is offline   Reply With Quote
Old 22nd June 2022, 11:28   #22  |  Link
Losko
Registered User
 
Join Date: Dec 2010
Posts: 57
Quote:
Originally Posted by forgetfool View Post
Code:
  CXXLD    src/core/libffms2.la
/usr/bin/ld: /home/romashka/ffmpeg_build_for_ffms2/lib/libswscale.a(swscale.o): warning: relocation against `ff_M24B' in read-only section `.text'
/usr/bin/ld: /home/romashka/ffmpeg_build_for_ffms2/lib/libavcodec.a(vc1dsp_mmx.o): relocation R_X86_64_PC32 against symbol `ff_pw_9' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make: *** [Makefile:653: src/core/libffms2.la] Error 1
I recently faced a similar "relocation..." error message (on a different OS, truth be told) when, due to a hidden setting, the linker was trying to mix up several object files created for a static build into a shared object - that doesn't make any sense.
So, as I first step I would double check your build from the basis: do you want ffmpeg shared (CHECK THIS!) ? ffms2 shared ?
Losko is offline   Reply With Quote
Old 22nd June 2022, 18:01   #23  |  Link
forgetfool
Registered User
 
Join Date: Aug 2020
Posts: 33
Thank you, people, for your replies. I REALLY need to get this working... This is my process (from scratch, i.e. no old files and folders). Can someone spot a problem? BIG THANKS!

1) Install AviSynthPlus and FFmpeg from the Community repo (inc. DevIL !)
2) Build/install minimal FFmpeg (*)
3) Build/install FFMS2, directing PKG_CONFIG_PATH to the minimal FFmpeg and installing it to $HOME/.local (**)

(*)
git clone git://git.ffmpeg.org/ffmpeg.git
cd ffmpeg
mkdir ffmpeg-build-for-ffms2
cd ffmpeg-build-for-ffms2
../configure --prefix=$HOME/ffmpeg_build_for_ffms2 --enable-gpl --enable-version3 --disable-encoders --disable-muxers --disable-doc --enable-debug --disable-devices --disable-avdevice --enable-libdav1d --enable-pic --extra-cflags="-march=native"
make -j$(nproc)
make install

(**)
git clone git://github.com/FFMS/ffms2 ("git://" does not respond, so I am using "https://")
cd ffms2
PKG_CONFIG_PATH=$HOME/ffmpeg_build_for_ffms2/lib/pkgconfig CPPFLAGS="-I/usr/include/avisynth" ./autogen.sh --prefix=$HOME/.local --libdir=$HOME/.local/lib/avisynth --enable-shared --enable-avisynth
make -j$(nproc)
----8<----
- at this point I get the failure from above about relocation
(1) mv /home/romashka/ffmpeg_build_for_ffms2/lib/libavcodec.a /home/romashka/ffmpeg_build_for_ffms2/lib/libavcodec.a.old
(2) mv /home/romashka/ffmpeg_build_for_ffms2/lib/libswscale.a /home/romashka/ffmpeg_build_for_ffms2/lib/libswscale.a.old
(3) make -j$(nproc)
- at this point I get the undefined references failure
(4) move the files from (1) & (2) back
(5) make -j$(nproc)
- at this point it builds fine
----8<----
make install


So everything seemed to have worked. But then I run "ffplay film.avs" and get an error:
[avisynth @ 0x7f554c000c80] Cannot load file '/home/romashka/.local/lib/avisynth/libffms2.so'. Reason: /home/romashka/.local/lib/avisynth/libffms2.so: undefined symbol: ff_mjpeg_val_ac_chrominance
(film.avs, line 20)
- Line 20 is a call to FFVideoSource()

Last edited by forgetfool; 22nd June 2022 at 18:06.
forgetfool is offline   Reply With Quote
Old 22nd June 2022, 19:16   #24  |  Link
qyot27
...?
 
qyot27's Avatar
 
Join Date: Nov 2005
Location: Florida
Posts: 1,355
Moving the FFmpeg libraries around manually outside the build process is what is breaking FFMS2, because you've removed the thing it *needs* to point to; the fact that it then builds absolutely means it's linking to the wrong library.

FFMS2 *should* be using -Wl,-Bsymbolic automatically when being pointed at a static FFmpeg, but if that's somehow broken, you have to provide it yourself to LDFLAGS.

Last edited by qyot27; 22nd June 2022 at 19:20.
qyot27 is offline   Reply With Quote
Old 23rd June 2022, 01:30   #25  |  Link
forgetfool
Registered User
 
Join Date: Aug 2020
Posts: 33
So what you are saying is that I need it to build naturally without the things I do in between ----8<----, right? Then it will link to the right libraries and will have no missing symbols?

This is what fails:

echo " CXXLD " src/core/libffms2.la;/bin/sh ./libtool --silent --tag=CXX --mode=link g++ -std=c++11 -fvisibility=hidden -O3 -Wall -Wextra -version-info 5:0:0 -o src/core/libffms2.la -rpath /home/romashka/.local/lib/avisynth src/core/audiosource.lo src/core/ffms.lo src/core/filehandle.lo src/core/indexing.lo src/core/track.lo src/core/utils.lo src/core/videosource.lo src/core/videoutils.lo src/core/zipfile.lo src/vapoursynth/vapoursource.lo src/vapoursynth/vapoursynth.lo src/avisynth/avssources.lo src/avisynth/avisynth.lo -L/home/romashka/ffmpeg_build_for_ffms2/lib -lavformat -lbz2 -lm -lavcodec -lm -llzma -ldav1d -lz -lswscale -lswresample -lavutil -pthread -lva-drm -lva-x11 -lvdpau -lm -lva -latomic -lX11 -lz

it looks like it's missing -Wl,-Bsymbolic. I'll try to see how to enable that.

Last edited by forgetfool; 23rd June 2022 at 01:52. Reason: more info
forgetfool is offline   Reply With Quote
Old 23rd June 2022, 16:21   #26  |  Link
forgetfool
Registered User
 
Join Date: Aug 2020
Posts: 33
I found this during the configure of ffms2:

checking whether -Wl,-Bsymbolic is needed... no

So I am missing something? configure file almost makes no sence to me ...

Last edited by forgetfool; 23rd June 2022 at 16:25.
forgetfool is offline   Reply With Quote
Old 23rd June 2022, 16:28   #27  |  Link
forgetfool
Registered User
 
Join Date: Aug 2020
Posts: 33
So I forced these things: -Wl,-Bsymbolic in LDFLAGS

It built.

AND WORKS!

So whats missing in the line below to get it included automatically?
PKG_CONFIG_PATH=$HOME/ffmpeg_build_for_ffms2/lib/pkgconfig CPPFLAGS="-I/usr/include/avisynth" ./autogen.sh --prefix=$HOME/.local --libdir=$HOME/.local/lib/avisynth --enable-shared --enable-avisynth

Last edited by forgetfool; 23rd June 2022 at 16:55.
forgetfool is offline   Reply With Quote
Old 24th June 2022, 01:29   #28  |  Link
qyot27
...?
 
qyot27's Avatar
 
Join Date: Nov 2005
Location: Florida
Posts: 1,355
Nothing you can do to FFMS2 will make it add Bsymbolic automatically. The way FFmpeg was built caused the disconnect. There are probably scenarios where FFMS2 will correctly detect that Bsymbolic is needed and add it, but in other cases, it's going to always be a requirement that the user pass it to LDFLAGS.

Code:
PKG_CONFIG_PATH=$HOME/ffmpeg_build_for_ffms2/lib/pkgconfig CPPFLAGS="-I/usr/include/avisynth" LDFLAGS="-Wl,-Bsymbolic" ./autogen.sh --prefix=$HOME/.local --libdir=$HOME/.local/lib/avisynth --enable-shared --enable-avisynth
qyot27 is offline   Reply With Quote
Old 24th June 2022, 17:24   #29  |  Link
forgetfool
Registered User
 
Join Date: Aug 2020
Posts: 33
Thank you, qyot27, once again. Final input from me for now: it looks like I was simply missing --enable-shared flag when running ../configure for ffmpeg build (see above). Including the flag fixed the overall build for ffms2. For some reason the flag was not required before...
forgetfool is offline   Reply With Quote
Old 24th June 2022, 18:32   #30  |  Link
qyot27
...?
 
qyot27's Avatar
 
Join Date: Nov 2005
Location: Florida
Posts: 1,355
When you're building a static build of FFmpeg, of course you don't want to use --enable-shared. It's not 'required' now either, because that's a completely different type of build.
qyot27 is offline   Reply With Quote
Old 28th June 2022, 06:37   #31  |  Link
forgetfool
Registered User
 
Join Date: Aug 2020
Posts: 33
Would anyone have an idea why both
1) ffplay film.avs
2) ffmpeg -i film.avs film.mkv
produce segmentation fault at the end?

Or is this question out of place here?

The stream or output file end up fine...

(gdb) bt
#0 0x00007f197409c89e in free () at /usr/lib/libc.so.6
#1 0x00007f1973c181ba in Cache::~Cache() () at /usr/lib/libvmaf.so.1
#2 0x00007f196374d06e in Cache::~Cache() () at /usr/lib/libavisynth.so
#3 0x00007f196376e58e in PClip::~PClip() () at /usr/lib/libavisynth.so
#4 0x00007f196374d0de in CacheGuard::~CacheGuard() () at /usr/lib/libavisynth.so
#5 0x00007f196374d11e in CacheGuard::~CacheGuard() () at /usr/lib/libavisynth.so
#6 0x00007f196376e58e in PClip::~PClip() () at /usr/lib/libavisynth.so
#7 0x00007f19637d6801 in () at /usr/lib/libavisynth.so
#8 0x00007f196376e58e in PClip::~PClip() () at /usr/lib/libavisynth.so
#9 0x00007f19637d6881 in () at /usr/lib/libavisynth.so
#10 0x00007f196376f8b4 in AVSValue:ESTRUCTOR() () at /usr/lib/libavisynth.so
#11 0x00007f196376f94e in AVSValue::~AVSValue() () at /usr/lib/libavisynth.so
#12 0x00007f196373ab98 in ScriptEnvironment::~ScriptEnvironment() () at /usr/lib/libavisynth.so
#13 0x00007f1963748fae in ScriptEnvironment:eleteScriptEnvironment() () at /usr/lib/libavisynth.so
#14 0x00007f196374c9af in avs_delete_script_environment () at /usr/lib/libavisynth.so
#15 0x00007f1975a3c355 in () at /usr/lib/libavformat.so.59
#16 0x00007f1975a3c40f in () at /usr/lib/libavformat.so.59
#17 0x00007f1975a8bf85 in avformat_close_input () at /usr/lib/libavformat.so.59
#18 0x000055c525cf5241 in ()
#19 0x000055c525cf57a5 in ()
#20 0x000055c525ce55c5 in main ()

Last edited by forgetfool; 28th June 2022 at 07:46.
forgetfool is offline   Reply With Quote
Old 2nd July 2022, 02:53   #32  |  Link
forgetfool
Registered User
 
Join Date: Aug 2020
Posts: 33
BLOODY HELL! This is impossible...

I have done everything again from complete scratch from the very start as I mention above (just to have --enable-debug for ffms2) and now everything just locks up... It's like that initial deadlock if you use original ffms2, except that it definitely uses my the manually built libffms2.so (if don't do AddAutoloadDir("/home/romashka/.local/lib/avisynth") it complains about not finding FFVideoSource).

I have done everything without --enable-debug, from scratch (just to be sure)... ffplay film.avs still locks up

ffplay film.avs
ffplay version n5.0.1 Copyright (c) 2003-2022 the FFmpeg developers
built with gcc 12.1.0 (GCC)
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm --enable-lto --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librav1e --enable-librsvg --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-nvdec --enable-nvenc --enable-shared --enable-version3
libavutil 57. 17.100 / 57. 17.100
libavcodec 59. 18.100 / 59. 18.100
libavformat 59. 16.100 / 59. 16.100
libavdevice 59. 4.100 / 59. 4.100
libavfilter 8. 24.100 / 8. 24.100
libswscale 6. 4.100 / 6. 4.100
libswresample 4. 3.100 / 4. 3.100
libpostproc 56. 3.100 / 56. 3.100
nan : 0.000 fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0


Last edited by forgetfool; 2nd July 2022 at 03:02.
forgetfool is offline   Reply With Quote
Old 2nd July 2022, 18:20   #33  |  Link
forgetfool
Registered User
 
Join Date: Aug 2020
Posts: 33
It's even crazier:

LOCKS UP (all proper files/func names) -
AddAutoloadDir("/home/romashka/.local/lib/avisynth")
a = FFAudioSource("audio.mp3")
v = FFVideoSource("video.AVI")
AudioDub(v, a)

LOCKS UP (no audio involved) -
AddAutoloadDir("/home/romashka/.local/lib/avisynth")
FFVideoSource("video.AVI")

RAISES AN ERROR (as expected, no such video) -
AddAutoloadDir("/home/romashka/.local/lib/avisynth")
FFVideoSource("no-such-video.AVI")

LOCKS UP (????????!!!!!)
AddAutoloadDir("/home/romashka/.local/lib/avisynth")
a = FFAudioSource("audio.mp3")
v = FFVideoSource("no-such-video.AVI")
AudioDub(v, a)

RAISES AN ERROR (as expected, wrong func name) -
AddAutoloadDir("/home/romashka/.local/lib/avisynth")
FFVideoSourceblahblahblah("no-such-video.AVI")

LOCKS UP (????????!!!!!)
AddAutoloadDir("/home/romashka/.local/lib/avisynth")
a = FFAudioSource("audio.mp3")
v = FFVideoSourceblahblahblah("no-such-video.AVI")
AudioDub(v, a)



LSMASHSource(), DirectShowSource(), FFmpegSource() all lock up (when using just them with a valid file)

Last edited by forgetfool; 2nd July 2022 at 18:47.
forgetfool is offline   Reply With Quote
Old 2nd July 2022, 19:27   #34  |  Link
qyot27
...?
 
qyot27's Avatar
 
Join Date: Nov 2005
Location: Florida
Posts: 1,355
Arch doesn't put the subdirectories in ~/.local on the system search paths; you have to do that yourself.

To reiterate again: build the minimal FFmpeg as static, and configure FFMS2 with LDFLAGS="-Wl,-Bsymbolic".
qyot27 is offline   Reply With Quote
Old 3rd July 2022, 07:51   #35  |  Link
forgetfool
Registered User
 
Join Date: Aug 2020
Posts: 33
Ok, I got it working cleaning EVERYTHING out first. This is my process.

for minimal FFMPEG:
1) ../configure --prefix=$HOME/ffmpeg_build_for_ffms2 --enable-gpl --enable-version3 --disable-encoders --disable-muxers --disable-doc --enable-debug --disable-devices --disable-avdevice --enable-libdav1d --extra-cflags="-march=native"
2) make -j$(nproc)
3) make install

This puts all the built stuff into $HOME/ffmpeg_build_for_ffms2


for FFMS2:
1) PKG_CONFIG_PATH=$HOME/ffmpeg_build_for_ffms2/lib/pkgconfig CPPFLAGS="-I/usr/include/avisynth" ./autogen.sh --prefix=$HOME/.local --libdir=$HOME/.local/lib/avisynth --enable-shared --enable-avisynth
2) make -j$(nproc)
3) make install

Currently 2) fails with the message
"lib/libavcodec.a(vc1dsp_mmx.o): relocation R_X86_64_PC32 against symbol `ff_pw_9' can not be used when making a shared object; recompile with -fPIC"

Everything goes smoothly if I manually enable the required flags in configure (src_core_libffms2_la_LDFLAGS="-Wl,-Bsymbolic"). They should be enabled automatically, I think, from the code below, but they are not:

.....
if ac_fn_c_try_link "$LINENO"
then :
eval no_bsymbolic=yes
else $as_nop
eval no_bsymbolic=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext

if test "$no_bsymbolic" = "no"; then
LDFLAGS="$LDFLAGS -Wl,-Bsymbolic"
.....


So I re-run 2), then run 3) and it puts libffms2.so into $HOME/.local/lib/avisynth, and that's the one that is being used (I verified that).

(Perhaps, I MUST CLEAN EVERYTHING, otherwise it links to old/global things and that's why I get a deadlock, like with the main package FFMS2...)



"/usr/bin/ffplay -v trace film.avs" (i.e. using the official FFMPEG package) works fine, however, it produces segfault after the rendering is finished.

Initialized opengl renderer.
ffplay version n5.0.1 Copyright (c) 2003-2022 the FFmpeg developers
built with gcc 12.1.0 (GCC)
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm --enable-lto --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librav1e --enable-librsvg --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-nvdec --enable-nvenc --enable-shared --enable-version3
libavutil 57. 17.100 / 57. 17.100
libavcodec 59. 18.100 / 59. 18.100
libavformat 59. 16.100 / 59. 16.100
libavdevice 59. 4.100 / 59. 4.100
libavfilter 8. 24.100 / 8. 24.100
libswscale 6. 4.100 / 6. 4.100
libswresample 4. 3.100 / 4. 3.100
libpostproc 56. 3.100 / 56. 3.100
Initialized opengl renderer.
[NULL @ 0x7fae94000c80] Opening '/home/romashka/Downloads/video-test/film-test-linux.avs' for reading
[file @ 0x7fae940015c0] Setting default whitelist 'file,crypto,data'
[avisynth @ 0x7fae94000c80] Format avisynth probed with size=2048 and score=50
[avisynth @ 0x7fae94000c80] avs_is_field_based: 0 sq= 0B f=0/0
[avisynth @ 0x7fae94000c80] avs_is_parity_known: 0
[avisynth @ 0x7fae94000c80] Before avformat_find_stream_info() pos: 0 bytes read:1541 seeks:0 nb_streams:2
[avisynth @ 0x7fae94000c80] All info found 0KB sq= 0B f=0/0
[avisynth @ 0x7fae94000c80] stream 0: start_time: 0 duration: 41
[avisynth @ 0x7fae94000c80] stream 1: start_time: 0 duration: 242.86
[avisynth @ 0x7fae94000c80] format: start_time: 0 duration: 242.86 (estimate from stream) bitrate=0 kb/s
[avisynth @ 0x7fae94000c80] After avformat_find_stream_info() pos: 0 bytes read:1541 seeks:0 frames:3.....
...
... all the frames rendering...
...
Segmentation Fault



So what you meant by "STATIC build" is what I already have via main FFMPEG package (/usr/bin/ffmpeg & friends). But, I think, it is not static. It's just "complete" so to speak, not "minimal", like the guy I am building for FFMS2 to work. The idea was to build a minimal FFMPEG, just so that we can build FFMS2 manually. Can you please explain in more detail why we needed that, i.e. why the FFMS2 that comes with a distro would not work (i.e. causes deadlock)? Can it be made to work? What's needed for that?


Now back to segfault. I guess the problem is with the different versions of libs:

package ("complete") FFMPEG has:
libavutil 57. 17.100 / 57. 17.100
libavcodec 59. 18.100 / 59. 18.100
libavformat 59. 16.100 / 59. 16.100
libavdevice 59. 4.100 / 59. 4.100
libavfilter 8. 24.100 / 8. 24.100
libswscale 6. 4.100 / 6. 4.100
libswresample 4. 3.100 / 4. 3.100
libpostproc 56. 3.100 / 56. 3.100

manually built ("minimal") FFMPEG has:
libavutil 57. 27.100 / 57. 27.100
libavcodec 59. 35.100 / 59. 35.100
libavformat 59. 25.100 / 59. 25.100
libavfilter 8. 41.100 / 8. 41.100
libswscale 6. 6.100 / 6. 6.100
libswresample 4. 6.100 / 4. 6.100
libpostproc 56. 5.100 / 56. 5.100


Can you please take time to read the above. I really want to understand what's going on. Thank you, and I really appreciate you spending time on this!

Last edited by forgetfool; 3rd July 2022 at 14:13.
forgetfool is offline   Reply With Quote
Reply

Tags
linux

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 00:23.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, vBulletin Solutions Inc.