Avidemux 2.7.9 210731 audio and video won't stay in sync

Started by Who, August 28, 2021, 12:03:35 AM

Previous topic - Next topic

Who

A couple of nights ago I upgraded to the latest nightly that is available (Avidemux 2.7.9 210731-16h25m_01a36b3ace1.dmg - still wish there were a newer one) and after that I found that when playing a video in Avidemux's window, the audio and video quickly get out of sync and stay that way.  This did not happen in previous versions - I wont say there were never occasions where the audio and video got a little out of sync, but in this case the difference between the audio and video get progressively worse the more you allow to play.  Stopping the playback and starting again puts the audio back in sync but it doesn't stay that way more than a fraction of a second.  This makes it difficult to locate cutpoints, particularly when you are listening for some particular snippet of audio.  I have tried setting the video display preference as both Qt and OpenGL, the problem occurs in Qt (apparently the default setting) but not in OpenGL, but playback in OpenGL is very jumpy (edit: also, I had forgotten about the issue of Avidemux crashing right after finishing an encode, which occurs when OpenGL is used).  This did not occur in Avidemux 2.7.9 210327-18h09m_31ad3e68980.dmg which is the previous version I was running.

Another minor issue is that Avidemux's window comes up much larger than it used to and I cannot find any way to resize it to a slightly smaller size and have that persist between sessions.

szlldm

This desynchronizations happens, when the video decoder can not keep up with the desired frame rate. The OpenGL output works, because it offloads the displaying from the CPU, so more resource left for decoding. The Qt output use CPU resources to display the video.

eumagga0x2a

Please provide information about the properties of the videos which are too demanding to be played in sync on your system.

To reduce CPU load, you might try to hide the VU meter widget, it is an awful resource hog.

Quote from: Who on August 28, 2021, 12:03:35 AMthe problem occurs in Qt (apparently the default setting) but not in OpenGL

On macOS, OpenGL output is the default.

Quote from: Who on August 28, 2021, 12:03:35 AMbut playback in OpenGL is very jumpy

Could you please elaborate?

Quote from: Who on August 28, 2021, 12:03:35 AMAnother minor issue is that Avidemux's window comes up much larger than it used to

Does this apply to the empty window shown upon application launch? Is the display in macOS settings configured to use scaling like when fonts at the native resolution would appear too small to read comfortably?

Who

Quote from: eumagga0x2a on August 28, 2021, 10:03:35 AMPlease provide information about the properties of the videos which are too demanding to be played in sync on your system.

To reduce CPU load, you might try to hide the VU meter widget, it is an awful resource hog.

So far it's been every video; all I can say for now (since I don't have another one ready at the moment) is they are usually .ts files, if that makes any difference, and often they are rather large.  And using OpenGL, Avidemux has crashed after saving the file, twice now.

I'll try hiding that VU meter widget and see if that makes a difference, next time I have a file to encode. (edit: I just went back and checked a file I did yesterday and with the VU meter not displayed, the OpenGL playback does seem much smoother.  However, it does not affect the loss of audio/video sync when using Qt).

Quote from: eumagga0x2a on August 28, 2021, 10:03:35 AM
Quote from: Who on August 28, 2021, 12:03:35 AMthe problem occurs in Qt (apparently the default setting) but not in OpenGL

On macOS, OpenGL output is the default.

Sorry, I had forgotten that a few versions back you told me to try Qt as a way to avoid the crashes that occur when the video is finished encoding.  Just to be clear, by "crashes" I mean that Avidemux just quits (fortunately AFTER saving the encoded file) and then MacOS pops up a box telling me that it closed unexpectedly.  So Qt has been the default on my system for a while now, but as you said OpenGL is the default.

Quote from: eumagga0x2a on August 28, 2021, 10:03:35 AM
Quote from: Who on August 28, 2021, 12:03:35 AMbut playback in OpenGL is very jumpy

Could you please elaborate?

All I mean by that is that in OpenGL it seems like a lot more frames are dropped and there is more hesitation in the video.  This is not a huge issue because I don't typically use Avidemux as a video player, but I was just commenting that it happens more in OpenGL than in Qt.  As you have probably guessed, my system isn't the most powerful, it is a 2014 Mac Mini (actually purchased in 2017 because Apple had not released any new models and my old computer had just died).  But with Qt the video playback was pretty smooth, and in previous versions of Avidemux the video and audio were not out of sync.  Something has changed in the 2.7.9 210731 version but I don't know what.

