AviSynth / AviSynthPlus

AviSynth with improvements
http://avs-plus.net
935 stars 73 forks source link

ffms2 decoding plugin conflicts with ffmpeg shared encoder (Linux) #194

Open ghost opened 3 years ago

ghost commented 3 years ago

ffms2 linking with ffmpeg 4 shared libs. Export to ffmpeg 4.3.1 (for encoding) only works fine if ffmpeg is static (compiled with avisynth support, of course). If ffmpeg is shared, nothing happens in the terminal - a white window. I think this is because of the recursion.

I personally have no problem using ffmpeg static for export. But, for example, Arch Linux repository has avisynthplus, ffmpeg shared (with --enable-avisynth --enable-shared) and ffms2 (with --enable-avisynth). Most likely, this bundle is not working there. I can't check. I am using Ubuntu 16.04 (GCC 10), ffmpeg 4.3.1.

Let me remind that shared differs from static in that shared has 8 libav libs, and static contains them inside the ffmpeg bin. By the way, internal scripts (like Colorbars) work fine in ffmpeg shared. The problem is ffms2.

ghost commented 3 years ago

L-SMASH does work with ffmpeg shared. However, with ffmpeg shared it doesn't show progress. Except ffmpeg -progress pipe:1 With ffmpeg static, there is progress. Build instructions https://pastebin.com/raw/P9R1JiwM

qyot27 commented 3 years ago

I can't reproduce this on Ubuntu 20.04. Built a fresh FFmpeg from the release/4.3 branch with --enable-shared, linked FFMS2 against it, and then tried to use said ffplay to play back the test script using FFMS2. It played fine.

The odd behavior of shared!FFmpeg not showing any file info or progress is there, but it does encode from the script to the output without issue (although it seemed partially dependent on what the output file was configured to encode to). Dumping to a log with -report will show that, although -loglevel doesn't want to show anything unless you set it up to trace, and even then it only shows the probing section.

FFmpeg:

git clone git://source.ffmpeg.org && \
cd ffmpeg && \
git checkout release/4.3 && \
    PKG_CONFIG_PATH=/usr/local/lib/pkgconfig \
    ./configure --enable-gpl --enable-version3 --enable-pic \
    --disable-doc --enable-shared \
    --enable-opengl --enable-libaom --enable-libdav1d \
    --enable-libmp3lame --enable-libopus --enable-libtwolame \
    --enable-libvorbis --enable-libx264 \
    --enable-libxvid --enable-avisynth --cpu=silvermont \
    --extra-cflags="-mfpmath=sse -march=native" \
    --pkg-config-flags="--static" && \
make -j$(nproc) && \
    sudo checkinstall --pkgname=ffmpeg --pkgversion="7:$(git rev-list \
    --count HEAD)-g$(git rev-parse --short HEAD)" --backup=no --deldoc=yes \
    --delspec=yes --deldesc=yes --strip=yes --stripso=yes --addso=yes \
    --fstrans=no --default

FFMS2:

git clone git://github.com/FFMS/ffms2.git && \
cd ffms2 && \
./autogen.sh && \
CPPFLAGS="-I/usr/local/include/avisynth" ./configure --enable-avisynth --with-pic && \
make -j$(nproc) && \
    sudo checkinstall --pkgname=ffms2 --pkgversion="1:$(./version.sh)-git" --backup=no \
    --deldoc=yes --delspec=yes --deldesc=yes --strip=yes --stripso=yes --addso=yes \
    --fstrans=no --default
[symlink ffms2 into avisynth autoload subdirectory]

Script:

#Version()
FFmpegSource2("test.mkv",atrack=-1)
#ConvertToPlanarRGB().ConvertToFloat().AddAlphaPlane()
ghost commented 3 years ago

I'll check your config. My: --enable-pic --enable-gpl --enable-version3 --enable-nonfree --enable-shared --disable-static --disable-debug --disable-doc --enable-avisynth --enable-frei0r --enable-gcrypt --enable-gmp --enable-gnutls --enable-gray --enable-libdav1d --enable-librav1e --enable-libaom --enable-libass --enable-ladspa --enable-libbluray --enable-libcdio --enable-libdc1394 --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-libopus --enable-libpulse --enable-librubberband --enable-libvidstab --enable-librtmp --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libxml2 --enable-libzimg --enable-libzvbi --enable-vapoursynth --enable-openal

git clone git://github.com/ffms/ffms2.git
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig CPPFLAGS="-I/usr/local/include/avisynth" ./autogen.sh --enable-shared --enable-avisynth
make
sudo make install

I have explicitly specified --disable-static. It looks like there is also hybrid build where shared and static are enabled (by default).

The odd behavior of shared!FFmpeg not showing any file info or progress is there

I also observed similar behavior in vapoursynth in ffmpeg shared. But it worked.

ghost commented 3 years ago

Linux mpv can open avisynth scripts with sound.

video = LWLibavVideoSource("input.mkv")
audio = LWLibavAudioSource("input.mkv", cache=false)
AudioDub(video, audio)
TDecimate(cycleR=1, cycle=6)

mpv input.avs

TDecimate allows to make fps correction while watching the video.

But most likely, if mpv is built with ffmpeg 4.3.1, which is built with avisynth support. The ffmpeg libraries are responsible for avs decoding. There is no mention of avisynth in configure mpv.

ghost commented 3 years ago

https://trac.ffmpeg.org/ticket/9059