mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.02k stars 2.88k forks source link

CRASH = mpv + AVISynth(HDV video) #6235

Closed belonesox closed 1 year ago

belonesox commented 5 years ago

mpv version and platform

Tested on

Reproduction steps

Expected behavior

show video

Actual behavior

Crush! (with memory exhaustion)

Log file

output.txt

Sample files

mpv-bug-with-avisynth-and-hdv.zip 1sec video + trivial AVS script that leads mpv to crush.

mpv mpv-bug.avi — OK mpv mpv-bug.avs — Crush ffmpeg/ffplay on mpv-bug.avs — OK VirtualDub mpv-bug.avs — OK

qyot27 commented 5 years ago

I can't reproduce this, and not just because I don't have a VfW decoder for MPEG2-in-AVI (which is what HDV is). Not with my own builds of mpv, ffmpeg, AviSynth+, and FFMS2, but also with shinchiro's build of 0.29.0-66-g0f3e25cb0a.

I'd actually be willing to bet that the problem lies in the VfW decoder leaking, rather than any issue with mpv or AviSynth.

belonesox commented 5 years ago

But where is no problem, when open this mpv-bug.avs with VirtualDub, ffmpeg, ffplay.

image

Yes, decoding from HDV performed by ffdshow

image

I tried both libavcodec and libmpeg2 — mpv still crushed, VirtualDub/ffmpeg/fflplay still works.

qyot27 commented 5 years ago

ffdshow has not been updated in over 4 years, and even when it was being updated, toward the end it was not updated often and often had issues interacting with external programs.

And when using the latest available version of ffdshow-tryouts with my own builds of ffplay, the 64-bit version did indeed make AviSynth throw an Access Violation. And that is entirely ffdshow's fault. mpv did not crash when using either the 32-bit or 64-bit ffdshow through AviSynth, though the video output was green.

The real fix for this is to update your script pipeline. Use FFMS2 or LSMASHSource (both of which are still updated or at least reasonably up-to-date) for most formats, only fall back to AVISource for stuff like MJPEG, HuffYUV, etc.

belonesox commented 5 years ago

ffdshow has not been updated in over 4 years,

Not a problem until it works with old good AVISynth. The absense of 64bit AVISynth is the problem...

the 64-bit version did indeed make AviSynth throw an Access Violation.

There are no official AVISynth64 bit. So only 32bit versions of mpv, avisynth and ffdshow can be considered. My version of AVISynth 2.60

image

mpv did not crash when using either the 32-bit or 64-bit ffdshow through AviSynth

What version of ffdshow tryouts did you try? (I trIed 4531 and 4532 with no luck) What library (libavcodec of libmpeg2) selected in ffdshow config for HDV?

though the video output was green.

It is OK, first 60 frames can be green (try from 100th frame).

The real fix for this is to update your script pipeline. Use FFMS2 or LSMASHSource…

Actually, I use FFMS2 but I use it only to open non-avi containers (MTS, etc), and trying not use it for AVI files because it consumes more memory that dummy AVISource. In my workflow (hundreds of video files from tens sources) I use every possibility to climb under 4GB memory limit for 32bit ffmpeg/avisynth.

I missed born of LSMASHVideoSource but I just tried to use

clip = LSMASHVideoSource("mpv-bug.avi")                     

and got

[importer: Error]: failed to find the matched importer.
[avisynth @ 05097b60] LSMASHVideoSource [Fatal]: Failed to read an input file

Update: I tried LWLibavVideoSource it looks working for this. But still want to make working AVISource+ffdshow

Now I just want to know, why your "mpv+ffdshow+avisynth" not failing as in my case.

(In my case it still failed even

mpv.com --log-file=output.txt -vo=null -ao=null  bug-mpv.avs

)

belonesox commented 5 years ago

I reproduced the bug on another Clean Windows PC. Same crash.

https://datapacket.dl.sourceforge.net/project/avisynth2/AviSynth%202.6/AviSynth%202.6.0/AviSynth_260.exe + https://datapacket.dl.sourceforge.net/project/ffdshow-tryout/Official%20releases/generic%20build%20%28stable%29/ffdshow_rev4531_20140628.exe + mpv-i686-20181019-git-0f3e25c.7z ==> "mpv has stopped working"

I can provide access to this box using Team Viewver or something else.

belonesox commented 5 years ago

Same problem with DV video

  Duration: 00:01:56.05, start: 0.000000, bitrate: 30319 kb/s
    Stream #0:0: Video: dvvideo (dvsd / 0x64737664), yuv411p, 720x480 [SAR 8:9 DAR 4:3], 28779 kb/s, 29.97 fps, 29.97 tbr, 29.97 tbn
    Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 2 channels, s16, 1536 kb/s

and AVISource+ffdshow

Hrxn commented 5 years ago

Does it work with VapourSynth? Should be a good alternative to AviSynth.

qyot27 commented 5 years ago

There are no official AVISynth64 bit.

Yes, there is. AviSynth+ basically picked up where classic AviSynth left off the moment the fork happened in 2013. And official 64-bit support was one of the first things avsplus added. The de facto current development is taking place on pinterf's branch.

As Hrxn mentioned, VapourSynth is also an option.

Now I just want to know, why your "mpv+ffdshow+avisynth" not failing as in my case.

AviSynth+ having better memory management and cache improvements compared to Classic? Compilation differences in the FFmpeg libs (since I have no idea about the configuration of shinchiro's builds)?

avih commented 5 years ago

Well, there's at least one reason I'm aware of (which is possibly the only reason) to use 32 bits avisynth, and that's that the SVP plugin is 32 bits, and I think (didn't try) it won't work with 64 bits avisynth.

belonesox commented 5 years ago

Yes, there is. AviSynth+ basically picked up where classic AviSynth left off the moment the fork happened in 2013.

OK. I will try to move on from AVISynth classic to AviSynth+ (but right now I have to fast deliver video from a conference on my old stack, but I can wait to replace VirtualDub with MPV).

Now I have to use some legacy plugins (crop4slides.dll, GetSystemEnv.dll, Grid.dll, Rotate.dll, SmoothDeinterlacer.dll, TransAll.dll…), not sure they all ported to AVI+, some of these plugins lost their sources...

Now I just want to know, why your "mpv+ffdshow+avisynth" not failing as in my case.

@qyot27 Did I understand right that you have tested my "bad case" on AVISynth+, not AVISynth 2.60 32bit?

qyot27 commented 5 years ago

I tested on both. AVISource outputting green video but exiting at the end of playback without crashing occurred in both cases. That could mostly be a product of how the sample file was cut.

belonesox commented 5 years ago

If anyone else has AVISynth 2.60 32bit and ffdshow tryouts (see https://github.com/mpv-player/mpv/issues/6235#issuecomment-432584744 ) please, try to reproduce the bug.

belonesox commented 5 years ago

@qyot27 Can you please share your working windows/32 build of MPV?

qyot27 commented 5 years ago

http://www.mediafire.com/file/1g5r9t58g535tvw/mpv32.7z/file

That's the most recent, as I'm still in the process of rebuilding my cross environment from scratch.