X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Fsrc%2Fmodules%2Fmod_ffmpeg%2Ftrgt_ffmpeg.cpp;h=528166d2fcfc50e146cea346b02b082b420c1819;hb=771bab79d7ca89c8389d9ec4aef5a0f8387f8f7c;hp=4159ac9bf1b0e5d9bfb1af71e1ae3adc3e6628ff;hpb=cd499408f2383ccc602277e45a4bfe2313c08a23;p=synfig.git diff --git a/synfig-core/src/modules/mod_ffmpeg/trgt_ffmpeg.cpp b/synfig-core/src/modules/mod_ffmpeg/trgt_ffmpeg.cpp index 4159ac9..528166d 100644 --- a/synfig-core/src/modules/mod_ffmpeg/trgt_ffmpeg.cpp +++ b/synfig-core/src/modules/mod_ffmpeg/trgt_ffmpeg.cpp @@ -26,8 +26,6 @@ /* === H E A D E R S ======================================================= */ -#define SYNFIG_TARGET - #ifdef USING_PCH # include "pch.h" #else @@ -90,8 +88,17 @@ ffmpeg_trgt::ffmpeg_trgt(const char *Filename, buffer=NULL; color_buffer=0; set_remove_alpha(); - video_codec = params.video_codec; - bitrate = params.bitrate; + + // Set default video codec and bitrate if they weren't given. + if (params.video_codec == "none") + video_codec = "mpeg1video"; + else + video_codec = params.video_codec; + + if (params.bitrate == -1) + bitrate = 200; + else + bitrate = params.bitrate; } ffmpeg_trgt::~ffmpeg_trgt() @@ -212,25 +219,52 @@ ffmpeg_trgt::init() // 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_input", - "-metadata", - strprintf("title=\"%s\"", get_canvas()->get_name().c_str()).c_str(), - "-vcodec", video_codec.c_str(), - "-b", strprintf("%ik", bitrate).c_str(), - "-y", "--", filename.c_str(), (const char *)NULL); + { + // x264 codec needs -vpre hq parameters + if (video_codec == "libx264") + execlp("ffmpeg", "ffmpeg", "-f", "image2pipe", "-vcodec", + "ppm", "-an", "-r", + strprintf("%f", desc.get_frame_rate()).c_str(), + "-i", "pipe:", "-loop_input", "-metadata", + strprintf("title=\"%s\"", get_canvas()->get_name().c_str()).c_str(), + "-vcodec", video_codec.c_str(), + "-b", strprintf("%ik", bitrate).c_str(), + "-vpre", "hq", + "-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_input", "-metadata", + strprintf("title=\"%s\"", get_canvas()->get_name().c_str()).c_str(), + "-vcodec", video_codec.c_str(), + "-b", strprintf("%ik", bitrate).c_str(), + "-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_input", - "-metadata", - strprintf("title=\"%s\"", get_canvas()->get_name().c_str()).c_str(), - "-vcodec", video_codec.c_str(), - "-b", strprintf("%ik", bitrate).c_str(), - "-y", filename.c_str(), (const char *)NULL); + { + if (video_codec == "libx264") + execlp("ffmpeg", "ffmpeg", "-f", "image2pipe", "-vcodec", + "ppm", "-an", "-r", + strprintf("%f", desc.get_frame_rate()).c_str(), + "-i", "pipe:", "-loop_input", + "-metadata", + strprintf("title=\"%s\"", get_canvas()->get_name().c_str()).c_str(), + "-vcodec", video_codec.c_str(), + "-b", strprintf("%ik", bitrate).c_str(), + "-vpre", "hq", + "-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_input", + "-metadata", + strprintf("title=\"%s\"", get_canvas()->get_name().c_str()).c_str(), + "-vcodec", video_codec.c_str(), + "-b", strprintf("%ik", bitrate).c_str(), + "-y", filename.c_str(), (const char *)NULL); + } // We should never reach here unless the exec failed synfig::error(_("Unable to open pipe to ffmpeg"));