Merge pull request #13 from DanielSWolf/feature/output-option
Add --output option
This commit is contained in:
commit
bd5a80e7fd
|
@ -77,8 +77,8 @@ This shape is also used as an in-between when animating from {C} or {D} to {F}.
|
||||||
Rhubarb Lip-Sync is a command-line tool that is currently available for Windows and OS X.
|
Rhubarb Lip-Sync is a command-line tool that is currently available for Windows and OS X.
|
||||||
|
|
||||||
* Download the https://github.com/DanielSWolf/rhubarb-lip-sync/releases[latest release] and unzip the file anywhere on your computer.
|
* Download the https://github.com/DanielSWolf/rhubarb-lip-sync/releases[latest release] and unzip the file anywhere on your computer.
|
||||||
* Call `rhubarb`, passing it a WAVE file as argument, and redirecting the output to a file. In its simplest form, this might look like this: `rhubarb my-recording.wav > output.txt`. There are additional <<options,command-line options>> you can specify in order to get better results.
|
* Call `rhubarb`, passing it a WAVE file as argument and telling it where to create the output file. In its simplest form, this might look like this: `rhubarb -o output.txt my-recording.wav`. There are additional <<options,command-line options>> you can specify in order to get better results.
|
||||||
* Rhubarb Lip-Sync will analyze the sound file and print the result to `stdout`. If you've redirected `stdout` to a file like above, you will now have an XML file containing the lip-sync data. If an error occurs, Rhubarb Lip-Sync will print an error message to `stderr` and exit with a non-zero exit code.
|
* Rhubarb Lip-Sync will analyze the sound file, animate it, and create an output file containing the animation. If an error occurs, Rhubarb Lip-Sync will instead print an error message to `stderr` and exit with a non-zero exit code.
|
||||||
|
|
||||||
[[options]]
|
[[options]]
|
||||||
=== Command-line options ===
|
=== Command-line options ===
|
||||||
|
@ -125,6 +125,9 @@ _Default value: as many threads as your CPU has cores_
|
||||||
|
|
||||||
_Default value: ``debug``_
|
_Default value: ``debug``_
|
||||||
|
|
||||||
|
| `-o`, `--output` _<output file>_
|
||||||
|
| The name of the output file to create. If the file already exists, it will be overwritten. If you don't specify an output file, the result will be written to `stdout`.
|
||||||
|
|
||||||
| `--version`
|
| `--version`
|
||||||
| Displays version information and exits.
|
| Displays version information and exits.
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
# Version history
|
# Version history
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
* Added --output command-line option
|
||||||
|
|
||||||
## Version 1.5.0
|
## Version 1.5.0
|
||||||
|
|
||||||
* Improved animation rules for ER and AW sounds
|
* Improved animation rules for ER and AW sounds
|
||||||
|
|
11
src/main.cpp
11
src/main.cpp
|
@ -23,6 +23,7 @@
|
||||||
#include <boost/iostreams/stream.hpp>
|
#include <boost/iostreams/stream.hpp>
|
||||||
#include <boost/iostreams/device/null.hpp>
|
#include <boost/iostreams/device/null.hpp>
|
||||||
#include "targetShapeSet.h"
|
#include "targetShapeSet.h"
|
||||||
|
#include <boost/utility/in_place_factory.hpp>
|
||||||
|
|
||||||
using std::exception;
|
using std::exception;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
@ -35,8 +36,10 @@ using std::make_shared;
|
||||||
using std::map;
|
using std::map;
|
||||||
using std::chrono::duration;
|
using std::chrono::duration;
|
||||||
using std::chrono::duration_cast;
|
using std::chrono::duration_cast;
|
||||||
|
using std::ofstream;
|
||||||
using boost::filesystem::path;
|
using boost::filesystem::path;
|
||||||
using boost::adaptors::transformed;
|
using boost::adaptors::transformed;
|
||||||
|
using boost::optional;
|
||||||
|
|
||||||
namespace tclap = TCLAP;
|
namespace tclap = TCLAP;
|
||||||
|
|
||||||
|
@ -103,6 +106,7 @@ int main(int argc, char *argv[]) {
|
||||||
tclap::CmdLine cmd(appName, argumentValueSeparator, appVersion);
|
tclap::CmdLine cmd(appName, argumentValueSeparator, appVersion);
|
||||||
cmd.setExceptionHandling(false);
|
cmd.setExceptionHandling(false);
|
||||||
cmd.setOutput(new NiceCmdLineOutput());
|
cmd.setOutput(new NiceCmdLineOutput());
|
||||||
|
tclap::ValueArg<string> outputFileName("o", "output", "The output file path.", false, string(), "string", cmd);
|
||||||
auto logLevels = vector<logging::Level>(logging::LevelConverter::get().getValues());
|
auto logLevels = vector<logging::Level>(logging::LevelConverter::get().getValues());
|
||||||
tclap::ValuesConstraint<logging::Level> logLevelConstraint(logLevels);
|
tclap::ValuesConstraint<logging::Level> logLevelConstraint(logLevels);
|
||||||
tclap::ValueArg<logging::Level> logLevel("", "logLevel", "The minimum log level to log", false, logging::Level::Debug, &logLevelConstraint, cmd);
|
tclap::ValueArg<logging::Level> logLevel("", "logLevel", "The minimum log level to log", false, logging::Level::Debug, &logLevelConstraint, cmd);
|
||||||
|
@ -163,7 +167,12 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
// Export animation
|
// Export animation
|
||||||
unique_ptr<Exporter> exporter = createExporter(exportFormat.getValue());
|
unique_ptr<Exporter> exporter = createExporter(exportFormat.getValue());
|
||||||
exporter->exportAnimation(inputFilePath, animation, targetShapeSet, std::cout);
|
optional<ofstream> outputFile;
|
||||||
|
if (outputFileName.isSet()) {
|
||||||
|
outputFile = boost::in_place(outputFileName.getValue());
|
||||||
|
outputFile->exceptions(std::ifstream::failbit | std::ifstream::badbit);
|
||||||
|
}
|
||||||
|
exporter->exportAnimation(inputFilePath, animation, targetShapeSet, outputFile ? *outputFile : std::cout);
|
||||||
|
|
||||||
logging::info("Exiting application normally.");
|
logging::info("Exiting application normally.");
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
|
Loading…
Reference in New Issue