September 23, 2020, 07:40:21 am

News:

--


"Open With", File Associations, and multiple instances

Started by John Hagan, September 14, 2020, 02:07:03 am

Previous topic - Next topic

John Hagan

I've attempted to "Open With" and associate (that is, always open with) MP4 and MKV files using Avidemux_2.7.6 under MacOS Catalina. Although Avidemux opens, it does so without loading the file requesting to be opened. I can drag&drop the file, or use File-->Open... to then actually load the file--which loads the file perfectly, as expected.

While I have your attention, is there a recommended way to run more than one instance of Avidemux under MacOS? At the moment, since I can't get double-clicking a file to open the app AND load the file, I associate Avidemux with a desired file type, double-click such a file (which does open a new instance of Avidemux, but doesn't load the file), and then drag&drop the desired file into the new instance.

My situation would be vastly improved if double-clicking an associated file type would just open and load the requesting file into a new instance of Avidemux. Also, it probably would be cool to add something like "Open in New Window..." to the file menu, since you can't get the the Dock or Launcher to open a second instance of Avidemux.

Well, at least I can't figure out how to!

--John.

eumagga0x2a

It turns out to be that Finder doesn't pass the file to open as an argument to the app, so there is no easy way to make "Open With" work with Avidemux.

Regarding concurrent execution of multiple Avidemux instances, I would discourage trying to do so as the instance last to close will overwrite whatever configuration and session restore data was created by other instances (maybe also other things may go haywire).

John Hagan

I understand that the Finder doesn't pass the file to open as an argument to the app via the old argv[] interface, but the MacOS framework does provide a mechanism for the Finder to send a message to an app it launches with the reference to the selected file that caused the launch. That's how every other MacOS app gets the file to open when invoked by the Finder. I think it's just a few lines of code to implement the handler for the message.

I've used Avidemux under Windows for many years, during which time I had it associated with the video file types I used. I could double-clicked any video file in an Explorer window, and it would open  right up in a new instance of Avidemux. It was also quite common for me to have more than one file open at the same time in their own instances of Avidemux. Sometimes it would be to compare two files, or to look for the right file to append to the video I was editing in another instance of Avidemux, or to verify the recently saved file turned out correctly before closing the instance with all the editing cuts. I believe Windows also had the last closed instance "win" regarding the overwriting of configuration settings; however, that seemed to be consistent, expected, and even desirable behavior. I don't think I was ever surprised by any unexpected or corrupt saved settings suddenly popping up.

Now that I'm working on a Mac instead of Windows, I was thrilled to see that there is a version of Avidemux for it. However, without the ability to open files right from the Finder, my workflow is pretty badly impacted. And, even in its current form where it can be configured to launch another instance based on a file type (but not load it) from the Finder, I do it because it's the only way I can get more than one instance to run at the same time.

I hope you will consider adding the Finder open file capability. It would allow Avidemux to serve as a full fledged Mac app suitable for associating with video file types and launching with the Finder. And, it would give me back my dearly missed multi-instance capability, too!

eumagga0x2a

Quote from: John Hagan on September 15, 2020, 12:33:12 amI understand that the Finder doesn't pass the file to open as an argument to the app via the old argv[] interface,

...which works just fine for every application elsewhere like a basic concept of interaction...

Quote from: John Hagan on September 15, 2020, 12:33:12 ambut the MacOS framework does provide a mechanism for the Finder to send a message to an app it launches with the reference to the selected file that caused the launch. That's how every other MacOS app gets the file to open when invoked by the Finder.

Yes, and the rationale begind this design is the exact opposite of your second wish: it is to avoid launching multiple instances of the application.

Quote from: John Hagan on September 15, 2020, 12:33:12 amI think it's just a few lines of code to implement the handler for the message.

I hope so: https://doc.qt.io/qt-5/qfileopenevent.html.

I don't know yet whether the fact that the executable which is launched when running Avidemux app on macOS is a shell script which sets an env variable and then executes the real Avidemux binary is compatible with this approach.

Quote from: John Hagan on September 15, 2020, 12:33:12 amNow that I'm working on a Mac instead of Windows, I was thrilled to see that there is a version of Avidemux for it. However, without the ability to open files right from the Finder, my workflow is pretty badly impacted. And, even in its current form where it can be configured to launch another instance based on a file type (but not load it) from the Finder, I do it because it's the only way I can get more than one instance to run at the same time.

I usually run Avidemux on macOS from the Terminal as I need to see debug messages, which also allows concurrent execution.

/Applications/Avidemux_2.7.7.app/Contents/MacOS/Avidemux2.7
(replace "2.7.7" with "2.7.6" if you use the last release, but I would recommend using the nightly, of course).

Quote from: undefinedI hope you will consider adding the Finder open file capability. It would allow Avidemux to serve as a full fledged Mac app suitable for associating with video file types and launching with the Finder.

Not that it is not desired, but the direction of evolution of macOS and Apple hardware will make Avidemux on macOS probably impossible, casting doubt on the purpose of investing more time and effort. macOS support can also cease at any moment when essential keys on the keyboard of my late-2016 MBP permanently stop working.

Quote from: undefinedAnd, it would give me back my dearly missed multi-instance capability, too!

Unsure about that, but I'll try to look into improving platform integration.

John Hagan

I understand that the 1960s ASCII terminal environment in Unix gave birth to the argv[] approach, and it still rules to this day in defining shell interaction with apps. However, because OS X defined a message passing and object oriented layer above their Unix kernel, the Mac intends to offer a "richer" and "improved" app environment. Regardless of any feelings for the two environments, I certainly understand the Mac's environment is different from the more "pure" derivatives of Unix shells like Linux, FreeBSD, and Windows.

Although the shell message passing approach provides a way for an app to be designed to prevent multiple instances, I wouldn't say its purpose was primarily aimed at avoiding the launching multiple instances of applications. Many Mac apps do open multiple instances: TextEdit, Preview, QuickTime Player, and VLC are just a few examples. I wouldn't say those apps are "working around" an OS X mechanism designed to prevent that behavior. Instead, I would say they are implementing the normal, desired behavior of a Mac app that is intended to open an instance of itself when asked to open a file from the Finder.

I hope QFileOpenEvent turns out to be compatible with the current Avidemux app approach. If it is, it doesn't look like too much code is needed. If it isn't, I understand why this can't be easily addressed.

Thanks for the tip regarding using Terminal to open multiple instances.

I hear you when you express doubts about Avidemux's future on the Mac platform. I know the changes Apple has made--and plans to make--is making it harder and harder to have common source code to serve the ever increasing differences in the platforms.

Very sorry to hear about your 2016 MacBook Pro. From what I've heard, the keyboard on that model is destine to fail. I know some folks got a whole new upper case along with a new keyboard when they took advantage of the Apple extended replacement program after having troubles with their butterfly keyboards. If you have a key already not working well, maybe you should try and get Apple to replace it while you still can. I'm sure all the other users of Mac Avidemux would appreciate knowing you'd be more likely to be able to support it for a little longer into the uncertain future.

Thanks for all your replies and consideration. And if you can't get your keyboard replaced, here's hoping you got the one good butterfly keyboard that lasts!