I would like to run the application on a headless Linux server using mono but I get this error:
$ mono SubtitleEdit.exe /?
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'System.Windows.Forms.XplatUI' threw an exception. ---> System.ArgumentNullException: Could not open display (X-Server required. Check your DISPLAY environment variable)
Parameter name: Display
at System.Windows.Forms.XplatUIX11.SetDisplay (System.IntPtr display_handle) [0x00435] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
at System.Windows.Forms.XplatUIX11..ctor () [0x00077] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
at System.Windows.Forms.XplatUIX11.GetInstance () [0x0001c] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
at System.Windows.Forms.XplatUI..cctor () [0x0007d] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.Application.EnableVisualStyles () [0x00006] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
at Nikse.SubtitleEdit.Program.Main () [0x0002d] in <a350741a374d4e31a818096ace4f9fe2>:0
This seems to work on Windows without any problem. Is there anyway to start the application without needing xserver/ a display?
You could try SE-3.5.9-headless.7z from this folder.
But, I doubt, /multiplereplace and some other things will work鈥攎ost likely the same exception will be raised.
Similar error unfortunately. I'm most interested in /fixcommonerrors and /removetextforhi.
$ mono SubtitleEdit.exe /?
Unhandled Exception:
System.TypeInitializationException: The type initializer for 'System.Windows.Forms.WindowsFormsSynchronizationContext' threw an exception. ---> System.TypeInitializationException: The type initializer for
'System.Windows.Forms.XplatUI' threw an exception. ---> System.ArgumentNullException: Could not open display (X-Server required. Check your DISPLAY environment variable)
Parameter name: Display
at System.Windows.Forms.XplatUIX11.SetDisplay (System.IntPtr display_handle) [0x00435] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
at System.Windows.Forms.XplatUIX11..ctor () [0x00077] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
at System.Windows.Forms.XplatUIX11.GetInstance () [0x0001c] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
at System.Windows.Forms.XplatUI..cctor () [0x0007d] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.Theme.get_MenuAccessKeysUnderlined () [0x00000] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
at System.Windows.Forms.SystemInformation.get_MenuAccessKeysUnderlined () [0x00005] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
at System.Windows.Forms.Control..ctor () [0x000ea] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:.ctor ()
at System.Windows.Forms.WindowsFormsSynchronizationContext..cctor () [0x00000] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.Control..ctor () [0x00014] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
at System.Windows.Forms.ScrollableControl..ctor () [0x00000] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
at System.Windows.Forms.ContainerControl..ctor () [0x0000e] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
at System.Windows.Forms.Form..ctor () [0x00012] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
at Nikse.SubtitleEdit.Forms.Main..ctor () [0x00126] in <3cf83f3f73744d7ea5df635a369e3383>:0
at (wrapper remoting-invoke-with-check) Nikse.SubtitleEdit.Forms.Main:.ctor ()
at Nikse.SubtitleEdit.Program.Main () [0x00000] in <3cf83f3f73744d7ea5df635a369e3383>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'System.Windows.Forms.WindowsFormsSynchronizationContext' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Windows.Forms.XplatUI' threw an exception. ---> System.ArgumentNullException: Could not open display (X-Server required. Check your DISPLAY environment variable)
Parameter name: Display
at System.Windows.Forms.XplatUIX11.SetDisplay (System.IntPtr display_handle) [0x00435] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
at System.Windows.Forms.XplatUIX11..ctor () [0x00077] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
at System.Windows.Forms.XplatUIX11.GetInstance () [0x0001c] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
at System.Windows.Forms.XplatUI..cctor () [0x0007d] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.Theme.get_MenuAccessKeysUnderlined () [0x00000] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
at System.Windows.Forms.SystemInformation.get_MenuAccessKeysUnderlined () [0x00005] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
at System.Windows.Forms.Control..ctor () [0x000ea] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:.ctor ()
at System.Windows.Forms.WindowsFormsSynchronizationContext..cctor () [0x00000] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.Control..ctor () [0x00014] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
at System.Windows.Forms.ScrollableControl..ctor () [0x00000] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
at System.Windows.Forms.ContainerControl..ctor () [0x0000e] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
at System.Windows.Forms.Form..ctor () [0x00012] in <d5b72d15d4f7424c8a1538e3f19ec2e3>:0
at Nikse.SubtitleEdit.Forms.Main..ctor () [0x00126] in <3cf83f3f73744d7ea5df635a369e3383>:0
at (wrapper remoting-invoke-with-check) Nikse.SubtitleEdit.Forms.Main:.ctor ()
at Nikse.SubtitleEdit.Program.Main () [0x00000] in <3cf83f3f73744d7ea5df635a369e3383>:0
+1 still waiting for it 馃憤
I'd also love to get a Linux headless version of this, even just for subtitle conversion (I'm running it in Windows in CLI to convert SRT to PAC and EBU-STL, works so brilliantly, thank you!). The 'headless' version in this comment has gone now, any chance of trying again? https://github.com/SubtitleEdit/subtitleedit/issues/3568#issuecomment-491418798
Hey, I got it working with Docker on a headless Linux environment. The same process should also work without Docker.
I used Subtitle Edit's Portable version, mono, and xvfb to achieve this.
xvfb is used to run GUI applications on headless environments using a virtual display.
xvfb-run, and also checked "Running Concurrent Builds" to learn about -a flag.Part of my docker setup about Subtitle Edit:
# to add xvfb
RUN apt-get install -y xvfb
# these are all the necessary packages that were specified on https://nikse.dk/SubtitleEdit/Help#linux
RUN apt-get install -y mono-complete
RUN apt-get install -y libhunspell-dev
RUN apt-get install -y libmpv-dev
RUN apt-get install -y tesseract-ocr
RUN apt-get install -y vlc
RUN apt-get install -y ffmpeg
After that, I also got an error about saying something like: /etc/timezone is not found.
To fix this, I followed the solution on this link.
After you do all that stuff, the terminal command looks like this:
xvfb-run -a mono SubtitleEdit.exe /convert sub1.srt sami
Hey, I got it working with Docker on a headless Linux environment. The same process should also work without Docker.
I used Subtitle Edit's Portable version, mono, and xvfb to achieve this.xvfb is used to run GUI applications on headless environments using a virtual display.
- This great reference a short explanation of why we need to use xvfb.
- This great reference has several options to approach this issue. I checked "Option 2" to learn about xvfb-run, and also checked "Running Concurrent Builds" to learn about
-aflag.Part of my docker setup about Subtitle Edit:
# to add xvfb RUN apt-get install -y xvfb # these are all the necessary packages that were specified on https://nikse.dk/SubtitleEdit/Help#linux RUN apt-get install -y mono-complete RUN apt-get install -y libhunspell-dev RUN apt-get install -y libmpv-dev RUN apt-get install -y tesseract-ocr RUN apt-get install -y vlc RUN apt-get install -y ffmpegAfter that, I also got an error about saying something like:
/etc/timezone is not found.
To fix this, I followed the solution on this link.After you do all that stuff, the terminal command looks like this:
xvfb-run -a mono SubtitleEdit.exe /convert sub1.srt sami
Wonderful, I'll try this out thank you @batatop - perfect timing as I was just about to resign myself to learning some PowerShell to use in Windows CLI scriptin.
Most helpful comment
+1 still waiting for it 馃憤