unosquare / ffmediaelement

FFME: The Advanced WPF MediaElement (based on FFmpeg)
https://unosquare.github.io/ffmediaelement/
Other
1.17k stars 240 forks source link

Crash when open some files #503

Closed dimskor closed 3 years ago

dimskor commented 4 years ago

A crash occurs when opening some files with MedieElement. No errors in logs or exceptions With ffplay it opens fine Attached one of the files for example

UPD. Most likely, this is due to the non-standard height and width of the video. In my case, it is 1278x720

Issue Categories

Version Information

Sample Code

XAML

<MainWindow>
    <ffme:MediaElement Name="Player" MinWidth="800" MinHeight="450" LoadedBehavior="Manual" UnloadedBehavior="Manual" />
</MainWindow>

C

Player.MessageLogged += (o, args) =>
{
    if (args == null) return;
    Console.WriteLine($"{args.MessageType} | {args.Message}");
};
Player.Loaded += async (sender, args) =>
{
    await Player.Open(new Uri(@"C:\OUTPUT.mp4"));
};

OUTPUT.zip

namcigar commented 4 years ago

You can view this project example at this file

Look for OpenCommand command and use it.

Ex:

var uriString = a as string;
if (string.IsNullOrWhiteSpace(uriString))
    return;

var target = new Uri(uriString);
var m = Player; // your player
var target = new Uri(uriString);
if (target.ToString().StartsWith(FileInputStream.Scheme, StringComparison.OrdinalIgnoreCase))
    await m.Open(new FileInputStream(target.LocalPath));
else
    await m.Open(target);

Remember to take this file's source code from this project example too :)

dimskor commented 4 years ago

The problem occurs when opening a some file with a non-standard size (1278x720, 854x480). I also tried to open this files in a sample project, it also crashes.

namcigar commented 4 years ago

You should view this pull request, maybe it's the problem: https://github.com/unosquare/ffmediaelement/pull/493

MrRickwi commented 4 years ago

The crash occurs for certain files, and it can be seen in the Windows Event Log:

Name der fehlerhaften Anwendung: ffmeplay.win.exe, Version: 4.2.340.0, Zeitstempel: 0x5ec598f1 Name des fehlerhaften Moduls: swscale-5.dll, Version: 5.6.101.0, Zeitstempel: 0x00000000 Ausnahmecode: 0xc0000005 Fehleroffset: 0x0000000000067e09 ID des fehlerhaften Prozesses: 0x5560 Startzeit der fehlerhaften Anwendung: 0x01d63f2fbff2bac2 Pfad der fehlerhaften Anwendung: C:\Sources\Internet\FFMediaElement\Unosquare.FFME.Windows.Sample\bin\Debug\netcoreapp3.1\ffmeplay.win.exe Pfad des fehlerhaften Moduls: C:\Sources\Internet\FFMediaElement\Unosquare.FFME.Windows.Sample\bin\Debug\netcoreapp3.1\x64\swscale-5.dll Berichtskennung: 7d1fdc04-6c99-41ca-839b-175642e5c42a Vollständiger Name des fehlerhaften Pakets: Anwendungs-ID, die relativ zum fehlerhaften Paket ist:

With this information (crash inside swscale-5.dll) it can be pinpointed to the following call in VideoComponent.cs:

// The scaling is done here var outputHeight = ffmpeg.sws_scale( Scaler, source.Pointer->data, source.Pointer->linesize, 0, source.Pointer->height, targetScan, targetStride);

Up to now I was unable to see what the problem is.

The pull request mentioned above seems to be correct, but the properties fixed in that pull request are never used, so it does not fix the problem.

In my test, the file has following properties as listed by ffplay:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users*****\Desktop\Videos\Interstellar-TLR_1b-5.1ch-4K-HDTN.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf54.63.104 Duration: 00:01:40.17, start: 0.000000, bitrate: 30058 kb/s Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv), 4096x1716 [SAR 1:1 DAR 1024:429], 29417 kb/s, 24 fps, 24 tbr, 16k tbn, 48 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(eng): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side), fltp, 640 kb/s (default) Metadata: handler_name : SoundHandler Side data: audio service type: main 12.57 A-V: -0.035 fd= 1 aq= 119KB vq= 3521KB sq= 0B f=0/0

MrRickwi commented 4 years ago

Could you please include this in the 3.40 milestone?

Th3K1pp3r commented 4 years ago

Whilst not the solution, I came up with a minor modification to the calling client that allows badly sized videos to play. In the Sample app > MediaRendering > OnMediaOpening there is a line that checks for 'videoStream.PixelHeight' > 1080. When this condition is true a line is appended to the videoFilter 'videoFilter.Append("scale=-1:1080,")'. Parse the videoStream height and width and regularize the values to known video sizes (718, 576 becomes 720,576) and append a line to the videoFilter 'videoFilter.Append("scale=720:576")'. The video now plays as expected.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.