+ if (pipe(p)) {
+ synfig::error(_("Unable to open pipe to ffmpeg"));
+ return false;
+ };
+
+ pid = fork();
+
+ if (pid == -1) {
+ synfig::error(_("Unable to open pipe to ffmpeg"));
+ return false;
+ }
+
+ if (pid == 0){
+ // Child process
+ // Close pipeout, not needed
+ close(p[1]);
+ // Dup pipeout to stdin
+ if( dup2( p[0], STDIN_FILENO ) == -1 ){
+ synfig::error(_("Unable to open pipe to ffmpeg"));
+ return false;
+ }
+ // Close the unneeded pipeout
+ close(p[0]);
+ if( filename.c_str()[0] == '-' )
+ execlp("ffmpeg", "ffmpeg", "-f", "image2pipe", "-vcodec", "ppm", "-an", "-r", strprintf("%f", desc.get_frame_rate()).c_str(), "-i", "pipe:", "-loop", "-hq", "-title", get_canvas()->get_name().c_str(), "-vcodec", "mpeg1video", "-y", "--", filename.c_str(), (const char *)NULL);
+ else
+ execlp("ffmpeg", "ffmpeg", "-f", "image2pipe", "-vcodec", "ppm", "-an", "-r", strprintf("%f", desc.get_frame_rate()).c_str(), "-i", "pipe:", "-loop", "-hq", "-title", get_canvas()->get_name().c_str(), "-vcodec", "mpeg1video", "-y", filename.c_str(), (const char *)NULL);
+ // We should never reach here unless the exec failed
+ synfig::error(_("Unable to open pipe to ffmpeg"));
+ return false;
+ } else {
+ // Parent process
+ // Close pipein, not needed
+ close(p[0]);
+ // Save pipeout to file handle, will write to it later
+ file = fdopen(p[1], "wb");
+ }
+
+#else
+ #error There are no known APIs for creating child processes
+#endif