Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

18.05.03 video import leads to crash #549

Closed
qubodup opened this issue May 5, 2018 · 18 comments
Closed

18.05.03 video import leads to crash #549

qubodup opened this issue May 5, 2018 · 18 comments

Comments

@qubodup
Copy link

qubodup commented May 5, 2018

Blank Shotcut 18.05.03 crashes when a video (h264 mp4) gets dragged into the source monitor (default view).

image
shotcut.exe has stopped working
A problem caused the program to stop working correctly. Please close the program.
Close the program
Debug the program

This stopped happening at some point, I think it was related to me selecting a video profile.

Edit: Workaround is to drag in a jpg image into the source view, after that, it so far never crashed when I added a video.

It can be reproduced by deleting HKEY_CURRENT_USER\SOFTWARE\Meltytech and C:\Users[username]\AppData\Local\Meltytech and then starting Shotcut 18.05.03 and dragging a video into the source monitor.

Not sure whether the command line output (win64) is useful:

[Debug  ] <MainWindow::open> "C:/Cache/x.MP4"
[Debug  ] <MltXmlChecker::MltXmlChecker> decimal point '.'
[Debug  ] <MltXmlChecker::check> begin
[Debug  ] <MltXmlChecker::check> end
[h264 @ 000000000822cfc0] Reinit context to 1920x1088, pix_fmt: yuv420p
[h264 @ 000000000822f640] Reinit context to 1920x1088, pix_fmt: yuv420p
[h264 @ 00000000134124c0] Reinit context to 1920x1088, pix_fmt: yuv420p
[Debug  ] <MLT> [producer avformat] audio: total_streams 1 max_stream 1 total_channels 2 max_channels 2
[h264 @ 000000000822cfc0] Reinit context to 1920x1088, pix_fmt: yuv420p
[h264 @ 000000000822f640] Reinit context to 1920x1088, pix_fmt: yuv420p
[h264 @ 0000000013778520] Reinit context to 1920x1088, pix_fmt: yuv420p
[Debug  ] <MLT> [producer avformat] "C:/Cache/x.MP4" checking VFR: pkt.duration %I64d
[h264 @ 000000001377c880] Reinit context to 1920x1088, pix_fmt: yuv420p
[Debug  ] <MainWindow::setAudioChannels> 2
[Debug  ] <Mlt::Controller::setAudioChannels> 2
[Info   ] <MLT> [filter swresample] 2(stereo) s16 48000Hz -> 0(independent) s16 0Hz

@ddennedy
Copy link
Member

ddennedy commented May 6, 2018

I have not been able to reproduce this. After you clear all settings and app data and start shotcut, do you do anything before dropping a video clip from, I assume, Explorer?

@qubodup
Copy link
Author

qubodup commented May 6, 2018

Yes, I drop the file from windows explorer.

Interesting: it does not crash if I drop it from the same partition in which shotcut is.

If I drop it from another partition however, it crashes.

(Shotcut is on D:)

@ddennedy
Copy link
Member

ddennedy commented May 6, 2018

I tested with clips on C:, D:, and E: where Shotcut is on C:. Do you know if there is a workaround? I will do some tests while running in a debugger next. Sometimes, that exposes a crash that normal running does not.

@qubodup
Copy link
Author

qubodup commented May 6, 2018

Moving Shotcut to C:\Shotcut reduced the occurrence a little. It seems to affect .mp4 (from internet or rendered on pc) videos more than .mov videos (recorded at 30fps with obs). Thinking the location has an effect might be complete nonsense though. The file format observations might be nonsense as well. File size seems to not be a factor. Some 1 MB files crash, some 1GB files open without problem and vice versa.

I arranged the following: shotcut.exe is in C:\Shotcut\ , all taken from the 18.05.03 zip.

I put this https://mega.nz/#!zWBz1IpD!oKlaEas5scLv1GW1rmYYE_ZyIRZ7b2tgXvum-k_fa5o 1.2MB video also into C:\Shotcut\

It does crash when I drag it in (output below). Using "Open File" has same effect.

