source: synfigstudio/trunk/fuentes/src/gui/dialogs/dialog_ffmpegparam.cpp @ 481

Last change on this file since 481 was 481, checked in by jrpelegrina, 4 years ago

First release to xenial

File size: 5.8 KB
Line 
1/* === S Y N F I G ========================================================= */
2/*!     \file dialog_targetparam.cpp
3**      \brief Implementation for the FFmpegParam Dialog
4**
5**      $Id$
6**
7**      \legal
8**      Copyright (c) 2010 Carlos López González
9**      Copyright (c) 2015 Denis Zdorovtsov
10**
11**      This package is free software; you can redistribute it and/or
12**      modify it under the terms of the GNU General Public License as
13**      published by the Free Software Foundation; either version 2 of
14**      the License, or (at your option) any later version.
15**
16**      This package is distributed in the hope that it will be useful,
17**      but WITHOUT ANY WARRANTY; without even the implied warranty of
18**      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19**      General Public License for more details.
20**      \endlegal
21*/
22/* ========================================================================= */
23
24/* === H E A D E R S ======================================================= */
25
26#ifdef USING_PCH
27#       include "pch.h"
28#else
29#ifdef HAVE_CONFIG_H
30#       include <config.h>
31#endif
32
33#include <iostream>
34#include "dialogs/dialog_ffmpegparam.h"
35
36#include "general.h"
37
38#endif
39
40/* === U S I N G =========================================================== */
41
42using namespace std;
43using namespace studio;
44
45/* === M A C R O S ========================================================= */
46
47#define CUSTOM_VCODEC_DESCRIPTION _("Custom Video Codec")
48#define CUSTOM_VCODEC _("write your video codec here")
49
50/* === G L O B A L S ======================================================= */
51//! Allowed video codecs
52/*! \warning This variable is linked to allowed_video_codecs_description,
53 *  if you change this you must change the other acordingly.
54 *  \warning These codecs are linked to the filename extensions for
55 *  mod_ffmpeg. If you change this you must change the others acordingly.
56 */
57const char* allowed_video_codecs[] =
58{
59        "flv", "h263p", "huffyuv", "libtheora", "libx264", "libx264-lossless",
60        "mjpeg", "mpeg1video", "mpeg2video", "mpeg4", "msmpeg4",
61        "msmpeg4v1", "msmpeg4v2", "wmv1", "wmv2", CUSTOM_VCODEC, NULL
62};
63
64//! Allowed video codecs description.
65/*! \warning This variable is linked to allowed_video_codecs,
66 *  if you change this you must change the other acordingly.
67 */
68const char* allowed_video_codecs_description[] =
69{
70        _("Flash Video (FLV) / Sorenson Spark / Sorenson H.263"),
71        _("H.263+ / H.263-1998 / H.263 version 2"),
72        _("Huffyuv / HuffYUV"),
73        _("libtheora Theora"),
74        _("H.264 / AVC / MPEG-4 AVC"),
75        _("H.264 / AVC / MPEG-4 AVC (LossLess)"),
76        _("MJPEG (Motion JPEG)"),
77        _("raw MPEG-1 video"),
78        _("raw MPEG-2 video"),
79        _("MPEG-4 part 2. (XviD/DivX)"),
80        _("MPEG-4 part 2 Microsoft variant version 3"),
81        _("MPEG-4 part 2 Microsoft variant version 1"),
82        _("MPEG-4 part 2 Microsoft variant version 2"),
83        _("Windows Media Video 7"),
84        _("Windows Media Video 8"),
85        CUSTOM_VCODEC_DESCRIPTION,
86        NULL
87};
88/* === P R O C E D U R E S ================================================= */
89
90/* === M E T H O D S ======================================================= */
91
92Dialog_FFmpegParam::Dialog_FFmpegParam(Gtk::Window &parent):
93        Dialog_TargetParam(parent, _("FFmpeg parameters"))
94{
95        // Custom Video Codec Entry
96        Gtk::Label* custom_label(manage(new Gtk::Label(std::string(CUSTOM_VCODEC_DESCRIPTION)+":")));
97        custom_label->set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_CENTER);
98        customvcodec=Gtk::manage(new Gtk::Entry());
99        // Available Video Codecs Combo Box Text.
100        Gtk::Label* label(manage(new Gtk::Label(_("Available Video Codecs:"))));
101        label->set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_CENTER);
102        vcodec = Gtk::manage(new Gtk::ComboBoxText());
103        // Appends the codec descriptions to the Combo Box
104        for (int i = 0; allowed_video_codecs[i] != NULL &&
105                                        allowed_video_codecs_description[i] != NULL; i++)
106                vcodec->append(allowed_video_codecs_description[i]);
107        //Adds the Combo Box and the Custom Video Codec entry to the vertical box
108        get_vbox()->pack_start(*label, true, true, 0);
109        get_vbox()->pack_start(*vcodec, true, true, 0);
110        get_vbox()->pack_start(*custom_label, true, true, 0);
111        get_vbox()->pack_start(*customvcodec, true, true, 0);
112
113        // Connect the signal change to the handler
114        vcodec->signal_changed().connect(sigc::mem_fun(*this, &Dialog_FFmpegParam::on_vcodec_change));
115
116        //Bitrate Spin Button
117        bitrate = Gtk::manage(new Gtk::SpinButton(Gtk::Adjustment::create(0.0, 10.0,100000.0)));
118        Gtk::Label* label2(manage(new Gtk::Label(_("Video Bit Rate:"))));
119        label2->set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_CENTER);
120        get_vbox()->pack_start(*label2, true, true, 0);
121        get_vbox()->pack_start(*bitrate,true, true, 0);
122
123        get_vbox()->show_all();
124}
125
126
127
128void
129Dialog_FFmpegParam::init()
130{
131        // By defaut, set the active text to the Custom Video Codec
132        vcodec->set_active_text(CUSTOM_VCODEC_DESCRIPTION);
133        customvcodec->set_text(CUSTOM_VCODEC);
134        //Compare the passed vcodec to the available and set it active if found
135        for (int i = 0; allowed_video_codecs[i] != NULL &&
136                                        allowed_video_codecs_description[i] != NULL; i++)
137                if(!get_tparam().video_codec.compare(allowed_video_codecs[i]))
138                {
139                        vcodec->set_active_text(allowed_video_codecs_description[i]);
140                        customvcodec->set_text(allowed_video_codecs[i]);
141                }
142        //Bitrate
143        bitrate->set_value(double(get_tparam().bitrate));
144}
145
146void
147Dialog_FFmpegParam::write_tparam(synfig::TargetParam & tparam_)
148{
149        tparam_.video_codec = customvcodec->get_text().c_str();
150        tparam_.bitrate = bitrate->get_value();
151}
152
153void
154Dialog_FFmpegParam::on_vcodec_change()
155{
156        std::string codecnamed = vcodec->get_active_text();
157        customvcodec->set_sensitive(false);
158        for (int i = 0; allowed_video_codecs[i] != NULL &&
159                                        allowed_video_codecs_description[i] != NULL; i++)
160                if(!codecnamed.compare(allowed_video_codecs_description[i]))
161                {
162                        if(!codecnamed.compare(CUSTOM_VCODEC_DESCRIPTION))
163                                customvcodec->set_sensitive(true);
164                        else
165                                customvcodec->set_text(allowed_video_codecs[i]);
166                }
167}
168
169Dialog_FFmpegParam::~Dialog_FFmpegParam()
170{
171}
Note: See TracBrowser for help on using the repository browser.