The output file can now be specified in GuiRenderSettings
This commit is contained in:
@@ -82,6 +82,7 @@ public class GuiConstants {
|
||||
public static final int RENDER_SETTINGS_ADVANCED_BUTTON = 9013;
|
||||
public static final int RENDER_SETTINGS_COLOR_PICKER = 9014;
|
||||
public static final int RENDER_SETTINGS_ENABLE_GREENSCREEN = 9015;
|
||||
public static final int RENDER_SETTINGS_OUTPUT_CHOOSER = 9016;
|
||||
|
||||
public static final int REPLAY_SETTINGS_RECORDSERVER_ID = 9004;
|
||||
public static final int REPLAY_SETTINGS_RECORDSP_ID = 9005;
|
||||
|
||||
@@ -155,7 +155,7 @@ public class GuiObjectManager extends GuiScreen {
|
||||
|
||||
Position defaultPosition = new Position(mc.getRenderViewEntity().getPosition());
|
||||
customImageObject.getTransformations().setDefaultPosition(defaultPosition);
|
||||
|
||||
|
||||
objectList.addElement(customImageObject);
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -6,6 +6,8 @@ import eu.crushedpixel.replaymod.gui.elements.listeners.SelectionListener;
|
||||
import eu.crushedpixel.replaymod.holders.GuiEntryListEntry;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import eu.crushedpixel.replaymod.settings.RenderOptions;
|
||||
import eu.crushedpixel.replaymod.utils.MouseUtils;
|
||||
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
||||
import eu.crushedpixel.replaymod.utils.StringUtils;
|
||||
import eu.crushedpixel.replaymod.video.frame.*;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -16,13 +18,23 @@ import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import net.minecraftforge.fml.client.config.GuiCheckBox;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.util.Point;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiRenderSettings extends GuiScreen {
|
||||
|
||||
//for default file
|
||||
private static final String DATE_FORMAT = "yyyy_MM_dd_HH_mm_ss";
|
||||
private static final SimpleDateFormat FILE_FORMAT = new SimpleDateFormat(DATE_FORMAT);
|
||||
private static final String WEBM_EXTENSION = ".webm";
|
||||
|
||||
private static final int LEFT_BORDER = 10;
|
||||
|
||||
private GuiButton renderButton, cancelButton, advancedButton;
|
||||
@@ -37,6 +49,7 @@ public class GuiRenderSettings extends GuiScreen {
|
||||
private GuiNumberInput bitrateInput;
|
||||
private GuiColorPicker colorPicker;
|
||||
private GuiAdvancedTextField commandInput, ffmpegArguments;
|
||||
private GuiFileChooser outputFileChooser;
|
||||
|
||||
private List<GuiButton> permanentButtons = new ArrayList<GuiButton>();
|
||||
private List<GuiButton> defaultButtons = new ArrayList<GuiButton>();
|
||||
@@ -115,6 +128,15 @@ public class GuiRenderSettings extends GuiScreen {
|
||||
framerateSlider = new GuiVideoFramerateSlider(GuiConstants.RENDER_SETTINGS_FRAMERATE_SLIDER, 0, 0, ReplayMod.replaySettings.getVideoFramerate(),
|
||||
I18n.format("replaymod.gui.rendersettings.framerate"));
|
||||
|
||||
File defaultFile = null;
|
||||
try {
|
||||
defaultFile = new File(ReplayFileIO.getRenderFolder(), FILE_FORMAT.format(Calendar.getInstance().getTime())+WEBM_EXTENSION);
|
||||
} catch(IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
|
||||
outputFileChooser = new GuiFileChooser(GuiConstants.RENDER_SETTINGS_OUTPUT_CHOOSER, 0, 0, I18n.format("replaymod.gui.rendersettings.outputfile")+": ", defaultFile, new String[]{"webm"}, true);
|
||||
|
||||
interpolation = new GuiToggleButton(GuiConstants.RENDER_SETTINGS_INTERPOLATION_BUTTON, 0, 0,
|
||||
I18n.format("replaymod.gui.rendersettings.interpolation")+": ",
|
||||
new String[]{I18n.format("replaymod.gui.settings.interpolation.cubic"),
|
||||
@@ -153,6 +175,7 @@ public class GuiRenderSettings extends GuiScreen {
|
||||
defaultButtons.add(customResolution);
|
||||
defaultButtons.add(framerateSlider);
|
||||
defaultButtons.add(ignoreCamDir);
|
||||
defaultButtons.add(outputFileChooser);
|
||||
|
||||
advancedButtons.add(interpolation);
|
||||
advancedButtons.add(forceChunks);
|
||||
@@ -197,13 +220,16 @@ public class GuiRenderSettings extends GuiScreen {
|
||||
bitrateInput.xPosition = forceChunks.xPosition + bsw;
|
||||
bitrateInput.width = forceChunks.width - bsw;
|
||||
|
||||
framerateSlider.xPosition = interpolation.xPosition;
|
||||
framerateSlider.yPosition = bitrateInput.yPosition = interpolation.yPosition + 20 + 10;
|
||||
framerateSlider.xPosition = outputFileChooser.xPosition = interpolation.xPosition;
|
||||
framerateSlider.yPosition = bitrateInput.yPosition = xRes.yPosition + 20 + 10;
|
||||
|
||||
ignoreCamDir.xPosition = framerateSlider.xPosition + (framerateSlider.width - ignoreCamDir.width)/2;
|
||||
|
||||
ignoreCamDir.yPosition = framerateSlider.yPosition+20+10;
|
||||
|
||||
outputFileChooser.yPosition = framerateSlider.yPosition+20+10;
|
||||
outputFileChooser.width = 312;
|
||||
|
||||
//align all advanced buttons
|
||||
|
||||
int i = 0;
|
||||
@@ -373,6 +399,9 @@ public class GuiRenderSettings extends GuiScreen {
|
||||
boolean enabled = customResolution.isChecked();
|
||||
xRes.setEnabled(enabled);
|
||||
yRes.setEnabled(enabled);
|
||||
} else if(button.id == GuiConstants.RENDER_SETTINGS_OUTPUT_CHOOSER) {
|
||||
Point mouse = MouseUtils.getMousePos();
|
||||
outputFileChooser.mouseClick(mc, mouse.getX(), mouse.getY(), 0);
|
||||
}
|
||||
|
||||
} else if(advancedButtons.contains(button) && advancedTab) {
|
||||
@@ -436,6 +465,8 @@ public class GuiRenderSettings extends GuiScreen {
|
||||
|
||||
options.setBitrate(bitrateInput.getIntValue() + "K"); //Bitrate value is in Kilobytes
|
||||
|
||||
options.setOutputFile(outputFileChooser.getSelectedFile());
|
||||
|
||||
if(enableGreenscreen.isChecked()) {
|
||||
options.setSkyColor(colorPicker.getPickedColor());
|
||||
}
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
package eu.crushedpixel.replaymod.settings;
|
||||
|
||||
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
||||
import eu.crushedpixel.replaymod.video.frame.FrameRenderer;
|
||||
import lombok.Data;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import static org.apache.commons.lang3.Validate.*;
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
import static org.apache.commons.lang3.Validate.isTrue;
|
||||
import static org.apache.commons.lang3.Validate.notNull;
|
||||
|
||||
@Data
|
||||
public final class RenderOptions {
|
||||
@@ -12,6 +18,8 @@ public final class RenderOptions {
|
||||
private String bitrate = "10M";
|
||||
private int fps = 30;
|
||||
|
||||
private File outputFile;
|
||||
|
||||
// Advanced
|
||||
private boolean waitForChunks = true;
|
||||
private boolean isLinearMovement = false;
|
||||
@@ -23,7 +31,7 @@ public final class RenderOptions {
|
||||
private String exportCommand = "ffmpeg";
|
||||
private String exportCommandArgs = "-f rawvideo -pix_fmt argb -s %WIDTH%x%HEIGHT% -r %FPS% -i - " +
|
||||
"-an " +
|
||||
"-c:v libvpx -b:v %BITRATE% %FILENAME%.webm";
|
||||
"-c:v libvpx -b:v %BITRATE% %FILENAME%";
|
||||
private int writerQueueSize = Integer.parseInt(System.getProperty("replaymod.render.writerQueueSize", "1"));
|
||||
|
||||
public void setRenderer(FrameRenderer renderer) {
|
||||
|
||||
@@ -2,7 +2,6 @@ package eu.crushedpixel.replaymod.video;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import eu.crushedpixel.replaymod.settings.RenderOptions;
|
||||
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
||||
import eu.crushedpixel.replaymod.utils.StreamPipe;
|
||||
import eu.crushedpixel.replaymod.utils.StringUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -21,8 +20,10 @@ import java.io.OutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.WritableByteChannel;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.locks.Condition;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
@@ -31,9 +32,6 @@ import static org.apache.commons.lang3.Validate.isTrue;
|
||||
|
||||
public class VideoWriter {
|
||||
|
||||
private static final String DATE_FORMAT = "yyyy_MM_dd_HH_mm_ss";
|
||||
private static final SimpleDateFormat FILE_FORMAT = new SimpleDateFormat(DATE_FORMAT);
|
||||
|
||||
private final RenderOptions options;
|
||||
private final Process process;
|
||||
private final OutputStream outputStream;
|
||||
@@ -56,8 +54,8 @@ public class VideoWriter {
|
||||
this.queueLimit = options.getWriterQueueSize();
|
||||
this.toWrite = new LinkedList<BufferedImage>();
|
||||
|
||||
File folder = ReplayFileIO.getRenderFolder();
|
||||
String fileName = FILE_FORMAT.format(Calendar.getInstance().getTime());
|
||||
File outputFolder = options.getOutputFile().getParentFile();
|
||||
String fileName = options.getOutputFile().getName();
|
||||
|
||||
final String args = options.getExportCommandArgs()
|
||||
.replace("%WIDTH%", String.valueOf(options.getWidth()))
|
||||
@@ -70,7 +68,7 @@ public class VideoWriter {
|
||||
command.add(options.getExportCommand());
|
||||
command.addAll(StringUtils.translateCommandline(args));
|
||||
System.out.println("Starting " + options.getExportCommand() + " with args: " + args);
|
||||
process = new ProcessBuilder(command).directory(folder).start();
|
||||
process = new ProcessBuilder(command).directory(outputFolder).start();
|
||||
OutputStream exportLogOut = new FileOutputStream("export.log");
|
||||
new StreamPipe(process.getInputStream(), exportLogOut).start();
|
||||
new StreamPipe(process.getErrorStream(), exportLogOut).start();
|
||||
|
||||
@@ -310,6 +310,7 @@ replaymod.gui.rendersettings.framerate=Video Framerate
|
||||
replaymod.gui.rendersettings.quality=Video Quality
|
||||
replaymod.gui.rendersettings.chromakey=Chroma Keying
|
||||
replaymod.gui.rendersettings.skycolor=Sky Color
|
||||
replaymod.gui.rendersettings.outputfile=Output File
|
||||
|
||||
replaymod.gui.rendersettings.command=Command
|
||||
replaymod.gui.rendersettings.arguments=Command Line Arguments
|
||||
|
||||
Reference in New Issue
Block a user