[Debug  ] <MainWindow::open> "C:/Shotcut/smallbunnies.mp4"
[Debug  ] <MltXmlChecker::MltXmlChecker> decimal point '.'
[Debug  ] <MltXmlChecker::check> begin
[Debug  ] <MltXmlChecker::check> end
[h264 @ 0000000012e7a540] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 0000000012e7cda0] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 0000000012ef4aa0] Reinit context to 480x256, pix_fmt: yuv420p
[Debug  ] <MLT> [producer avformat] audio: total_streams 1 max_stream 1 total_channels 2 max_channels 2
[h264 @ 000000000945cfc0] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 000000000945c620] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 0000000012ec9b00] Reinit context to 480x256, pix_fmt: yuv420p
[Debug  ] <MLT> [producer avformat] "C:/Shotcut/smallbunnies.mp4" checking VFR: pkt.duration %I64d
[h264 @ 0000000012ec87c0] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 000000000945eca0] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 000000000945c620] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 000000001308cec0] Reinit context to 480x256, pix_fmt: yuv420p
[Debug  ] <MLT> [producer avformat] audio: total_streams 1 max_stream 1 total_channels 2 max_channels 2
[Debug  ] <MainWindow::setAudioChannels> 2
[Debug  ] <Mlt::Controller::setAudioChannels> 2
[h264 @ 000000000945f640] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 00000000135a1d40] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 00000000135a8c00] Reinit context to 480x256, pix_fmt: yuv420p
[Debug  ] <MLT> [producer avformat-novalidate] "C:/Shotcut/smallbunnies.mp4" checking VFR: pkt.duration %I64d
[Info   ] <MLT> [filter swresample] 2(stereo) s16 48000Hz -> 0(independent) s16 0Hz

Could it be the
[Debug ] [producer avformat-novalidate] "C:/Shotcut/smallbunnies.mp4" checking VFR: pkt.duration %I64d
part? Seems like some variable name was read literally perhaps (%l64d).

The most important part to reproduce this (and see what first-time users see) seems to be not to change settings. For example changing video mode might have made the issue go away.

PS: workaround (sorry, forgot to mention) has been for me so far to drag in a jpg image into the source view, after that it so far always didn't crash when I added a video.

Hm. This begins to make sense, if setting the format/profile solves the issue and first adding an image solves the issue, then the culprit is probably the automatic resolution/framerate/etc/format identification system.

PPS: importing clips testing probably only works if it is the first thing imported, so shotcut needs to be restarted before each clip tested.

@bmatherly
Copy link
Member

This should not be possible:

[Info ] [filter swresample] 2(stereo) s16 48000Hz -> 0(independent) s16 0Hz

I can't even imagine how the consumer could request zero channels. Maybe the root problem, or maybe an unrelated side effect of the root problem.

@qubodup
Copy link
Author

qubodup commented May 6, 2018

In relation to @bmatherly here is the command line output if I first import a 1920x1080 jpg image and after that import the video that would cause the crash:

I import the photo:

[Debug  ] <MainWindow::open> "C:/Cache/Subscribe!/Image Slide 6 Lion.jpg"
[Debug  ] <MltXmlChecker::MltXmlChecker> decimal point '.'
[Debug  ] <MltXmlChecker::check> begin
[Debug  ] <MltXmlChecker::check> end
[Debug  ] <MainWindow::setAudioChannels> 2
[Debug  ] <Mlt::Controller::setAudioChannels> 2
[Info   ] <MLT> Failed to open audio device: XAudio2: XAudio2Create() failed at open.
[Info   ] <MainWindow::open> "C:/Cache/Subscribe!/Image Slide 6 Lion.jpg"
[Info   ] <MLT> [sdl2] Try alternative driver: xaudio2
[Info   ] <MLT> [consumer sdl2_audio] Audio Opened: driver=xaudio2 channels=2 frequency=48000

I import the video:

[Debug  ] <MainWindow::open> "C:/Shotcut/smallbunnies.mp4"
[Debug  ] <MltXmlChecker::MltXmlChecker> decimal point '.'
[Debug  ] <MltXmlChecker::check> begin
[Debug  ] <MltXmlChecker::check> end
[h264 @ 000000001358ea40] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 00000000134a5ac0] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 0000000013368160] Reinit context to 480x256, pix_fmt: yuv420p
[Debug  ] <MLT> [producer avformat] audio: total_streams 1 max_stream 1 total_channels 2 max_channels 2
[h264 @ 00000000099b44e0] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 00000000099b5340] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 000000001369acc0] Reinit context to 480x256, pix_fmt: yuv420p
[Debug  ] <MLT> [producer avformat] "C:/Shotcut/smallbunnies.mp4" checking VFR: pkt.duration %I64d
[h264 @ 000000001369dce0] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 00000000099b5340] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 00000000099b5ce0] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 00000000136c4f80] Reinit context to 480x256, pix_fmt: yuv420p
[Debug  ] <MLT> [producer avformat] audio: total_streams 1 max_stream 1 total_channels 2 max_channels 2
[Debug  ] <MainWindow::setAudioChannels> 2
[Debug  ] <Mlt::Controller::setAudioChannels> 2
[h264 @ 00000000099b6680] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 00000000135690a0] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 00000000135678a0] Reinit context to 480x256, pix_fmt: yuv420p
[Debug  ] <MLT> [producer avformat-novalidate] "C:/Shotcut/smallbunnies.mp4" checking VFR: pkt.duration %I64d
[h264 @ 0000000013569f20] Reinit context to 480x256, pix_fmt: yuv420p
[Info   ] <MLT> Failed to open audio device: XAudio2: XAudio2Create() failed at open.
[Info   ] <MainWindow::open> "C:/Shotcut/smallbunnies.mp4"
[Info   ] <MLT> [sdl2] Try alternative driver: xaudio2
[Info   ] <MLT> [consumer sdl2_audio] Audio Opened: driver=xaudio2 channels=2 frequency=48000