Quote from: eumagga0x2a on August 28, 2021, 10:03:35 AM
Quote from: Who on August 28, 2021, 12:03:35 AMAnother minor issue is that Avidemux's window comes up much larger than it used to

Does this apply to the empty window shown upon application launch? Is the display in macOS settings configured to use scaling like when fonts at the native resolution would appear too small to read comfortably?

No, the empty window shows up at normal size, it is only after loading the video that the size increases.  And no, the resolution is set to "Default for display", not "Scaled" if that is what you are talking about (and if it's not, I know I have never changed any setting related to scaling). Again, this is something that did not happen in the previous version of Avidemux that I was running (2.7.9 210327) - something changed in the 2.7.9 210731 nightly that causes this to happen.

EDIT: I just noticed that setting "Zoom 1:2" under the view menu brings back the window the way I have been used to seeing it, more or less.  I wonder if it came up using "Fit to window" after the upgrade.  And in that view, setting it to Qt does not seem to cause loss of A/V sync (at least on the video I'm running the tests on).  So this may have been an issue in previous versions that I would never have noticed because I never used "Fit to window".

eumagga0x2a

Quote from: Who on August 28, 2021, 02:02:19 PMSo far it's been every video; all I can say for now (since I don't have another one ready at the moment) is they are usually .ts files, if that makes any difference

This indeed make a difference as the MpegTS demuxer in the build you have installed produces an incredible amount of debug messages (more precisely, every query of video duration produces three or four messages, but this function is used on some occasions very frequently, unintentionally resulting in a tremendous number of log file writes). You would greatly benefit from using a build off the current code, if it were available.

And please, please provide the information you are asked to provide. It is not just for fun.

QuoteAnd using OpenGL, Avidemux has crashed after saving the file, twice now.

Please provide its last words when running it from the Terminal as it doesn't look to be difficult to trigger the crash.

Quote(edit: I just went back and checked a file I did yesterday and with the VU meter not displayed, the OpenGL playback does seem much smoother.  However, it does not affect the loss of audio/video sync when using Qt).

From your finding that zoom level is responsible for system load which ultimately results in loss of sync, it is scaling on the CPU instead of on GPU due to usage of unaccelerated (but safe) Qt display.

Quotethe empty window shows up at normal size, it is only after loading the video that the size increases.

I see, this was indeed changed on purpose. Now Avidemux tries to use the highest zoom level without upscaling which would fit into the available space, not a fixed fractional level like 1:2 or 1:4.

Who

I would love to run a build of the current code, but as you know it is not available for MacOS.  From what you are telling me, I think I should drop back to the previous build until a new MacOS build is released.  I don't want Avidemux killing my SSD.  Maybe I should ask, is there any way to black hole all those debug messages?

I sent you a PM with the mediainfo output of a typical file.

Regarding the crashing, I thought I'd sent you that info before, and that's when you told me to try using Qt.  I don't remember how you run Avidemux from a terminal in MacOS (unless it is just typing in the application name) but in any case I don't have time to do that right now, so I'll have to do it later.

Could you please provide an option to make it NOT try to use the highest zoom level without upscaling which would fit into the available space?  Or at least so that if you set it to use a fractional level it will honor that when you press the play button, and not just take it upon itself to take over the whole display?  And also, if you select a fractional level, could you allow that to persist between sessions?

I am sure that change might be seen as a benefit to some people (mainly people with very fast systems) but you are making it hard for amateurs that don't have the very latest equipment.  The problem with Avidemux is that you keep making improvements which are often beneficial, but it also seems like sometimes new versions bring new frustrations.  I still don't like those segmented numbers in the running time display that were introduced a few versions back.  Things would be great if you also had options to keep the old behavior in cases like that, rather than assuming that everyone will want the new behavior.  And I think this new problem illustrates why sometimes an option to keep the old behavior is really desirable for some users.

Who

Quote from: eumagga0x2a on August 28, 2021, 02:52:24 PMPlease provide its last words when running it from the Terminal as it doesn't look to be difficult to trigger the crash.

It printed exactly two lines when it started and nothing at all after it crashed:

"Directory /Users/user/.avidemux6/ exists.Good.
Using /Users/user/.avidemux6/ as base directory for prefs, jobs, etc."

eumagga0x2a

Quote from: Who on August 28, 2021, 04:01:23 PMI would love to run a build of the current code

It is not difficult to build it yourself. You need only Homebrew and command-line tools (if I am not mistaken, Homebrew will prompt you to install the latter).

Quote from: Who on August 28, 2021, 04:01:23 PMMaybe I should ask, is there any way to black hole all those debug messages?

Run Avidemux in Terminal using the command (assuming Avidemux nightly is installed to /Applications):

/Applications/Avidemux_2.7.9.app/Contents/MacOS/Avidemux2.7 > /dev/null 2>&1
This discards all the output of the application (both stdout and stderr).

Quote from: Who on August 28, 2021, 04:01:23 PMRegarding the crashing, I thought I'd sent you that info before, and that's when you told me to try using Qt.

You had, but it is already a while ago and I cannot find it anymore :-[

Quote from: Who on August 28, 2021, 04:01:23 PMI don't remember how you run Avidemux from a terminal in MacOS

/Applications/Avidemux_2.7.9.app/Contents/MacOS/Avidemux2.7
Quote from: Who on August 28, 2021, 04:01:23 PMCould you please provide an option to make it NOT try to use the highest zoom level without upscaling which would fit into the available space?

This change was contributed upon request of users which would be upset to see it reverted, and I am reluctant to expand the already big set of configuration parameters. Please press 3 or 4 upon loading a video, this is all it takes to make the window small again.

Quote from: Who on August 28, 2021, 04:01:23 PMI am sure that change might be seen as a benefit to some people (mainly people with very fast systems)

This is not related to the speed of a system as scaling is usually performed at almost zero cost by the graphics card. Effort should be put into improving the situation with hw acceleration on macOS (OpenGL is deprecated by Apple, so we need to move to something else – Metal?).

Quote from: Who on August 28, 2021, 10:56:46 PM
Quote from: eumagga0x2a on August 28, 2021, 02:52:24 PMPlease provide its last words when running it from the Terminal as it doesn't look to be difficult to trigger the crash.

It printed exactly two lines when it started and nothing at all after it crashed:

"Directory /Users/user/.avidemux6/ exists.Good.
Using /Users/user/.avidemux6/ as base directory for prefs, jobs, etc."

Please post the exact command you have executed. It looks like the output is still redirected to a file. Apple has changed the default shell from bash to zsh. I cannot rule out that it might be a problem, please run

chsh -s /bin/bash
to switch to bash, then log off and on again.

Who

Quote from: eumagga0x2a on August 28, 2021, 11:06:14 PM
Quote from: Who on August 28, 2021, 04:01:23 PMI would love to run a build of the current code

It is not difficult to build it yourself. You need only Homebrew and command-line tools (if I am not mistaken, Homebrew will prompt you to install the latter).

In case I haven't told you before, I'm not a programmer, and I would not have the foggiest notion how to use something like Homebrew.  Plus, I do not want to install something that will take up a lot of space.  There is some Apple tool that programmers use, I forget the name of it but I made the mistake of installing it once and it took up an incredible amount of space, and the real kick in the pants was I still couldn't make it work.  So, I leave building software to those who know how to do it and enjoy doing it.

Quote from: eumagga0x2a on August 28, 2021, 11:06:14 PM
Quote from: Who on August 28, 2021, 04:01:23 PMMaybe I should ask, is there any way to black hole all those debug messages?

Run Avidemux in Terminal using the command (assuming Avidemux nightly is installed to /Applications):

/Applications/Avidemux_2.7.9.app/Contents/MacOS/Avidemux2.7 > /dev/null 2>&1
This discards all the output of the application (both stdout and stderr).

Okay, thanks.  Would not want to have to run it that way forever but I guess I can do it that way until a new MacOS build comes out.

Quote from: eumagga0x2a on August 28, 2021, 11:06:14 PM
Quote from: Who on August 28, 2021, 04:01:23 PMRegarding the crashing, I thought I'd sent you that info before, and that's when you told me to try using Qt.

You had, but it is already a while ago and I cannot find it anymore :-[

Quote from: Who on August 28, 2021, 04:01:23 PMI don't remember how you run Avidemux from a terminal in MacOS

/Applications/Avidemux_2.7.9.app/Contents/MacOS/Avidemux2.7

Actually later this afternoon I had remembered that I could search my history and I found this (slightly modified to point to the current version):

/Applications/Avidemux_2.7.9.app/Contents/MacOS/Avidemux2.7 2>&1 | tee "~/admlog.txt"

In case you are wondering, admlog.txt contained the same two lines I posted in my previous post.

Quote from: eumagga0x2a on August 28, 2021, 11:06:14 PM
Quote from: Who on August 28, 2021, 04:01:23 PMCould you please provide an option to make it NOT try to use the highest zoom level without upscaling which would fit into the available space?

This change was contributed upon request of users which would be upset to see it reverted, and I am reluctant to expand the already big set of configuration parameters. Please press 3 or 4 upon loading a video, this is all it takes to make the window small again.

Okay, I really don't like that answer and I will tell you why.  You have a whole bunch of users that are used to the previous behavior, whom I assume were never asked if they were okay with the change.  But because some favored "users" made the request, you are acting like the new behavior is set in stone, and now all the rest of us (especially those running slower systems) have to be inconvenienced because you are reluctant to add one more configuration parameter.  I do not understand that thinking at all, nor how that is in any way fair to your longtime users.  You are willing to ask me to run Homebrew, which is way outside my skill set.  You want me to remember to punch in a non-mnemonic number (not even something I maybe could remember like "H" for half size) every time I run the program, and if I forget I'll have to endure poor performance in the display, and a display that covers far more of my screen than I want (blocking any other windows I may have open), all because you don't want to upset someone who made the request for this behavior, or add another configuration option.  Who are these magic users that have you under their spell, and what do they have that the rest of us don't?

But the bigger problem is that PRESSING 3 OR 4 DOES NOT WORK once you have clicked the "Play" button!  The behavior I see is that when I start Avidemux it comes up too large, so now I have to go to the View menu and click on "Zoom 1:2" which is an inconvenience, and because I can't remember which keypress number is which.  But okay, now it's at the size I want it, UNTIL I CLICK THE PLAY BUTTON.  Then it expands to fill the screen again (but not always exactly, often the right side is out beyond the edge of my screen, so now I have to try and move the window so it is all visible) and at this point I can press 3 or 4 from now until the video ends and those keys have absolutely no effect.  So that is not a solution at all!

I REALLY don't understand your objection to adding configuration options.  I am of the opinion that the more there are the better, as long as they serve a purpose.  If I were in that favored group of users that actually gets their requests granted, I would ask that you make everything configurable (if it makes sense to do so).  I will never, ever complain that a program is too configurable, but I really hate programs that aren't configurable enough, and I doubly hate those that change how they operate after users have gotten used to them working one way and don't offer an option to keep the old behavior, ESPECIALLY when the new behavior offers decreased functionality and/or makes the program harder to use.  Apple itself is famous for this, as an example, over the years they have turned iMessages (now just Messages) from a really great program into a steaming pile of crap that's only about 1/10 as usable.  Please don't be like Apple in that regard.

But in this particular case, I think this option is especially needed, probably more than anything else that I have ever asked for (and much of which you have ignored, apparently because I'm not in the favored few.  If you can't understand why I find your response so infuriating, please recall that when you changed to those segmented digits several of us long time users didn't like it, but that didn't bother you a bit, so I really have to wonder what this other user or group of users have over you that makes you think their preferences must be imposed on all your other users).

Quote from: eumagga0x2a on August 28, 2021, 11:06:14 PM
Quote from: Who on August 28, 2021, 04:01:23 PMI am sure that change might be seen as a benefit to some people (mainly people with very fast systems)

This is not related to the speed of a system as scaling is usually performed at almost zero cost by the graphics card. Effort should be put into improving the situation with hw acceleration on macOS (OpenGL is deprecated by Apple, so we need to move to something else – Metal?).

I have no clue at all what Metal is but the one thing I really hope is that you don't forget about all of us that still have Intel processors.  I am not certain I will ever have a system with Apple silicon, given my disgust with the direction Apple has taken in recent years.

Quote from: eumagga0x2a on August 28, 2021, 11:06:14 PM
Quote from: Who on August 28, 2021, 10:56:46 PM
Quote from: eumagga0x2a on August 28, 2021, 02:52:24 PMPlease provide its last words when running it from the Terminal as it doesn't look to be difficult to trigger the crash.

It printed exactly two lines when it started and nothing at all after it crashed:

"Directory /Users/user/.avidemux6/ exists.Good.
Using /Users/user/.avidemux6/ as base directory for prefs, jobs, etc."

Please post the exact command you have executed. It looks like the output is still redirected to a file. Apple has changed the default shell from bash to zsh. I cannot rule out that it might be a problem, please run

chsh -s /bin/bash
to switch to bash, then log off and on again.

I posted the command above, but here it is again:

/Applications/Avidemux_2.7.9.app/Contents/MacOS/Avidemux2.7 2>&1 | tee "~/admlog.txt"

My system is not running zsh, it is running bash.  I know this because every time I bring up a terminal window, it says:

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.

I have never updated to use zsh because I am happy with how the terminal works now (I really don't like changes being forced on me) so I am definitely running bash.  The real issue seems to be that for some reason when using OpenGL, after it finishes saving the encode it just exits abnormally without sending anything additional to the terminal.

eumagga0x2a

Quote from: Who on August 29, 2021, 03:46:24 AMThere is some Apple tool that programmers use, I forget the name of it but I made the mistake of installing it once and it took up an incredible amount of space

Later on I learned that installing Xcode is not necessary to obtain command-line tools (the only part we need). It is Xcode which is huge, but command-line tools (compilers etc.) are tiny in comparison.

Installing Homebrew amounts to running a single command in Terminal (per copy & paste), see the instructions.. My Homebrew with quite a lot of additional goodies, not related to building and packaging Avidemux, occupies 2.6 GiB of disk space.

That said, if you wish, there is an easy way forward to your own Avidemux build as there is an easy way to find an excuse not to. Neither requires any programmer's skills. I am perfectly fine with any choice.

Quote from: Who on August 29, 2021, 03:46:24 AMActually later this afternoon I had remembered that I could search my history and I found this (slightly modified to point to the current version):

/Applications/Avidemux_2.7.9.app/Contents/MacOS/Avidemux2.7 2>&1 | tee "~/admlog.txt"
In case you are wondering, admlog.txt contained the same two lines I posted in my previous post.

I indeed wondered why it happens (quotation marks in the command above are clearly an error – an unrelated error – did I give it to you this way, with the quotation marks?). It turns out to be that I fundamentally misunderstood how the function works which I used to detect that Avidemux is run in a Terminal to disable stdout redirection to /tmp/admlog.txt, my apologies. Any redirection of debug messages in the Terminal (using ">" or "|") makes stdout redirection to /tmp/admlog.txt kick in. This is what I wasn't aware of.

In this form the comfort of having the messages always in reach in a log file is probably not worth the hassle of losing the ability to filter or redirect stdout when running in Terminal.

Quote from: Who on August 29, 2021, 03:46:24 AMMy system is not running zsh, it is running bash

Very good.

Quote from: Who on August 29, 2021, 03:46:24 AMBut the bigger problem is that PRESSING 3 OR 4 DOES NOT WORK once you have clicked the "Play" button!

This is correct, you need to press 3 or 4 while in stop mode, so in case you already started playback, please press the space key first.

Who

The quotation marks were only there because when I previously ran the command I was saving the file to a directory that had a space in the name.  Therefore I had to surround the path and filename with quotation marks.  In this case the quotation marks weren't necessary but they don't hurt anything.

I don't know about you, but as a user I never look at log files.  They convey no useful information to me, and just take up space in my storage.  That's another option that would be nice to have, the ability to disable generation of a log file, because it's only useful on the rare occasion when someone like you requests it.

As for your comments about Homebrew, one thing that continually perplexes me is the mindset that some developers have that there are no "just plain users", that everyone should be a coder or a systems administrator or something.  And yet if you told those same developers that they should always fix their own cars, or do their own home repairs they would look at you like you're crazy.  I know what I'm good at and what I'm not, and programming is something I'm definitely not good at.  I'm just waiting patiently for an official MacOS build to be released, and until then I can always drop back to the previous version that I was using if I feel the need to do so.

I am pretty certain you have explained in the past why the MacOS builds don't get created at the same time as Windows and Linux builds, but my memory is so bad that I really don't remember.  I do recall that there is a reason, just not what that reason is.  Not that it matters, though, because I'm guessing there will be a new MacOS release sooner or later.  And who knows, someday I might give up on MacOS entirely and move to something else (it could be Linux, except those guys really seem to have the "there are no just plain users" mentality, so I don't think that would be a happy transition for me).

eumagga0x2a

Quote from: Who on August 30, 2021, 02:22:21 PMIn this case the quotation marks weren't necessary but they don't hurt anything.

Writing

~/admlog.txt
means file admlog.txt in your home directory, no matter with spaces or not. Writing

"~/admlog.txt"
with quote marks means file admlog.txt in a subdirectory ~ of the current directory. Putting the special character ~ in quote marks disables its function to expand to the absolute path to the home directory.

Quote from: Who on August 30, 2021, 02:22:21 PMI don't know about you, but as a user I never look at log files.  They convey no useful information to me, and just take up space in my storage.  That's another option that would be nice to have, the ability to disable generation of a log file, because it's only useful on the rare occasion when someone like you requests it.

Not having logs written to disk by default on macOS means to have to teach users to use Terminal (as it was all the time before this functionality was introduced) every time some reliable information about the application and its working is required. Logging starts well before Avidemux preferences are initialized – and they are initialized before the application window appears on screen, so if something happens in-between and the application fails to display a window, there is no way a non-technical user can enable logging.

I don't deny that logging itself can pose a problem (it has just proven this), but the issue is rather complex. It is high on my todo list, but not necessarily as a checkbox in the preferences.

Quote from: Who on August 30, 2021, 02:22:21 PMNot that it matters, though, because I'm guessing there will be a new MacOS release sooner or later.

I hope so.

eumagga0x2a

#12
A fresh macOS nightly is now available in https://avidemux.org/nightly/osx_catalina/. Please enable QtGl display, reproduce the crash you experience sometimes at the end of encoding, do not restart Avidemux yet, copy /tmp/admlog.txt to a different location to avoid it being overwritten (now it is fine to launch Avidemux again) and attach it to your reply.

(Please don't run Avidemux in Terminal for that, just execute it normally.)

Who

Quote from: eumagga0x2a on September 05, 2021, 10:40:00 AMA fresh macOS nightly is now available in https://avidemux.org/nightly/osx_catalina/. Please enable QtGl display, reproduce the crash you experience sometimes at the end of encoding, do not restart Avidemux yet, copy /tmp/admlog.txt to a different location to avoid it being overwritten (now it is fine to launch Avidemux again) and attach it to your reply.

(Please don't run Avidemux in Terminal for that, just execute it normally.)

I did one encoding with the new version and it did not crash afterwards, so I have a second one going now.  If it crashes I'll send that file to you, if not then I probably won't do any more encoding until tomorrow, but I'll keep this open in a tab for a few days so if it does crash (and I really hope it doesn't) I can refer to it and send you the requested file.

Thank you for the new version, it seems to work better than the previous MacOS version!

EDIT:  Didn't crash after second one either.  In Preferences, "Display" tab, Video Display is set to Qt - there is no "QtGl" option, just "Qt" and "OpenGl (best)".  Since it didn't crash under Qt (not yet anyway) I set it to use OpenGL and will try that tomorrow.

eumagga0x2a

Quote from: Who on September 06, 2021, 10:17:20 PMthere is no "QtGl" option, just "Qt" and "OpenGl (best)"

I've mixed up the name of the OpenGL renderer shown in the main window ("QtGl") and the menu entry in the preferences.

Quote from: Who on September 06, 2021, 10:17:20 PMI set it to use OpenGL and will try that tomorrow.

Yes, please.