Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

issue 517: MEncoder crashes when using > 8 cores

  • Loading branch information...
commit a766d0fa7ae8e28390113df202071c959af03ef3 1 parent b003c35
@chocolateboy chocolateboy authored
View
39 ps3mediaserver/net/pms/PMS.java
@@ -372,11 +372,8 @@ private boolean init() throws Exception {
}
frame.setStatusCode(0, Messages.getString("PMS.130"), "connect_no-220.png"); //$NON-NLS-1$ //$NON-NLS-2$
-
proxy = -1;
-
-
minimal("Starting PS3 Media Server " + VERSION); //$NON-NLS-1$
minimal("by shagrath / 2008-2011"); //$NON-NLS-1$
minimal("http://ps3mediaserver.org"); //$NON-NLS-1$
@@ -418,7 +415,7 @@ private boolean init() throws Exception {
minimal("Checking MPlayer font cache. It can take a minute or so.");
checkProcessExistence("MPlayer", true, null, configuration.getMplayerPath(), "dummy");
if(isWindows()) {
- checkProcessExistence("MPlayer", true, getConfiguration().getTempFolder(), configuration.getMplayerPath(), "dummy");
+ checkProcessExistence("MPlayer", true, configuration.getTempFolder(), configuration.getMplayerPath(), "dummy");
}
minimal("Done!");
@@ -590,7 +587,7 @@ public void manageRoot(RendererConfiguration renderer) throws IOException {
rootFolder.browse(MapFileConfiguration.parse(configuration.getVirtualFolders()));
// FIXME: this (the WEB.conf path) should be fully configurable
- File webConf = new File(PMS.getConfiguration().getProfileDir(), "WEB.conf"); //$NON-NLS-1$
+ File webConf = new File(configuration.getProfileDir(), "WEB.conf"); //$NON-NLS-1$
if (webConf.exists()) {
try {
@@ -652,13 +649,13 @@ public void manageRoot(RendererConfiguration renderer) throws IOException {
}
if (Platform.isMac()) {
- if (getConfiguration().getIphotoEnabled()) {
+ if (configuration.getIphotoEnabled()) {
addiPhotoFolder(renderer);
}
}
if (Platform.isMac() || Platform.isWindows()) {
- if (getConfiguration().getItunesEnabled()) {
+ if (configuration.getItunesEnabled()) {
addiTunesFolder(renderer);
}
}
@@ -857,13 +854,13 @@ public boolean enable() {
}
});
- vf.addChild(new VirtualVideoAction(" !!-- Fix 23.976/25fps A/V Mismatch --!!", getConfiguration().isFix25FPSAvMismatch()) { //$NON-NLS-1$
+ vf.addChild(new VirtualVideoAction(" !!-- Fix 23.976/25fps A/V Mismatch --!!", configuration.isFix25FPSAvMismatch()) { //$NON-NLS-1$
@Override
public boolean enable() {
- getConfiguration().setMencoderForceFps(!getConfiguration().isFix25FPSAvMismatch());
- getConfiguration().setFix25FPSAvMismatch(!getConfiguration().isFix25FPSAvMismatch());
- return getConfiguration().isFix25FPSAvMismatch();
+ configuration.setMencoderForceFps(!configuration.isFix25FPSAvMismatch());
+ configuration.setFix25FPSAvMismatch(!configuration.isFix25FPSAvMismatch());
+ return configuration.isFix25FPSAvMismatch();
}
});
@@ -1067,11 +1064,10 @@ private void registerExtensions() {
extensions.add(new RAW());
}
- /**Register a known set of audio/video transform tools (known as {@link Player}s). Used in PMS#init().
+ /**Register a known set of audio/video transcoders (known as {@link Player}s). Used in PMS#init().
* @see PMS#init()
*/
private void registerPlayers() {
- assert configuration != null;
if (Platform.isWindows()) {
registerPlayer(new FFMpegVideo());
}
@@ -1258,9 +1254,9 @@ public String usn() {
boolean uuidBasedOnMAC = false;
NetworkInterface ni = null;
try {
- if (getConfiguration().getServerHostname() != null && getConfiguration().getServerHostname().length() > 0) {
+ if (configuration.getServerHostname() != null && configuration.getServerHostname().length() > 0) {
try {
- ni = NetworkInterface.getByInetAddress(InetAddress.getByName(getConfiguration().getServerHostname()));
+ ni = NetworkInterface.getByInetAddress(InetAddress.getByName(configuration.getServerHostname()));
} catch (Exception e) {
}
} else if (get().getServer().getNi() != null) {
@@ -1381,6 +1377,7 @@ public static void main(String args[]) throws IOException, ConfigurationExceptio
}
}
}
+
try {
Toolkit.getDefaultToolkit();
if (GraphicsEnvironment.isHeadless() && System.getProperty(NOCONSOLE) == null) {
@@ -1393,7 +1390,13 @@ public static void main(String args[]) throws IOException, ConfigurationExceptio
}
}
- configuration = new PmsConfiguration();
+ try {
+ configuration = new PmsConfiguration();
+ } catch (Throwable t) {
+ System.err.println("Configuration error: " + t.getMessage());
+ }
+
+ assert configuration != null;
// Load the (optional) logback config file. This has to be called after 'new PmsConfiguration'
// as the logging starts immediately and some filters need the PmsConfiguration.
@@ -1404,8 +1407,7 @@ public static void main(String args[]) throws IOException, ConfigurationExceptio
try {
// let's allow us time to show up serious errors in the GUI before quitting
Thread.sleep(60000);
- } catch (InterruptedException e) {
- }
+ } catch (InterruptedException e) {}
}
public HTTPServer getServer() {
@@ -1429,7 +1431,6 @@ public void save() {
}
public static PmsConfiguration getConfiguration() {
- assert configuration != null;
return configuration;
}
}
View
178 ps3mediaserver/net/pms/configuration/PmsConfiguration.java
@@ -24,112 +24,116 @@
import com.sun.jna.Platform;
public class PmsConfiguration {
- private static final String KEY_TEMP_FOLDER_PATH = "temp";
- private static final String KEY_TSMUXER_FORCEFPS = "tsmuxer_forcefps";
- // private static final String KEY_TSMUXER_PREREMUX_PCM = "tsmuxer_preremux_pcm";
+ private static final int DEFAULT_PROXY_SERVER_PORT = -1;
+ private static final int DEFAULT_SERVER_PORT = 5001;
+ // MEncoder has a hardwired maximum of 8 threads for -lavcopts and -lavdopts:
+ // https://code.google.com/p/ps3mediaserver/issues/detail?id=517
+ private static final int MENCODER_MAX_THREADS = 8;
+ private static final String KEY_ALTERNATE_SUBS_FOLDER = "alternate_subs_folder";
+ private static final String KEY_ALTERNATE_THUMB_FOLDER = "alternate_thumb_folder";
private static final String KEY_AUDIO_BITRATE = "audiobitrate";
- private static final String KEY_TSMUXER_PREREMIX_AC3 = "tsmuxer_preremix_ac3";
- private static final String KEY_SERVER_PORT = "port";
- private static final String KEY_SERVER_HOSTNAME = "hostname";
- private static final String KEY_PROXY_SERVER_PORT = "proxy";
+ private static final String KEY_AUDIO_CHANNEL_COUNT = "audiochannels";
+ private static final String KEY_AUDIO_RESAMPLE = "audio_resample";
+ private static final String KEY_AUDIO_THUMBNAILS_METHOD = "audio_thumbnails_method";
+ private static final String KEY_AVISYNTH_CONVERT_FPS = "avisynth_convertfps";
+ private static final String KEY_AVISYNTH_SCRIPT = "avisynth_script";
+ private static final String KEY_BUFFER_TYPE = "buffertype";
+ private static final String KEY_CHAPTER_INTERVAL = "chapter_interval";
+ private static final String KEY_CHAPTER_SUPPORT = "chapter_support";
+ private static final String KEY_CHARSET_ENCODING = "charsetencoding";
+ private static final String KEY_CODEC_SPEC_SCRIPT = "codec_spec_script";
+ private static final String KEY_DISABLE_FAKESIZE = "disable_fakesize";
+ private static final String KEY_DVDISO_THUMBNAILS = "dvd_isos_thumbnails";
+ private static final String KEY_EMBED_DTS_IN_PCM = "embed_dts_in_pcm";
+ private static final String KEY_ENGINES = "engines";
+ private static final String KEY_FFMPEG_ALTERNATIVE_PATH = "alternativeffmpegpath";
+ private static final String KEY_FFMPEG_SETTINGS = "ffmpeg";
+ private static final String KEY_FIX_25FPS_AV_MISMATCH = "fix_25fps_av_mismatch";
+ private static final String KEY_FORCETRANSCODE = "forcetranscode";
+ private static final String KEY_HIDE_EMPTY_FOLDERS = "hide_empty_folders";
+ private static final String KEY_HIDE_ENGINENAMES = "hide_enginenames";
+ private static final String KEY_HIDE_EXTENSIONS = "hide_extensions";
+ private static final String KEY_HIDE_MEDIA_LIBRARY_FOLDER = "hide_media_library_folder";
+ private static final String KEY_HIDE_TRANSCODE_FOLDER = "hide_transcode_folder";
+ private static final String KEY_HIDE_VIDEO_SETTINGS = "hidevideosettings";
+ private static final String KEY_HTTP_ENGINE_V2 = "http_engine_v2";
+ private static final String KEY_IP_FILTER = "ip_filter";
+ private static final String KEY_IPHOTO_ENABLED = "iphoto";
+ private static final String KEY_ITUNES_ENABLED = "itunes";
private static final String KEY_LANGUAGE = "language";
- private static final String KEY_MIN_MEMORY_BUFFER_SIZE = "minvideobuffer";
+ private static final String KEY_LOGGING_LEVEL = "level";
+ private static final String KEY_MAX_AUDIO_BUFFER = "maxaudiobuffer";
+ private static final String KEY_MAX_BITRATE = "maximumbitrate";
private static final String KEY_MAX_MEMORY_BUFFER_SIZE = "maxvideobuffer";
private static final String KEY_MENCODER_AC3_FIXED = "mencoder_ac3_fixed";
+ private static final String KEY_MENCODER_ASS_DEFAULTSTYLE = "mencoder_ass_defaultstyle";
private static final String KEY_MENCODER_ASS_MARGIN = "mencoder_ass_margin";
+ private static final String KEY_MENCODER_ASS = "mencoder_ass";
private static final String KEY_MENCODER_ASS_OUTLINE = "mencoder_ass_outline";
private static final String KEY_MENCODER_ASS_SCALE = "mencoder_ass_scale";
private static final String KEY_MENCODER_ASS_SHADOW = "mencoder_ass_shadow";
- private static final String KEY_MENCODER_NOASS_SCALE = "mencoder_noass_scale";
- private static final String KEY_MENCODER_NOASS_SUBPOS = "mencoder_noass_subpos";
- private static final String KEY_MENCODER_NOASS_BLUR = "mencoder_noass_blur";
- private static final String KEY_MENCODER_NOASS_OUTLINE = "mencoder_noass_outline";
- private static final String KEY_THUMBNAIL_SEEK_POS = "thumbnail_seek_pos";
- private static final String KEY_MENCODER_FONT = "mencoder_font";
- private static final String KEY_MENCODER_SUB_FRIBIDI = "mencoder_subfribidi";
private static final String KEY_MENCODER_AUDIO_LANGS = "mencoder_audiolangs";
- private static final String KEY_MENCODER_SUB_LANGS = "mencoder_sublangs";
private static final String KEY_MENCODER_AUDIO_SUB_LANGS = "mencoder_audiosublangs";
- private static final String KEY_MENCODER_SUB_CP = "mencoder_subcp";
- private static final String KEY_MENCODER_ASS = "mencoder_ass";
+ private static final String KEY_MENCODER_DECODE = "mencoder_decode";
private static final String KEY_MENCODER_DISABLE_SUBS = "mencoder_disablesubs";
- private static final String KEY_MENCODER_USE_PCM = "mencoder_usepcm";
private static final String KEY_MENCODER_FONT_CONFIG = "mencoder_fontconfig";
+ private static final String KEY_MENCODER_FONT = "mencoder_font";
private static final String KEY_MENCODER_FORCE_FPS = "mencoder_forcefps";
- private static final String KEY_MENCODER_DECODE = "mencoder_decode";
- private static final String KEY_MENCODER_YADIF = "mencoder_yadif";
+ private static final String KEY_MENCODER_INTELLIGENT_SYNC = "mencoder_intelligent_sync";
+ private static final String KEY_MENCODER_MAIN_SETTINGS = "mencoder_encode";
+ private static final String KEY_MENCODER_MAX_THREADS = "mencoder_max_threads";
+ private static final String KEY_MENCODER_MT = "mencoder_mt";
+ private static final String KEY_MENCODER_MUX_COMPATIBLE = "mencoder_mux_compatible";
+ private static final String KEY_MENCODER_NOASS_BLUR = "mencoder_noass_blur";
+ private static final String KEY_MENCODER_NOASS_OUTLINE = "mencoder_noass_outline";
+ private static final String KEY_MENCODER_NOASS_SCALE = "mencoder_noass_scale";
+ private static final String KEY_MENCODER_NOASS_SUBPOS = "mencoder_noass_subpos";
+ private static final String KEY_MENCODER_NO_OUT_OF_SYNC = "mencoder_nooutofsync";
+ private static final String KEY_MENCODER_REMUX_AC3 = "mencoder_remux_ac3";
+ private static final String KEY_MENCODER_REMUX_MPEG2 = "mencoder_remux_mpeg2";
private static final String KEY_MENCODER_SCALER = "mencoder_scaler";
private static final String KEY_MENCODER_SCALEX = "mencoder_scalex";
private static final String KEY_MENCODER_SCALEY = "mencoder_scaley";
- private static final String KEY_OPEN_ARCHIVES = "enable_archive_browsing";
- private static final String KEY_AUDIO_CHANNEL_COUNT = "audiochannels";
- private static final String KEY_MAX_BITRATE = "maximumbitrate";
- private static final String KEY_THUMBNAILS_ENABLED = "thumbnails";
- private static final String KEY_NUMBER_OF_CPU_CORES = "nbcores";
- private static final String KEY_TURBO_MODE_ENABLED = "turbomode";
+ private static final String KEY_MENCODER_SUB_CP = "mencoder_subcp";
+ private static final String KEY_MENCODER_SUB_FRIBIDI = "mencoder_subfribidi";
+ private static final String KEY_MENCODER_SUB_LANGS = "mencoder_sublangs";
+ private static final String KEY_MENCODER_USE_PCM = "mencoder_usepcm";
+ private static final String KEY_MENCODER_VOBSUB_SUBTITLE_QUALITY = "mencoder_vobsub_subtitle_quality";
+ private static final String KEY_MENCODER_YADIF = "mencoder_yadif";
private static final String KEY_MINIMIZED = "minimized";
- private static final String KEY_USE_SUBTITLES = "autoloadsrt";
- private static final String KEY_HIDE_VIDEO_SETTINGS = "hidevideosettings";
- private static final String KEY_USE_CACHE = "usecache";
- private static final String KEY_AVISYNTH_CONVERT_FPS = "avisynth_convertfps";
- private static final String KEY_AVISYNTH_SCRIPT = "avisynth_script";
- private static final String KEY_MAX_AUDIO_BUFFER = "maxaudiobuffer";
+ private static final String KEY_MIN_MEMORY_BUFFER_SIZE = "minvideobuffer";
private static final String KEY_MIN_STREAM_BUFFER = "minwebbuffer";
- private static final String KEY_BUFFER_TYPE = "buffertype";
- private static final String KEY_FFMPEG_SETTINGS = "ffmpeg";
- private static final String KEY_MENCODER_NO_OUT_OF_SYNC = "mencoder_nooutofsync";
- private static final String KEY_TRANSCODE_BLOCKS_MULTIPLE_CONNECTIONS = "transcode_block_multiple_connections";
- private static final String KEY_TRANSCODE_KEEP_FIRST_CONNECTION = "transcode_keep_first_connection";
- private static final String KEY_CHARSET_ENCODING = "charsetencoding";
- private static final String KEY_MENCODER_INTELLIGENT_SYNC = "mencoder_intelligent_sync";
- private static final String KEY_FFMPEG_ALTERNATIVE_PATH = "alternativeffmpegpath";
- private static final String KEY_SKIP_LOOP_FILTER_ENABLED = "skiploopfilter";
- private static final String KEY_MENCODER_MAIN_SETTINGS = "mencoder_encode";
- private static final String KEY_MENCODER_VOBSUB_SUBTITLE_QUALITY = "mencoder_vobsub_subtitle_quality";
- private static final String KEY_LOGGING_LEVEL = "level";
- private static final String KEY_ENGINES = "engines";
- private static final String KEY_CODEC_SPEC_SCRIPT = "codec_spec_script";
+ private static final String KEY_MUX_ALLAUDIOTRACKS = "tsmuxer_mux_all_audiotracks";
private static final String KEY_NETWORK_INTERFACE = "network_interface";
- private static final String KEY_HIDE_EXTENSIONS = "hide_extensions";
- private static final String KEY_HIDE_ENGINENAMES = "hide_enginenames";
- private static final String KEY_SHARES = "shares";
private static final String KEY_NOTRANSCODE = "notranscode";
- private static final String KEY_FORCETRANSCODE = "forcetranscode";
- private static final String KEY_MENCODER_MT = "mencoder_mt";
- private static final String KEY_MENCODER_REMUX_AC3 = "mencoder_remux_ac3";
- private static final String KEY_MENCODER_REMUX_MPEG2 = "mencoder_remux_mpeg2";
+ private static final String KEY_NUMBER_OF_CPU_CORES = "nbcores";
+ private static final String KEY_OPEN_ARCHIVES = "enable_archive_browsing";
private static final String KEY_OVERSCAN = "mencoder_overscan";
- private static final String KEY_DISABLE_FAKESIZE = "disable_fakesize";
- private static final String KEY_MENCODER_ASS_DEFAULTSTYLE = "mencoder_ass_defaultstyle";
- private static final String KEY_SORT_METHOD = "key_sort_method";
- private static final String KEY_AUDIO_THUMBNAILS_METHOD = "audio_thumbnails_method";
- private static final String KEY_ALTERNATE_THUMB_FOLDER = "alternate_thumb_folder";
- private static final String KEY_EMBED_DTS_IN_PCM = "embed_dts_in_pcm";
- private static final String KEY_MENCODER_MUX_COMPATIBLE = "mencoder_mux_compatible";
- private static final String KEY_ALTERNATE_SUBS_FOLDER = "alternate_subs_folder";
- private static final String KEY_MUX_ALLAUDIOTRACKS = "tsmuxer_mux_all_audiotracks";
- private static final String KEY_USE_MPLAYER_FOR_THUMBS = "use_mplayer_for_video_thumbs";
- private static final String KEY_IP_FILTER = "ip_filter";
+ private static final String KEY_PLUGIN_DIRECTORY = "plugins";
private static final String KEY_PREVENTS_SLEEP = "prevents_sleep_mode";
- private static final String KEY_HTTP_ENGINE_V2 = "http_engine_v2";
- private static final String KEY_IPHOTO_ENABLED = "iphoto";
- private static final String KEY_ITUNES_ENABLED = "itunes";
- private static final String KEY_HIDE_EMPTY_FOLDERS = "hide_empty_folders";
- private static final String KEY_HIDE_MEDIA_LIBRARY_FOLDER = "hide_media_library_folder";
- private static final String KEY_HIDE_TRANSCODE_FOLDER = "hide_transcode_folder";
- private static final String KEY_DVDISO_THUMBNAILS = "dvd_isos_thumbnails";
- private static final String KEY_CHAPTER_SUPPORT = "chapter_support";
- private static final String KEY_CHAPTER_INTERVAL = "chapter_interval";
+ private static final String KEY_PROFILE_NAME = "name";
+ private static final String KEY_PROXY_SERVER_PORT = "proxy";
+ private static final String KEY_SERVER_HOSTNAME = "hostname";
+ private static final String KEY_SERVER_PORT = "port";
+ private static final String KEY_SHARES = "shares";
+ private static final String KEY_SKIP_LOOP_FILTER_ENABLED = "skiploopfilter";
+ private static final String KEY_SORT_METHOD = "key_sort_method";
private static final String KEY_SUBS_COLOR = "subs_color";
- private static final String KEY_FIX_25FPS_AV_MISMATCH = "fix_25fps_av_mismatch";
+ private static final String KEY_TEMP_FOLDER_PATH = "temp";
+ private static final String KEY_THUMBNAIL_SEEK_POS = "thumbnail_seek_pos";
+ private static final String KEY_THUMBNAILS_ENABLED = "thumbnails";
+ private static final String KEY_TRANSCODE_BLOCKS_MULTIPLE_CONNECTIONS = "transcode_block_multiple_connections";
+ private static final String KEY_TRANSCODE_KEEP_FIRST_CONNECTION = "transcode_keep_first_connection";
+ private static final String KEY_TSMUXER_FORCEFPS = "tsmuxer_forcefps";
+ private static final String KEY_TSMUXER_PREREMIX_AC3 = "tsmuxer_preremix_ac3";
+ // private static final String KEY_TSMUXER_PREREMUX_PCM = "tsmuxer_preremux_pcm";
+ private static final String KEY_TURBO_MODE_ENABLED = "turbomode";
+ private static final String KEY_USE_CACHE = "usecache";
+ private static final String KEY_USE_MPLAYER_FOR_THUMBS = "use_mplayer_for_video_thumbs";
+ private static final String KEY_USE_SUBTITLES = "autoloadsrt";
private static final String KEY_VIDEOTRANSCODE_START_DELAY = "key_videotranscode_start_delay";
- private static final String KEY_AUDIO_RESAMPLE = "audio_resample";
- private static final int DEFAULT_SERVER_PORT = 5001;
- private static final int DEFAULT_PROXY_SERVER_PORT = -1;
- private static final String UNLIMITED_BITRATE = "0";
private static final String KEY_VIRTUAL_FOLDERS = "vfolders";
- private static final String KEY_PLUGIN_DIRECTORY = "plugins";
- private static final String KEY_PROFILE_NAME = "name";
+ private static final String UNLIMITED_BITRATE = "0";
/*
* the name of the subdirectory under which PMS config files are stored for this build.
@@ -339,7 +343,11 @@ public String getMencoderAlternatePath() {
public String getMencoderAlternateMTPath() {
return programPaths.getMencoderAlternateMTPath();
}
-
+
+ public int getMaxMencoderThreads() {
+ return Math.min(getInt(KEY_MENCODER_MAX_THREADS, getNumberOfCpuCores()), MENCODER_MAX_THREADS);
+ }
+
public String getDCRawPath() {
return programPaths.getDCRaw();
}
@@ -515,6 +523,7 @@ public void setMencoderNoAssOutline(String value) {
configuration.setProperty(KEY_MENCODER_NOASS_OUTLINE, value);
}
+ // FIXME currently unused
public void setMencoderAc3Fixed(boolean value) {
configuration.setProperty(KEY_MENCODER_AC3_FIXED, value);
}
@@ -547,6 +556,11 @@ public void setMencoderNoAssSubPos(String value) {
configuration.setProperty(KEY_MENCODER_NOASS_SUBPOS, value);
}
+ // FIXME currently unused
+ public void setMaxMencoderThreads(int value) {
+ configuration.setProperty(KEY_MENCODER_MAX_THREADS, value);
+ }
+
public void setLanguage(String value) {
configuration.setProperty(KEY_LANGUAGE, value);
Locale.setDefault(new Locale(getLanguage()));
View
172 ps3mediaserver/net/pms/encoders/MEncoderVideo.java
@@ -88,10 +88,6 @@
import com.sun.jna.Platform;
public class MEncoderVideo extends Player {
-
- public JCheckBox getCheckBox() {
- return checkBox;
- }
private JTextField mencoder_ass_scale;
private JTextField mencoder_ass_margin;
private JTextField mencoder_ass_outline;
@@ -122,17 +118,59 @@ public JCheckBox getCheckBox() {
private JCheckBox intelligentsync;
private JTextField alternateSubFolder;
private JButton subColor;
+ private JCheckBox subs;
+ private JCheckBox fribidi;
+ private final PmsConfiguration configuration;
+ public static final int MENCODER_MAX_THREADS = 8;
+ protected boolean dts;
+ public static final String ID = "mencoder"; //$NON-NLS-1$
+ protected boolean pcm;
+ protected boolean mux;
+ protected boolean ovccopy;
+ protected boolean dvd;
+ protected boolean oaccopy;
+ protected boolean mpegts;
+ protected boolean wmv;
+ protected String overridenMainArgs[];
+ //protected String defaultSubArgs [];
+
+ public static final String DEFAULT_CODEC_CONF_SCRIPT =
+ Messages.getString("MEncoderVideo.68") //$NON-NLS-1$
+ + Messages.getString("MEncoderVideo.69") //$NON-NLS-1$
+ + Messages.getString("MEncoderVideo.70") //$NON-NLS-1$
+ + Messages.getString("MEncoderVideo.71") //$NON-NLS-1$
+ + Messages.getString("MEncoderVideo.72") //$NON-NLS-1$
+ + Messages.getString("MEncoderVideo.73") //$NON-NLS-1$
+ + Messages.getString("MEncoderVideo.75") //$NON-NLS-1$
+ + Messages.getString("MEncoderVideo.76") //$NON-NLS-1$
+ + Messages.getString("MEncoderVideo.77") //$NON-NLS-1$
+ + Messages.getString("MEncoderVideo.78") //$NON-NLS-1$
+ + Messages.getString("MEncoderVideo.79") //$NON-NLS-1$
+ + "#\n" //$NON-NLS-1$
+ + Messages.getString("MEncoderVideo.80") //$NON-NLS-1$
+ + "container == iso :: -nosync\n" //$NON-NLS-1$
+ + "(container == avi || container == matroska) && vcodec == mpeg4 && acodec == mp3 :: -mc 0.1\n" //$NON-NLS-1$
+ + "container == flv :: -mc 0.1\n" //$NON-NLS-1$
+ + "container == mov :: -mc 0.1 -noass\n" //$NON-NLS-1$
+ + "container == rm :: -mc 0.1\n" //$NON-NLS-1$
+ + "container == matroska && framerate == 29.97 :: -nomux -mc 0\n" //$NON-NLS-1$
+ + "\n" //$NON-NLS-1$
+ + Messages.getString("MEncoderVideo.87") //$NON-NLS-1$
+ + Messages.getString("MEncoderVideo.88") //$NON-NLS-1$
+ + Messages.getString("MEncoderVideo.89") //$NON-NLS-1$
+ + Messages.getString("MEncoderVideo.91"); //$NON-NLS-1$
+
+ public JCheckBox getCheckBox() {
+ return checkBox;
+ }
public JCheckBox getNoskip() {
return noskip;
}
- private JCheckBox subs;
public JCheckBox getSubs() {
return subs;
}
- private JCheckBox fribidi;
- private final PmsConfiguration configuration;
public MEncoderVideo(PmsConfiguration configuration) {
this.configuration = configuration;
@@ -151,13 +189,13 @@ public JComponent config() {
checkBox = new JCheckBox(Messages.getString("MEncoderVideo.0")); //$NON-NLS-1$
checkBox.setContentAreaFilled(false);
- if (PMS.getConfiguration().getSkipLoopFilterEnabled()) {
+ if (configuration.getSkipLoopFilterEnabled()) {
checkBox.setSelected(true);
}
checkBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
- PMS.getConfiguration().setSkipLoopFilterEnabled((e.getStateChange() == ItemEvent.SELECTED));
+ configuration.setSkipLoopFilterEnabled((e.getStateChange() == ItemEvent.SELECTED));
}
});
@@ -168,14 +206,14 @@ public void itemStateChanged(ItemEvent e) {
mencodermt = new JCheckBox(Messages.getString("MEncoderVideo.35")); //$NON-NLS-1$
mencodermt.setFont(mencodermt.getFont().deriveFont(Font.BOLD));
mencodermt.setContentAreaFilled(false);
- if (PMS.getConfiguration().getMencoderMT()) {
+ if (configuration.getMencoderMT()) {
mencodermt.setSelected(true);
}
mencodermt.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- PMS.getConfiguration().setMencoderMT(mencodermt.isSelected());
- if (PMS.getConfiguration().getMencoderMT()) {
+ configuration.setMencoderMT(mencodermt.isSelected());
+ if (configuration.getMencoderMT()) {
JOptionPane.showMessageDialog(
(JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())),
Messages.getString("MEncoderVideo.31"), //$NON-NLS-1$
@@ -191,13 +229,13 @@ public void actionPerformed(ActionEvent e) {
noskip = new JCheckBox(Messages.getString("MEncoderVideo.2")); //$NON-NLS-1$
noskip.setContentAreaFilled(false);
- if (PMS.getConfiguration().isMencoderNoOutOfSync()) {
+ if (configuration.isMencoderNoOutOfSync()) {
noskip.setSelected(true);
}
noskip.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
- PMS.getConfiguration().setMencoderNoOutOfSync((e.getStateChange() == ItemEvent.SELECTED));
+ configuration.setMencoderNoOutOfSync((e.getStateChange() == ItemEvent.SELECTED));
}
});
@@ -209,7 +247,7 @@ public void itemStateChanged(ItemEvent e) {
public void actionPerformed(ActionEvent e) {
JPanel codecPanel = new JPanel(new BorderLayout());
final JTextArea textArea = new JTextArea();
- textArea.setText(PMS.getConfiguration().getCodecSpecificConfig());
+ textArea.setText(configuration.getCodecSpecificConfig());
textArea.setFont(new Font("Courier", Font.PLAIN, 12)); //$NON-NLS-1$
JScrollPane scrollPane = new JScrollPane(textArea);
scrollPane.setPreferredSize(new java.awt.Dimension(900, 100));
@@ -219,21 +257,21 @@ public void actionPerformed(ActionEvent e) {
textAreaDefault.setBackground(Color.WHITE);
textAreaDefault.setFont(new Font("Courier", Font.PLAIN, 12)); //$NON-NLS-1$
textAreaDefault.setEditable(false);
- textAreaDefault.setEnabled(PMS.getConfiguration().isMencoderIntelligentSync());
+ textAreaDefault.setEnabled(configuration.isMencoderIntelligentSync());
JScrollPane scrollPaneDefault = new JScrollPane(textAreaDefault);
scrollPaneDefault.setPreferredSize(new java.awt.Dimension(900, 450));
JPanel customPanel = new JPanel(new BorderLayout());
intelligentsync = new JCheckBox(Messages.getString("MEncoderVideo.3")); //$NON-NLS-1$
intelligentsync.setContentAreaFilled(false);
- if (PMS.getConfiguration().isMencoderIntelligentSync()) {
+ if (configuration.isMencoderIntelligentSync()) {
intelligentsync.setSelected(true);
}
intelligentsync.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
- PMS.getConfiguration().setMencoderIntelligentSync((e.getStateChange() == ItemEvent.SELECTED));
- textAreaDefault.setEnabled(PMS.getConfiguration().isMencoderIntelligentSync());
+ configuration.setMencoderIntelligentSync((e.getStateChange() == ItemEvent.SELECTED));
+ textAreaDefault.setEnabled(configuration.isMencoderIntelligentSync());
}
});
@@ -372,13 +410,13 @@ public void keyReleased(KeyEvent e) {
videoremux = new JCheckBox("<html>" + Messages.getString("MEncoderVideo.38") + "</html>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
videoremux.setContentAreaFilled(false);
videoremux.setFont(videoremux.getFont().deriveFont(Font.BOLD));
- if (PMS.getConfiguration().isMencoderMuxWhenCompatible()) {
+ if (configuration.isMencoderMuxWhenCompatible()) {
videoremux.setSelected(true);
}
videoremux.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
- PMS.getConfiguration().setMencoderMuxWhenCompatible((e.getStateChange() == ItemEvent.SELECTED));
+ configuration.setMencoderMuxWhenCompatible((e.getStateChange() == ItemEvent.SELECTED));
}
});
@@ -814,13 +852,13 @@ public void itemStateChanged(ItemEvent e) {
subs = new JCheckBox(Messages.getString("MEncoderVideo.22")); //$NON-NLS-1$
subs.setContentAreaFilled(false);
- if (PMS.getConfiguration().getUseSubtitles()) {
+ if (configuration.getUseSubtitles()) {
subs.setSelected(true);
}
subs.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
- PMS.getConfiguration().setUseSubtitles((e.getStateChange() == ItemEvent.SELECTED));
+ configuration.setUseSubtitles((e.getStateChange() == ItemEvent.SELECTED));
}
});
builder.add(subs, cc.xyw(1, 43, 15));
@@ -909,7 +947,6 @@ public void itemStateChanged(ItemEvent e) {
public int purpose() {
return VIDEO_SIMPLEFILE_PLAYER;
}
- public static final String ID = "mencoder"; //$NON-NLS-1$
@Override
public String id() {
@@ -925,17 +962,6 @@ public boolean avisynth() {
public boolean isTimeSeekable() {
return true;
}
- protected boolean dts;
- protected boolean pcm;
- protected boolean mux;
- protected boolean ovccopy;
- protected boolean dvd;
- protected boolean oaccopy;
- protected boolean mpegts;
- protected boolean wmv;
- protected String overridenMainArgs[];
- //protected String defaultSubArgs [];
-
protected String[] getDefaultArgs() {
return new String[]{"-quiet", "-oac", oaccopy ? "copy" : (pcm ? "pcm" : "lavc"), "-of", (wmv || mpegts) ? "lavf" : (pcm && avisynth()) ? "avi" : (((pcm || dts || mux) ? "rawvideo" : "mpeg")), (wmv || mpegts) ? "-lavfopts" : "-quiet", wmv ? "format=asf" : (mpegts ? "format=mpegts" : "-quiet"), "-mpegopts", "format=mpeg2:muxrate=500000:vbuf_size=1194:abuf_size=64", "-ovc", (mux || ovccopy) ? "copy" : "lavc"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ //$NON-NLS-14$ //$NON-NLS-15$ //$NON-NLS-16$ //$NON-NLS-17$ //$NON-NLS-18$
}
@@ -988,7 +1014,7 @@ public String executable() {
}
private String addMaximumBitrateConstraints(String encodeSettings, DLNAMediaInfo media, String quality, RendererConfiguration mediaRenderer) {
- int defaultMaxBitrates[] = getVideoBitrateConfig(PMS.getConfiguration().getMaximumBitrate());
+ int defaultMaxBitrates[] = getVideoBitrateConfig(configuration.getMaximumBitrate());
int rendererMaxBitrates[] = new int[2];
if (mediaRenderer.getMaxVideoBitrate() != null) {
rendererMaxBitrates = getVideoBitrateConfig(mediaRenderer.getMaxVideoBitrate());
@@ -1055,7 +1081,7 @@ public ProcessWrapper launchTranscode(
// don't honour "Switch to tsMuxeR..." if the resource is being streamed via an MEncoder entry in
// the #--TRANSCODE--# folder
- boolean forceMencoder = !PMS.getConfiguration().getHideTranscodeEnabled()
+ boolean forceMencoder = !configuration.getHideTranscodeEnabled()
&& dlna.noName
&& (dlna.getParent() instanceof FileTranscodeVirtualFolder);
@@ -1074,7 +1100,7 @@ public ProcessWrapper launchTranscode(
configuration.isMencoderMuxWhenCompatible() &&
params.mediaRenderer.isMuxH264MpegTS()
) {
- String sArgs[] = getSpecificCodecOptions(PMS.getConfiguration().getCodecSpecificConfig(), media, params, fileName, subString, PMS.getConfiguration().isMencoderIntelligentSync(), false);
+ String sArgs[] = getSpecificCodecOptions(configuration.getCodecSpecificConfig(), media, params, fileName, subString, configuration.isMencoderIntelligentSync(), false);
boolean nomux = false;
for (String s : sArgs) {
if (s.equals("-nomux")) {
@@ -1094,7 +1120,7 @@ public ProcessWrapper launchTranscode(
return tv.launchTranscode(fileName, media, params);
}
} else if (params.sid == null && dvd && configuration.isMencoderRemuxMPEG2() && params.mediaRenderer.isMpeg2Supported()) {
- String sArgs[] = getSpecificCodecOptions(PMS.getConfiguration().getCodecSpecificConfig(), media, params, fileName, subString, PMS.getConfiguration().isMencoderIntelligentSync(), false);
+ String sArgs[] = getSpecificCodecOptions(configuration.getCodecSpecificConfig(), media, params, fileName, subString, configuration.isMencoderIntelligentSync(), false);
boolean nomux = false;
for (String s : sArgs) {
if (s.equals("-nomux")) {
@@ -1153,7 +1179,7 @@ public ProcessWrapper launchTranscode(
if (dvd) {
alternativeCodec = ""; //$NON-NLS-1$
}
- int channels = wmv ? 2 : PMS.getConfiguration().getAudioChannelCount();
+ int channels = wmv ? 2 : configuration.getAudioChannelCount();
if (media != null && params.aid != null) {
channels = wmv ? 2 : CodecUtil.getRealChannelCount(configuration, params.aid);
}
@@ -1162,28 +1188,26 @@ public ProcessWrapper launchTranscode(
StringTokenizer st = new StringTokenizer(alternativeCodec + "-channels " + channels + " " + configuration.getMencoderDecode() + add, " "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
overridenMainArgs = new String[st.countTokens()];
int i = 0;
- boolean next = false;
+ boolean processToken = false;
+ int nThreads = (dvd || fileName.toLowerCase().endsWith("dvr-ms")) ? //$NON-NLS-1$
+ 1 : configuration.getMaxMencoderThreads();
+
while (st.hasMoreTokens()) {
String token = st.nextToken().trim();
- if (next) {
- int nbcores = configuration.getNumberOfCpuCores();
- if (dvd || fileName.toLowerCase().endsWith("dvr-ms")) //$NON-NLS-1$
- {
- nbcores = 1;
- }
- token += ":threads=" + nbcores; //$NON-NLS-1$
+ if (processToken) {
+ token += ":threads=" + nThreads; //$NON-NLS-1$
if (configuration.getSkipLoopFilterEnabled() && !avisynth()) {
token += ":skiploopfilter=all"; //$NON-NLS-1$
}
- next = false;
+ processToken = false;
}
if (token.toLowerCase().contains("lavdopts")) { //$NON-NLS-1$
- next = true;
+ processToken = true;
}
overridenMainArgs[i++] = token;
}
- //}
+
if (configuration.getMencoderMainSettings() != null) {
String mainConfig = configuration.getMencoderMainSettings();
if (params.mediaRenderer.getCustomMencoderQualitySettings() != null) {
@@ -1200,7 +1224,7 @@ public ProcessWrapper launchTranscode(
String encodeSettings = "-lavcopts autoaspect=1:vcodec=" + vcodec + //$NON-NLS-1$
(wmv ? ":acodec=wmav2:abitrate=256" : (cbr_settings + ":acodec=" + (configuration.isMencoderAc3Fixed() ? "ac3_fixed" : "ac3") + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
":abitrate=" + CodecUtil.getAC3Bitrate(configuration, params.aid))) + //$NON-NLS-1$
- ":threads=" + (wmv ? 1 : configuration.getNumberOfCpuCores()) + ":" + mainConfig; //$NON-NLS-1$ //$NON-NLS-2$
+ ":threads=" + (wmv ? 1 : configuration.getMaxMencoderThreads()) + ":" + mainConfig; //$NON-NLS-1$ //$NON-NLS-2$
encodeSettings = addMaximumBitrateConstraints(encodeSettings, media, mainConfig, params.mediaRenderer);
st = new StringTokenizer(encodeSettings, " "); //$NON-NLS-1$
@@ -1286,17 +1310,16 @@ public ProcessWrapper launchTranscode(
int oldc = overridenMainArgs.length;
overridenMainArgs = Arrays.copyOf(overridenMainArgs, overridenMainArgs.length + st.countTokens());
i = oldc;
- next = false;
+ processToken = false;
while (st.hasMoreTokens()) {
String s = st.nextToken();
- if (next) {
+ if (processToken) {
s = "-quiet"; //$NON-NLS-1$
- next = false;
+ processToken = false;
}
if ((!configuration.isMencoderAss() || dvd) && s.contains("-ass")) { //$NON-NLS-1$
s = "-quiet"; //$NON-NLS-1$
-
- next = true;
+ processToken = true;
}
overridenMainArgs[i++] = s;
}
@@ -1313,7 +1336,7 @@ public ProcessWrapper launchTranscode(
(media.muxingMode != null && media.muxingMode.equals("Header stripping")) ||
(params.sid != null && params.sid.type == DLNAMediaSubtitle.VOBSUB)
) {
- // Use the newer version of MEncoder
+ // Use the newer version of MEncoder
if (isMultiCore && configuration.getMencoderMT()) {
if (new File(configuration.getMencoderAlternateMTPath()).exists()) {
cmdArray[0] = configuration.getMencoderAlternateMTPath();
@@ -1324,7 +1347,7 @@ public ProcessWrapper launchTranscode(
}
}
} else if (isMultiCore && configuration.getMencoderMT()) {
- // Use the older MEncoder with multithreading
+ // Use the older MEncoder with multithreading
if (new File(configuration.getMencoderMTPath()).exists()) {
cmdArray[0] = configuration.getMencoderMTPath();
}
@@ -1465,7 +1488,7 @@ public ProcessWrapper launchTranscode(
boolean noMC0NoSkip = false;
if (media != null) {
- String sArgs[] = getSpecificCodecOptions(PMS.getConfiguration().getCodecSpecificConfig(), media, params, fileName, subString, PMS.getConfiguration().isMencoderIntelligentSync(), false);
+ String sArgs[] = getSpecificCodecOptions(configuration.getCodecSpecificConfig(), media, params, fileName, subString, configuration.isMencoderIntelligentSync(), false);
if (sArgs != null && sArgs.length > 0) {
boolean vfConsumed = false;
boolean afConsumed = false;
@@ -1523,7 +1546,7 @@ public ProcessWrapper launchTranscode(
cmdArray[c + 1] = "autoaspect=1:vcodec=" + vcodec + //$NON-NLS-1$
":acodec=" + (configuration.isMencoderAc3Fixed() ? "ac3_fixed" : "ac3") + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
":abitrate=" + CodecUtil.getAC3Bitrate(configuration, params.aid) + //$NON-NLS-1$
- ":threads=" + configuration.getNumberOfCpuCores() + ":" + sArgs[s + 1]; //$NON-NLS-1$ //$NON-NLS-2$
+ ":threads=" + configuration.getMaxMencoderThreads() + ":" + sArgs[s + 1]; //$NON-NLS-1$ //$NON-NLS-2$
addMaximumBitrateConstraints(cmdArray[c + 1], media, cmdArray[c + 1], params.mediaRenderer);
sArgs[s + 1] = "-quality"; //$NON-NLS-1$
s++;
@@ -1572,7 +1595,7 @@ public ProcessWrapper launchTranscode(
}
}
- if ((pcm || dts || mux) || (PMS.getConfiguration().isMencoderNoOutOfSync() && !noMC0NoSkip)) {
+ if ((pcm || dts || mux) || (configuration.isMencoderNoOutOfSync() && !noMC0NoSkip)) {
cmdArray = Arrays.copyOf(cmdArray, cmdArray.length + 3);
cmdArray[cmdArray.length - 5] = "-mc"; //$NON-NLS-1$
cmdArray[cmdArray.length - 4] = "0"; //$NON-NLS-1$
@@ -1956,29 +1979,4 @@ public int type() {
args.toArray(definitiveArgs);
return definitiveArgs;
}
- public static final String DEFAULT_CODEC_CONF_SCRIPT =
- Messages.getString("MEncoderVideo.68") //$NON-NLS-1$
- + Messages.getString("MEncoderVideo.69") //$NON-NLS-1$
- + Messages.getString("MEncoderVideo.70") //$NON-NLS-1$
- + Messages.getString("MEncoderVideo.71") //$NON-NLS-1$
- + Messages.getString("MEncoderVideo.72") //$NON-NLS-1$
- + Messages.getString("MEncoderVideo.73") //$NON-NLS-1$
- + Messages.getString("MEncoderVideo.75") //$NON-NLS-1$
- + Messages.getString("MEncoderVideo.76") //$NON-NLS-1$
- + Messages.getString("MEncoderVideo.77") //$NON-NLS-1$
- + Messages.getString("MEncoderVideo.78") //$NON-NLS-1$
- + Messages.getString("MEncoderVideo.79") //$NON-NLS-1$
- + "#\n" //$NON-NLS-1$
- + Messages.getString("MEncoderVideo.80") //$NON-NLS-1$
- + "container == iso :: -nosync\n" //$NON-NLS-1$
- + "(container == avi || container == matroska) && vcodec == mpeg4 && acodec == mp3 :: -mc 0.1\n" //$NON-NLS-1$
- + "container == flv :: -mc 0.1\n" //$NON-NLS-1$
- + "container == mov :: -mc 0.1 -noass\n" //$NON-NLS-1$
- + "container == rm :: -mc 0.1\n" //$NON-NLS-1$
- + "container == matroska && framerate == 29.97 :: -nomux -mc 0\n" //$NON-NLS-1$
- + "\n" //$NON-NLS-1$
- + Messages.getString("MEncoderVideo.87") //$NON-NLS-1$
- + Messages.getString("MEncoderVideo.88") //$NON-NLS-1$
- + Messages.getString("MEncoderVideo.89") //$NON-NLS-1$
- + Messages.getString("MEncoderVideo.91"); //$NON-NLS-1$
}
View
4 ps3mediaserver/net/pms/encoders/MEncoderWebVideo.java
@@ -29,6 +29,7 @@
import net.pms.io.PipeProcess;
import net.pms.io.ProcessWrapper;
import net.pms.io.ProcessWrapperImpl;
+import net.pms.PMS;
public class MEncoderWebVideo extends Player {
@@ -60,10 +61,11 @@ public String mimeType() {
}
protected String[] getDefaultArgs() {
+ int nThreads = PMS.getConfiguration().getMaxMencoderThreads();
return new String [] { "-prefer-ipv4", "-nocache", "-quiet", "-oac", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"lavc", "-of", "lavf", "-lavfopts", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"format=dvd", "-ovc", "lavc", "-lavcopts", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- "vcodec=mpeg2video:vbitrate=4096:threads=2:acodec=" + (configuration.isMencoderAc3Fixed() ? "ac3_fixed" : "ac3") + ":abitrate=128", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ "vcodec=mpeg2video:vbitrate=4096:threads=" + nThreads + ":acodec=" + (configuration.isMencoderAc3Fixed() ? "ac3_fixed" : "ac3") + ":abitrate=128", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"-vf", "harddup", "-ofps", "24000/1001" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
Please sign in to comment.
Something went wrong with that request. Please try again.