@ddennedy
Copy link
Member

ddennedy commented May 7, 2018

workaround (sorry, forgot to mention) has been for me so far to drag in a jpg image into the source

If you do not add this to the Playlist or Timeline, then Shotcut does not determine the video mode from Automatic. Automatic resolution occurs when adding the first item to either of those.

@qubodup
Copy link
Author

qubodup commented May 7, 2018

If you do not add this to the Playlist or Timeline, then Shotcut does not determine the video mode from Automatic. Automatic resolution occurs when adding the first item to either of those.

In the beginning of the bug hitting me, I assumed I have to drag the image to the timeline first for the workaround to work. I just tested a few more times, including clearing registry and AppData again. It works if I drag the image into shotcut and then drag the video into shotcut without any timeline interaction first.

Here's a video of the crashing. https://youtu.be/3iIy_09i_VI

Some more tests:

If GPU is enabled, the crash doesn't happen. Turning GPU off leads to the crashes happening again.

Setting the video mode to 1080p30fps before importing does not fix it.

Disabling Realtime (frame dropping) seems to solve it. Enabling it back again makes it crash again on import.

OpenGL/DirectX display mode changing has no effect (crashes on import either way).

@WASCHMASCHINE
Copy link

@qubodup Thanks for the workaround. Just tried ShortCut for the first time and was stumped...

@qubodup
Copy link
Author

qubodup commented May 7, 2018

@WASCHMASCHINE glad to hear this thread helped. I updated the first post so googlers can be helped quicker.

I just realized that I apparently can debug programs because I have VS2017 installed. Here's what it tells me:

image
Unhandled exception at 0x00007FFBE3C7749F (swresample-2.dll) in shotcut.exe: 0xC0000094: Integer division by zero. occurred

@ddennedy
Copy link
Member

ddennedy commented May 7, 2018

The divide by zero error is most likely because of the 0 channels and 0Hz log message @bmatherly mentioned. You cannot use stock Visual Studio for debugging because Shotcut uses gcc and the mingw runtime and not msvcrt. You need to install something like VisualGDB or follow this article. I use Qt Creator and its debugger. However, I tested several times today in the (very slow) debugger with different clips, and I still did not reproduce it. At this point I am reviewing code to develop a hypothesis for the cause, which currently smells like a race condition around some initialization somewhere.

@ddennedy
Copy link
Member

ddennedy commented May 7, 2018

I found the bug in MLT. On a machine with more than 2 cores, it is directly related to the Realtime setting in Shotcut. It may affect more than Windows, but less likely. It is difficult for me to test a fix. So, after tonight's nightly build, I will post a link of a new build to test.

@bmatherly take a look at https://github.com/mltframework/mlt/blob/master/src/framework/mlt_consumer.c#L599

priv->channels, and frequency are not set until after start is called. Look a little above that, and you can see consumer_read_ahead_start() is called on the main thread on Windows. consumer_read_ahead_start() calls mlt_frame_get_audio(), which might have unset channels and frequency in consumer_private.

@vpinon
Copy link

vpinon commented May 7, 2018

swresample div by 0 was occurring at every start of Kdenlive 18.04.0 trial builds for Windows. The only workaround I found (yesterday night) was to comment the filter out in loader.ini...
Thanks for the fix!!

@ddennedy
Copy link
Member

ddennedy commented May 8, 2018

Please test this: http://builds.us.meltytech.s3.amazonaws.com/shotcut/shotcut-win64-180508.zip

@qubodup
Copy link
Author

qubodup commented May 8, 2018

No more crashes, thanks!

