FFMPEG module if needed parameter overriding.
[synfig.git] / synfig-core / src / modules / mod_ffmpeg / trgt_ffmpeg.cpp
index cf53761..57d0b9d 100644 (file)
@@ -90,8 +90,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()
@@ -164,21 +173,21 @@ ffmpeg_trgt::init()
        if( filename.c_str()[0] == '-' )
                command = strprintf("ffmpeg -f image2pipe -vcodec ppm -an"
                                                        " -r %f -i pipe: -loop_input"
-                                                       //" -metadata title=\"%s\" "
-                                                       " -vcodec %s -b %i"
+                                                       " -metadata title=\"%s\" "
+                                                       " -vcodec %s -b %ik"
                                                        " -y -- \"%s\"\n",
                                                        desc.get_frame_rate(),
-                                                       //get_canvas()->get_name().c_str(),
+                                                       get_canvas()->get_name().c_str(),
                                                        video_codec.c_str(), bitrate,
                                                        filename.c_str());
        else
                command = strprintf("ffmpeg -f image2pipe -vcodec ppm -an"
                                                        " -r %f -i pipe: -loop_input"
-                                                       //" -metadata title=\"%s\" "
-                                                       "-vcodec %s -b %i"
+                                                       " -metadata title=\"%s\" "
+                                                       "-vcodec %s -b %ik"
                                                        " -y -- \"%s\"\n",
                                                        desc.get_frame_rate(),
-                                                       //get_canvas()->get_name().c_str(),
+                                                       get_canvas()->get_name().c_str(),
                                                        video_codec.c_str(), bitrate,
                                                        filename.c_str());
 
@@ -216,18 +225,20 @@ ffmpeg_trgt::init()
                                   "ppm", "-an", "-r",
                                   strprintf("%f", desc.get_frame_rate()).c_str(),
                                   "-i", "pipe:", "-loop_input",
-                                  //strprintf("-metadata title=\"%s\"", get_canvas()->get_name().c_str()).c_str(),
+                                  "-metadata",
+                                  strprintf("title=\"%s\"", get_canvas()->get_name().c_str()).c_str(),
                                   "-vcodec", video_codec.c_str(),
-                                  "-b "+bitrate,
+                                  "-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",
-                                  //strprintf("-metadata title=\"%s\"", get_canvas()->get_name().c_str()).c_str(),
+                                  "-metadata",
+                                  strprintf("title=\"%s\"", get_canvas()->get_name().c_str()).c_str(),
                                   "-vcodec", video_codec.c_str(),
-                                  "-b "+bitrate,
+                                  "-b", strprintf("%ik", bitrate).c_str(),
                                   "-y", filename.c_str(), (const char *)NULL);
 
                // We should never reach here unless the exec failed