X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=synfig-core%2Fsrc%2Fmodules%2Fmod_ffmpeg%2Ftrgt_ffmpeg.cpp;h=528166d2fcfc50e146cea346b02b082b420c1819;hb=26f78d052cedf01a267206f31f20bac8eaaa2c89;hp=0f2a728492ce79f5d59bbcd809938ababba85742;hpb=6202fa9106fb2e71a2684094cb534eda9588fadd;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 0f2a728..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() @@ -163,8 +170,9 @@ ffmpeg_trgt::init() if( filename.c_str()[0] == '-' ) command = strprintf("ffmpeg -f image2pipe -vcodec ppm -an" - " -r %f -i pipe: -loop -hq" - " -title \"%s\" -vcodec %s -b %i" + " -r %f -i pipe: -loop_input" + " -metadata title=\"%s\" " + " -vcodec %s -b %ik" " -y -- \"%s\"\n", desc.get_frame_rate(), get_canvas()->get_name().c_str(), @@ -172,8 +180,9 @@ ffmpeg_trgt::init() filename.c_str()); else command = strprintf("ffmpeg -f image2pipe -vcodec ppm -an" - " -r %f -i pipe: -loop -hq" - " -title \"%s\" -vcodec %s -b %i" + " -r %f -i pipe: -loop_input" + " -metadata title=\"%s\" " + "-vcodec %s -b %ik" " -y -- \"%s\"\n", desc.get_frame_rate(), get_canvas()->get_name().c_str(), @@ -210,23 +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", "-hq", - "-title", get_canvas()->get_name().c_str(), - "-vcodec", video_codec.c_str(), - "-b", bitrate, - "-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", "-hq", - "-title", get_canvas()->get_name().c_str(), - "-vcodec", video_codec.c_str(), - "-b", bitrate, - "-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"));