-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
MPV error 'non monotonically increasing dts' when encoding a dynamically loaded playlist to output stream. #7524
Comments
The commands you send up until the crash and the files involved would probably help. You also forgot to attach the log file. |
The only commands I'm sending are to load the playlist and to observe a few properties. I was a bit tight for time last night and forgot the log. Here it is: I believe the culprit is this, my arch nemesis - the non-monotonically increasing DTS warning:
After that it crashes. However it doesn't crash if I load the playlist as a command line input with the --merge-files param. Edit 1: Also worth noting it doesn't crash if I exclude the --o param so I can see the GUI (which I've been doing all throughout testing...) Edit 2: Here are the files I'm using, but I'm sure you can probably use any 2 videos and encounter this error: https://drive.google.com/open?id=1hSKkhgd04UVHZeWZ-OW44Yp5g3NP2XTj |
No google drive. Does it actually crash, or just exit? |
Oh, nevermind, actually looking at the log shows:
That's a fatal error. It pretty much complains about timestamps going backwards, for whatever reasons. Normally, some code in there should compensate that in the normal case. Edit: performing some more tests with this:
And as a general comment: everything other than mpv pure playback handles format changes badly (including encoding mode), so you may need to awkwardly prevent this with video and audio filters, unless mpv somehow gets special support for that. |
I was just about to post your second point - Loading a new file during "playback" works. Considering that, there should be a simple workaround for this problem. I tried making this app with VLC originally and I had a similar problem, it couldn't handle the transition between videos. Rather than crash it just spewed out a load of DTS errors. The sound continued to play but the video froze. But when I piped VLC's output into an ffmpeg process, ffmpeg managed to sew the 2 streams together to create 1 seamless video. |
Can't tell without reproduction. There is no crash. |
Your last response doesn't make any sense to me. Sorry. |
Still haven't found a way around this. The fact it works if I load the playlist via the command line, or if I skip to the next playlist item, would indicate that a fix can be easily implemented. I would really appreciate if someone took a closer look at this issue. |
Like I said, needs reproduction/files. |
Earlier you said you'd been performing tests and confirmed the bug essentially:
and
But then you said:
Can you see why I'm a little confused? I assumed you'd re-produced the bug from your earlier post but then you appear to contradict yourself. The command I'm using is in the initial post, and after that just simply send a couple of commands to load 2 files into the playlist via the IPC interface (or any interface that doesn't trigger the GUI) I've posted video samples to test on, but you can use any video file to confirm this behaviour. |
https://en.wikipedia.org/wiki/Crash_(computing) |
I appreciate that you're trying to help but please be a little less cryptic in your responses. Here's a sample vid again: Or assuming zips aren't a problem for you: If you load it into the playlist twice via IPC and you should encounter the error at the end of the first item, supposing you're using --out |
Tried that, and I get two pigs as output. Maybe make a log with the pig. |
It's the same issue as before:
If I remove the audio track from the source video, start mpv with the same arguments and send the same commands, it doesn't error. |
You should try with a more recent mpv version then. Preferably git master. |
I'm using the latest release (20200315-git-281f5c6) and I still consistently get this error. |
I'm not getting it, with the exact command line from the first post (just added |
Let's simplify down it to the bare essentials then. I run this command:
Then I wait a moment for mpv to load, then:
I can only assume there's an inconsistency between your ffmpeg lib and mine. That said, I'm sure there must be a configurable ffmpeg option that can easily fix this. |
I've just tested the above code on a remote server running Ubuntu 16.04 (changed slightly so the commands execute correctly)... and it worked. This issue appears to be for Windows only. |
-- |
Just bumping this in the hope that someone with Windows could look into this. A simpler way to test this is to simply call:
Because the behaviour will be exactly the same as adding files dynamically through the playlist. On my remote Ubuntu server the command works perfectly, creating an output file with the 2 videos seamlessly joined. I recommend using the test file I uploaded last week, pig.mkv, as I've found it doesn't run into this error with some other video files I've tested. However, just to clarify, the video encoding is not corrupted or of an unusual standard. It's a standard mkv with h264 + aac tracks. I'm not sure why some work and some don't but I suspect it's to do with the completeness of the last segment of audio: It doesn't matter what version of mpv I use on Ubuntu or Windows, the behaviour of each remain the same. EDIT: This is the version I'm using on Windows: This is the version I'm using on Ubuntu: |
Do you have the ffmpeg git version number from when it worked? It's also possible that it's just some kind of race condition (though somewhat unlikely). |
I just managed to get it to work again on an earlier version.... much earlier in fact. |
That is decades old. |
I know. It's the version that I got when I ran 'apt-get install mpv', before adding a dedicated repo on Ubuntu 16.04. |
You can easily build it yourself. mpv-build may be helpful to try different ffmpeg versions. Requires you to use git etc. though. |
Rather than building mpv with an older version of ffmpeg (I assume that's what you mean) I'd rather configure mpv to not exit when it encounters 'non monotonically increasing dts'. |
That's a ffmpeg bug. (They'd rather abort than allowing us to write possibly, but not really, invalid timestamps.) |
I can't think why you aren't running into the same problem as me when you run the same command with (presumably) the latest build of mpv + ffmpeg. |
Actually I can reproduce it with that command line now, for whatever reason. |
Thanks! Hope you can find an effective solution to this problem. |
Seems to crash hard if an error happens somewhere at init. Who cares. Part of #7524.
????????????? Makes no sense, can endless loop, but whatever. Part of #7524.
It's probably fixed now, but I lost motivation somewhere along the way. Encoding mode is now deprecated. I suggest you find a better way to implement what you want, without mpv. |
Hm, possibly encoding mode could be salvaged by stepping around the old design, in a way that avoids the severe problems with it. Have to think about this. Encoding/muxing itself is a pretty simple thing. |
I went looking and all I found was VLC and mpv. I really appreciate the work you've put in, and I'd ask not to do away with the encoding mode just yet. Even if it is a bit quirky at times, it's very useful and I've not come across another video player that matches it. I'll try building mpv now to give it a whirl. |
vlc is in theory better, because it was designed to be a streaming server.
The original author of the encoding mode doesn't have time anymore, so what happens is open. |
I managed to compile a windows build using MSYS2.
EDIT: Just tried rewinding back to commit cdd6eb0 and those filters are working. EDIT2: #7555 |
I've reverted part on this on master, but on the other hand, audio timestamp handling should be significantly better now. Still very much alpha-quality code though. |
I still have this issue too with slightly 'bad' media files. Example of badly encoded media file: When checked with ffmpeg I get the following errors with said media file:
And when I try to encode this file in mpv it immediately quits and produces the following log: But the media file in question plays perfectly fine in mpv GUI mode. Can we make it so the encoder is a bit more robust when it comes to these sorts of minor errors? |
@hedgehog90 Did you ever solve this? Running into this issue as well when using the |
@frozenpandaman I wrote a fix on my fork that works for me. |
@hedgehog90 |
I wrote the 'fix' specific for my configuration, wouldn't recommend merging. |
Important Information
mpv 0.31.0-67-g63bf362d11
Windows 10
Reproduction steps
I want to use MPV to encode a dynamic playlist of items - that is, a playlist that can be altered during playback / encoding.
It important to make the point that I am not using the mpv command line to input my playlist or files. The playlist is generated dynamically after mpv is started, controlled by an IPC interface.
The input files are of all different shapes and size, different frame rates, etc.
With a set of video files, I can quite easily merge them into one seamless video stream using the mpv commandline, with the help of --merge-files and some filters to give them a consistent format.
However, if I insert those same files dynamically with IPC commands with the same set of filters and encoding options, I will all too often encounter a crash at the transition point between files.
Here's an example command for how I start MPV:
mpv --idle --msg-level=ipc=v --no-osc --keep-open=yes --merge-files --input-ipc-server=\\.\pipe\mpvserver --of=mpegts --ovc=libx264 --ovcopts=profile=main,preset=veryfast,level=4,crf=20,maxrate=5000k --vf=lavfi=[format=yuv420p,scale=(iw*sar)*min(1280/(iw*sar)\,720/ih):ih*min(1280/(iw*sar)\,720/ih),pad=1280:720:(1280-iw*min(1280/iw\,720/ih))/2:(720-ih*min(1280/iw\,720/ih))/2] --oac=aac --oacopts=ac=2,b=160k --o=out.ts
I hope there's a simple fix for this.
I've already spent countless hours writing a web-app and node server that allows me to control MPV remotely, and it's only in this last stage of testing that I've encountered this problem.
The text was updated successfully, but these errors were encountered: