12345678910111213141516171819202122232425262728293031323334353637383940 |
- namespace Publicate.Video {
- public class Encoder {
- public string input_file { get; private set; }
- public string output_dir { get; private set; }
- public EncodingProfile profile { get; private set; }
- public signal void progress_changed(double fraction, bool completed);
- public Encoder(File input, string output_dir, EncodingProfile profile) {
- input_file = input.get_path();
- this.output_dir = output_dir;
- this.profile = profile;
- }
- public void encode() throws Error {
- progress_changed(0.0, false);
- var output_file = output_dir + "/" + profile.output_name();
- var first_pass = new Subprocess.newv(profile.get_first_pass_command(input_file, output_file), GLib.SubprocessFlags.NONE);
- first_pass.wait();
- if(first_pass.get_exit_status() != 0) {
- throw new Error.literal(Quark.from_string("first-pass-failed"), 19, "Failed to analyse video");
- }
- progress_changed(0.5, false);
- var second_pass = new Subprocess.newv(profile.get_second_pass_command(input_file, output_file), GLib.SubprocessFlags.NONE);
- second_pass.wait();
- if(second_pass.get_exit_status() != 0) {
- throw new Error.literal(Quark.from_string("second-pass-failed"), 19, "Failed to encode video");
- }
- progress_changed(1.0, true);
- }
- }
- }
|