[Debug  ] <MainWindow::open> "C:/Shotcut/smallbunnies.mp4"
[Debug  ] <MltXmlChecker::MltXmlChecker> decimal point '.'
[Debug  ] <MltXmlChecker::check> begin
[Debug  ] <MltXmlChecker::check> end
[h264 @ 0000000009441340] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 000000000943f660] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 00000000097152e0] Reinit context to 480x256, pix_fmt: yuv420p
[Debug  ] <MLT> [producer avformat] audio: total_streams 1 max_stream 1 total_channels 2 max_channels 2
[Debug  ] <MainWindow::setAudioChannels> 1
[Debug  ] <Mlt::Controller::setAudioChannels> 1
[h264 @ 00000000094421a0] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 000000000943f660] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 000000001b806620] Reinit context to 480x256, pix_fmt: yuv420p
[Debug  ] <MLT> [producer avformat-novalidate] "C:/Shotcut/smallbunnies.mp4" checking VFR: pkt.duration %I64d
[Info   ] <MLT> [filter swresample] 2(stereo) s16 48000Hz -> 1(mono) s16 48000Hz
[h264 @ 000000001b806ae0] Reinit context to 480x256, pix_fmt: yuv420p
[Info   ] <MLT> Failed to open audio device: XAudio2: XAudio2Create() failed at open.
[Info   ] <MainWindow::open> "C:/Shotcut/smallbunnies.mp4"
[Info   ] <MLT> [sdl2] Try alternative driver: xaudio2
[Info   ] <MLT> [consumer sdl2_audio] Audio Opened: driver=xaudio2 channels=1 frequency=48000

@ddennedy
Copy link
Member

ddennedy commented May 8, 2018

MainWindow::setAudioChannels 1

It seems you did not clear your settings or left it set for mono.

@qubodup
Copy link
Author

qubodup commented May 8, 2018

You're right, I left it in the state after yesterday's testing, where it still would crash. Cleared the settings and confirmed that new version doesn't crash any more with multiple videos (smallbunnies.mp4 output below), cleared settings again, confirmed 180503 still crashes with smallbunnies.mp4 just to make sure.

[Debug  ] <MainWindow::open> "C:/Shotcut/smallbunnies.mp4"
[Debug  ] <MltXmlChecker::MltXmlChecker> decimal point '.'
[Debug  ] <MltXmlChecker::check> begin
[Debug  ] <MltXmlChecker::check> end
[h264 @ 0000000013828280] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 0000000013863980] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 00000000138576c0] Reinit context to 480x256, pix_fmt: yuv420p
[Debug  ] <MLT> [producer avformat] audio: total_streams 1 max_stream 1 total_ch                                                                     annels 2 max_channels 2
[h264 @ 000000001383eca0] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 00000000138ac220] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 0000000013868a40] Reinit context to 480x256, pix_fmt: yuv420p
[Debug  ] <MLT> [producer avformat] "C:/Shotcut/smallbunnies.mp4" checking VFR:                                                                      pkt.duration %I64d
[h264 @ 00000000138a7740] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 00000000138b0a40] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 0000000013837480] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 0000000013ac6ba0] Reinit context to 480x256, pix_fmt: yuv420p
[Debug  ] <MLT> [producer avformat] audio: total_streams 1 max_stream 1 total_ch                                                                     annels 2 max_channels 2
[Debug  ] <MainWindow::setAudioChannels> 2
[Debug  ] <Mlt::Controller::setAudioChannels> 2
[h264 @ 0000000013837a80] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 0000000013a1a1e0] Reinit context to 480x256, pix_fmt: yuv420p
[h264 @ 0000000013a0fba0] Reinit context to 480x256, pix_fmt: yuv420p
[Debug  ] <MLT> [producer avformat-novalidate] "C:/Shotcut/smallbunnies.mp4" che                                                                     cking VFR: pkt.duration %I64d
[h264 @ 0000000013a428c0] Reinit context to 480x256, pix_fmt: yuv420p
[Info   ] <MLT> Failed to open audio device: XAudio2: XAudio2Create() failed at                                                                      open.
[Info   ] <MainWindow::open> "C:/Shotcut/smallbunnies.mp4"
[Info   ] <MLT> [sdl2] Try alternative driver: xaudio2
[Info   ] <MLT> [consumer sdl2_audio] Audio Opened: driver=xaudio2 channels=2 fr                                                                     equency=48000

@ddennedy
Copy link
Member

ddennedy commented May 8, 2018

Excellent. There are also many fixes for the fade in/out filters. I feel 18.05 may deserve a re-release.

@ddennedy ddennedy modified the milestones: v18.06, v18.05 May 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants