vtl: simple/localhost mode.
[ardour.git] / gtk2_ardour / add_video_dialog.cc
1 /*
2     Copyright (C) 2010-2013 Paul Davis
3     Author: Robin Gareus <robin@gareus.org>
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 */
20 #ifdef WITH_VIDEOTIMELINE
21
22 #include <cstdio>
23 #include <cmath>
24
25 #include <sigc++/bind.h>
26 #include <curl/curl.h>
27
28 #include "pbd/error.h"
29 #include "pbd/convert.h"
30 #include "gtkmm2ext/utils.h"
31 #include "gtkmm2ext/rgb_macros.h"
32 #include "ardour/session_directory.h"
33 #include "ardour/profile.h"
34 #include "ardour/template_utils.h"
35 #include "ardour/session.h"
36 #include "ardour_ui.h"
37
38 #include "utils.h"
39 #include "add_video_dialog.h"
40 #include "utils_videotl.h"
41 #include "i18n.h"
42
43 using namespace Gtk;
44 using namespace std;
45 using namespace PBD;
46 using namespace ARDOUR;
47
48 #define PREVIEW_WIDTH (240)
49 #define PREVIEW_HEIGHT (180)
50
51 #ifndef MIN
52 #define MIN(a,b) ( (a) < (b) ? (a) : (b) )
53 #endif
54
55 AddVideoDialog::AddVideoDialog (Session* s)
56         : ArdourDialog (_("Set Video Track"))
57         , seek_slider (0,1000,1)
58         , preview_path ("")
59         , pi_duration ("-", Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER, false)
60         , pi_aspect ("-", Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER, false)
61         , pi_fps ("-", Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER, false)
62         , chooser (FILE_CHOOSER_ACTION_OPEN)
63         , xjadeo_checkbox (_("Launch External Video Monitor"))
64         , set_session_fps_checkbox (_("Adjust Session Framerate to Match Video Framerate"))
65         , harvid_path ("")
66         , harvid_reset (_("Reload docroot"))
67         , harvid_list (ListStore::create(harvid_list_columns))
68         , harvid_list_view (harvid_list)
69 {
70         set_session (s);
71         set_name ("AddVideoDialog");
72         set_position (Gtk::WIN_POS_MOUSE);
73         set_modal (true);
74         set_skip_taskbar_hint (true);
75         set_resizable (true);
76         set_size_request (800, -1);
77
78         harvid_initialized = false;
79         std::string dstdir = video_dest_dir(_session->session_directory().video_path(), video_get_docroot(Config));
80
81         if (Config->get_video_advanced_setup()) {
82
83                 /* Harvid Browser */
84                 harvid_list_view.append_column("", pixBufRenderer);
85                 harvid_list_view.append_column(_("Filename"), harvid_list_columns.filename);
86
87                 harvid_list_view.get_column(0)->set_alignment(0.5);
88                 harvid_list_view.get_column(0)->add_attribute(pixBufRenderer, "stock-id", harvid_list_columns.id);
89                 harvid_list_view.get_column(1)->set_expand(true);
90                 harvid_list_view.get_column(1)->set_sort_column(harvid_list_columns.filename);
91                 harvid_list_view.set_enable_search(true);
92                 harvid_list_view.set_search_column(1);
93
94                 harvid_list_view.get_selection()->set_mode (SELECTION_SINGLE);
95
96                 harvid_list_view.get_selection()->signal_changed().connect(sigc::mem_fun(*this, &AddVideoDialog::harvid_list_view_selected));
97                 harvid_list_view.signal_row_activated().connect (sigc::mem_fun (*this, &AddVideoDialog::harvid_list_view_activated));
98
99                 VBox* vbox = manage (new VBox);
100                 Gtk::ScrolledWindow *scroll = manage(new ScrolledWindow);
101                 scroll->add(harvid_list_view);
102                 scroll->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
103
104                 HBox* hbox = manage (new HBox);
105                 harvid_path.set_alignment (0, 0.5);
106                 hbox->pack_start (harvid_path, true, true);
107                 hbox->pack_start (harvid_reset, false, false);
108
109                 vbox->pack_start (*hbox, false, false);
110                 vbox->pack_start (*scroll, true, true);
111
112                 notebook.append_page (*vbox, _("VideoServerIndex"));
113         } else {
114                 /* dummy entry */
115                 VBox* vbox = manage (new VBox);
116                 notebook.append_page (*vbox, _("VideoServerIndex"));
117         }
118
119         /* file chooser */
120         chooser.set_border_width (4);
121 #ifdef GTKOSX
122         /* some broken redraw behaviour - this is a bandaid */
123         chooser.signal_selection_changed().connect (mem_fun (chooser, &Widget::queue_draw));
124 #endif
125         chooser.set_current_folder (dstdir);
126
127         Gtk::FileFilter video_filter;
128         Gtk::FileFilter matchall_filter;
129         video_filter.add_custom (FILE_FILTER_FILENAME, mem_fun(*this, &AddVideoDialog::on_video_filter));
130         video_filter.set_name (_("Video files"));
131
132         matchall_filter.add_pattern ("*.*");
133         matchall_filter.set_name (_("All files"));
134
135         chooser.add_filter (video_filter);
136         chooser.add_filter (matchall_filter);
137         chooser.set_select_multiple (false);
138
139         /* file import options */
140         import_combo.set_name ("PaddedButton");
141         import_combo.append_text(_("Reference From Current Location"));
142         import_combo.append_text(_("Hardlink or Copy to Session"));
143         import_combo.append_text(_("Transcode to Session"));
144         import_combo.set_active(2);
145
146         VBox* vboxfb = manage (new VBox);
147         vboxfb->pack_start (chooser, true, true, 0);
148         vboxfb->pack_start (import_combo, false, true, 4);
149
150         if (video_get_docroot(Config).size() > 0 &&
151                         Config->get_video_advanced_setup()) {
152                 notebook.append_page (*vboxfb, _("Browse Files"));
153         }
154
155         /* Global Options*/
156         Gtk::Label* l;
157         VBox* options_box = manage (new VBox);
158
159         l = manage (new Label (_("<b>Options</b>"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
160         l->set_use_markup ();
161
162         options_box->pack_start (*l, false, true, 4);
163         options_box->pack_start (xjadeo_checkbox, false, true, 2);
164         options_box->pack_start (set_session_fps_checkbox, false, true, 2);
165
166         /* preview pane */
167         VBox* previewpane = manage (new VBox);
168         Gtk::Table *table = manage(new Table(4,2));
169
170         table->set_row_spacings(2);
171         table->set_col_spacings(4);
172
173         l = manage (new Label (_("<b>Video Information</b>"), Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER, false));
174         l->set_use_markup ();
175         table->attach (*l, 0, 2, 0, 1, FILL, FILL);
176         l = manage (new Label (_("Duration:"), Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER, false));
177         table->attach (*l, 0, 1, 1, 2, FILL, FILL);
178         table->attach (pi_duration, 1, 2, 1, 2, FILL, FILL);
179         l = manage (new Label (_("Frame rate:"), Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER, false));
180         table->attach (*l, 0, 1, 2, 3, FILL, FILL);
181         table->attach (pi_fps, 1, 2, 2, 3, FILL, FILL);
182         l = manage (new Label (_("Aspect Ratio:"), Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER, false));
183         table->attach (*l, 0, 1, 3, 4, FILL, FILL);
184         table->attach (pi_aspect, 1, 2, 3, 4, FILL, FILL);
185
186         preview_image = manage(new Gtk::Image);
187
188         imgbuf = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, true, 8, PREVIEW_WIDTH, PREVIEW_HEIGHT);
189         imgbuf->fill(RGBA_TO_UINT(127,0,0,255));
190         preview_image->set(imgbuf);
191         seek_slider.set_draw_value(false);
192
193         HBox* hbox = manage (new HBox);
194         hbox->pack_start (*table, true, false);
195
196         Gtk::Alignment *al = manage(new Gtk::Alignment());
197         al->set_size_request(-1, 20);
198
199         previewpane->pack_start (*al, false, false);
200         previewpane->pack_start (*hbox, true, true, 6);
201         previewpane->pack_start (*preview_image, false, false);
202         previewpane->pack_start (seek_slider, false, false);
203
204         /* Overall layout */
205         hbox = manage (new HBox);
206         if (Config->get_video_advanced_setup()) {
207                 hbox->pack_start (notebook, true, true);
208         } else {
209                 hbox->pack_start (*vboxfb, true, true);
210         }
211         hbox->pack_start (*previewpane, false, false);
212
213         get_vbox()->set_spacing (4);
214         get_vbox()->pack_start (*hbox, true, true);
215         get_vbox()->pack_start (*options_box, false, false);
216
217
218         /* xjadeo checkbox */
219         if (ARDOUR_UI::instance()->video_timeline->found_xjadeo()
220                         /* TODO xjadeo setup w/ xjremote */
221                         && video_get_docroot(Config).size() > 0) {
222                 xjadeo_checkbox.set_active(true);  /* set in ardour_ui.cpp ?! */
223         } else {
224                 printf("xjadeo was not found or video-server docroot is unset (remote video-server)\n");
225                 xjadeo_checkbox.set_active(false);
226                 xjadeo_checkbox.set_sensitive(false);
227         }
228
229         /* FPS checkbox */
230         set_session_fps_checkbox.set_active(true);
231
232         /* Buttons */
233         add_button (Stock::CANCEL, RESPONSE_CANCEL);
234         ok_button = add_button (Stock::OK, RESPONSE_ACCEPT);
235         //ok_button->set_sensitive(false);
236         set_action_ok(false);
237
238         /* connect signals after eveything has been initialized */
239         chooser.signal_selection_changed().connect (mem_fun (*this, &AddVideoDialog::file_selection_changed));
240         chooser.signal_file_activated().connect (mem_fun (*this, &AddVideoDialog::file_activated));
241         //chooser.signal_update_preview().connect(sigc::mem_fun(*this, &AddVideoDialog::update_preview));
242         notebook.signal_switch_page().connect (sigc::hide_return (sigc::hide (sigc::hide (sigc::mem_fun (*this, &AddVideoDialog::page_switch)))));
243         seek_slider.signal_value_changed().connect(sigc::mem_fun(*this, &AddVideoDialog::seek_preview));
244         harvid_reset.signal_clicked().connect (sigc::mem_fun (*this, &AddVideoDialog::harvid_load_docroot));
245
246         show_all_children ();
247 }
248
249 AddVideoDialog::~AddVideoDialog ()
250 {
251 }
252
253 void
254 AddVideoDialog::on_show ()
255 {
256         Dialog::on_show ();
257 }
258
259 static bool check_video_file_extension(std::string file)
260 {
261         const char* suffixes[] = {
262                 ".avi"     , ".AVI"     ,
263                 ".mov"     , ".MOV"     ,
264                 ".ogg"     , ".OGG"     ,
265                 ".ogv"     , ".OGV"     ,
266                 ".mpg"     , ".MPG"     ,
267                 ".mov"     , ".MOV"     ,
268                 ".mp4"     , ".MP4"     ,
269                 ".mkv"     , ".MKV"     ,
270                 ".vob"     , ".VOB"     ,
271                 ".asf"     , ".ASF"     ,
272                 ".avs"     , ".AVS"     ,
273                 ".dts"     , ".DTS"     ,
274                 ".flv"     , ".FLV"     ,
275                 ".m4v"     , ".M4V"     ,
276                 ".matroska", ".MATROSKA",
277                 ".h264"    , ".H264"    ,
278                 ".dv"      , ".DV"      ,
279                 ".dirac"   , ".DIRAC"   ,
280                 ".webm"    , ".WEBM"    ,
281         };
282
283         for (size_t n = 0; n < sizeof(suffixes)/sizeof(suffixes[0]); ++n) {
284                 if (file.rfind (suffixes[n]) == file.length() - strlen (suffixes[n])) {
285                         return true;
286                 }
287         }
288
289         return false;
290 }
291
292 bool
293 AddVideoDialog::on_video_filter (const FileFilter::Info& filter_info)
294 {
295         return check_video_file_extension(filter_info.filename);
296 }
297
298 std::string
299 AddVideoDialog::file_name (bool &local_file)
300 {
301         int n = notebook.get_current_page ();
302         if (n == 1 || ! Config->get_video_advanced_setup()) {
303                 local_file = true;
304                 return chooser.get_filename();
305         } else {
306                 local_file = false;
307                 Gtk::TreeModel::iterator iter = harvid_list_view.get_selection()->get_selected();
308                 if(!iter) return "";
309
310                 std::string uri = (*iter)[harvid_list_columns.uri];
311                 std::string video_server_url = video_get_server_url(Config);
312
313                 /* check if video server is running locally */
314                 if (video_get_docroot(Config).size() > 0
315                                 && !video_server_url.compare(0, 16, "http://localhost"))
316                 {
317                         /* check if the file can be accessed */
318                         int plen;
319                         CURL *curl;
320                         curl = curl_easy_init();
321                         char *ue = curl_easy_unescape(curl, uri.c_str(), uri.length(), &plen);
322                         std::string path = video_get_docroot(Config) + ue;
323                         if (!::access(path.c_str(), R_OK)) {
324                                 uri = path;
325                                 local_file = true;
326                         }
327                         curl_easy_cleanup(curl);
328                         curl_free(ue);
329                 }
330                 return uri;
331         }
332 }
333
334 enum VtlImportOption
335 AddVideoDialog::import_option ()
336 {
337         int n = notebook.get_current_page ();
338         if (n == 0 && Config->get_video_advanced_setup()) { return VTL_IMPORT_NONE; }
339         int i = import_combo.get_active_row_number();
340         return static_cast<VtlImportOption>(i);
341 }
342
343 bool
344 AddVideoDialog::launch_xjadeo ()
345 {
346         return xjadeo_checkbox.get_active();
347 }
348
349 bool
350 AddVideoDialog::auto_set_session_fps ()
351 {
352         return set_session_fps_checkbox.get_active();
353 }
354
355 void
356 AddVideoDialog::set_action_ok (bool yn)
357 {
358         if (yn) {
359                 ok_button->set_sensitive(true);
360         } else {
361                 preview_path = "";
362                 pi_duration.set_text("-");
363                 pi_aspect.set_text("-");
364                 pi_fps.set_text("-");
365                 ok_button->set_sensitive(false);
366                 imgbuf->fill(RGBA_TO_UINT(0,0,0,255));
367                 video_draw_cross(imgbuf);
368                 preview_image->set(imgbuf);
369                 preview_image->show();
370         }
371 }
372
373 void
374 AddVideoDialog::file_selection_changed ()
375 {
376         if (chooser.get_filename().size() > 0) {
377                 std::string path = chooser.get_filename();
378                 bool ok =
379                                 check_video_file_extension(path)
380                                 &&  Glib::file_test(path.c_str(), Glib::FILE_TEST_IS_REGULAR | Glib::FILE_TEST_IS_SYMLINK)
381                                 && !Glib::file_test(path.c_str(), Glib::FILE_TEST_IS_DIR);
382                 set_action_ok(ok);
383                 if (ok) {
384                         request_preview(video_map_path(video_get_docroot(Config), path));
385                 }
386         } else {
387                 set_action_ok(false);
388         }
389 }
390
391 void
392 AddVideoDialog::file_activated ()
393 {
394         if (chooser.get_filename().size() > 0) {
395                 std::string path = chooser.get_filename();
396                 // TODO check docroot -> set import options
397                 bool ok =
398                                 check_video_file_extension(path)
399                                 &&  Glib::file_test(path.c_str(), Glib::FILE_TEST_IS_REGULAR | Glib::FILE_TEST_IS_SYMLINK)
400                                 && !Glib::file_test(path.c_str(), Glib::FILE_TEST_IS_DIR);
401                 if (ok) {
402                         Gtk::Dialog::response(RESPONSE_ACCEPT);
403                 }
404         }
405 }
406
407 /**** Tree List Interaction ***/
408
409 void
410 AddVideoDialog::harvid_list_view_selected () {
411         Gtk::TreeModel::iterator iter = harvid_list_view.get_selection()->get_selected();
412         // TODO check docroot -> set import options, xjadeo
413         if(!iter) {
414                 set_action_ok(false);
415                 return;
416         }
417         if ((std::string)((*iter)[harvid_list_columns.id]) == Stock::DIRECTORY.id) {
418                 set_action_ok(false);
419         } else {
420                 set_action_ok(true);
421                 request_preview((*iter)[harvid_list_columns.uri]);
422         }
423 }
424
425 void
426 AddVideoDialog::harvid_list_view_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn*) {
427         Gtk::TreeModel::iterator iter = harvid_list->get_iter(path);
428         if (!iter) return;
429         std::string type = (*iter)[harvid_list_columns.id];
430         std::string url = (*iter)[harvid_list_columns.uri];
431
432 #if 0
433         printf ("A: %s %s %s\n",
434                         ((std::string)((*iter)[harvid_list_columns.id])).c_str(),
435                         ((std::string)((*iter)[harvid_list_columns.uri])).c_str(),
436                         ((std::string)((*iter)[harvid_list_columns.filename])).c_str());
437 #endif
438
439         if (type == Gtk::Stock::DIRECTORY.id) {
440                 harvid_request(url.c_str());
441         } else {
442                 Gtk::Dialog::response(RESPONSE_ACCEPT);
443         }
444 }
445
446 void
447 AddVideoDialog::harvid_load_docroot() {
448         set_action_ok(false);
449
450         std::string video_server_url = video_get_server_url(Config);
451         char url[2048];
452         snprintf(url, sizeof(url), "%s%sindex/"
453                 , video_server_url.c_str()
454                 , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/");
455         harvid_request(url);
456         harvid_initialized = true;
457 }
458
459 bool
460 AddVideoDialog::page_switch() {
461         if (notebook.get_current_page () == 1 || Config->get_video_advanced_setup()) {
462                 file_selection_changed();
463                 return true;
464         }
465
466         if (harvid_initialized) {
467                 harvid_list_view_selected();
468         } else {
469                 harvid_load_docroot();
470         }
471         return true;
472 }
473
474 /**** Harvid HTTP interface ***/
475 void
476 AddVideoDialog::harvid_request(std::string u)
477 {
478         char url[2048];
479         int status;
480         snprintf(url, sizeof(url), "%s?format=csv", u.c_str());
481
482         harvid_list->clear();
483
484         char *res = curl_http_get(url, &status);
485         if (status != 200) {
486                 printf("request failed\n"); // XXX
487                 harvid_path.set_text(" - request failed -");
488                 free(res);
489                 return;
490         }
491
492         /* add up-to-parent */
493         size_t se = u.find_last_of("/", u.size()-2);
494         size_t ss = u.find("/index/");
495         if (se != string::npos && ss != string::npos && se > ss) {
496                 TreeModel::iterator new_row = harvid_list->append();
497                 TreeModel::Row row = *new_row;
498                 row[harvid_list_columns.id      ] = Gtk::Stock::DIRECTORY.id;
499                 row[harvid_list_columns.uri     ] = u.substr(0, se + 1);
500                 row[harvid_list_columns.filename] = X_("..");
501         }
502         if (se != string::npos) {
503                 int plen;
504                 std::string path = u.substr(ss + 6);
505                 CURL *curl;
506                 curl = curl_easy_init();
507                 char *ue = curl_easy_unescape(curl, path.c_str(), path.length(), &plen);
508                 harvid_path.set_text(std::string(ue));
509                 curl_easy_cleanup(curl);
510                 curl_free(ue);
511         } else {
512                 harvid_path.set_text(" ??? ");
513         }
514
515         if (!res) return;
516
517         std::vector<std::vector<std::string> > lines;
518         ParseCSV(std::string(res), lines);
519         for (std::vector<std::vector<std::string> >::iterator i = lines.begin(); i != lines.end(); ++i) {
520                 TreeModel::iterator new_row = harvid_list->append();
521                 TreeModel::Row row = *new_row;
522
523                 if (i->at(0) == X_("D")) {
524                         row[harvid_list_columns.id      ] = Gtk::Stock::DIRECTORY.id;
525                         row[harvid_list_columns.uri     ] = i->at(1).c_str();
526                         row[harvid_list_columns.filename] = i->at(2).c_str();
527                 } else {
528                         row[harvid_list_columns.id      ] = Gtk::Stock::MEDIA_PLAY.id;
529                         row[harvid_list_columns.uri     ] = i->at(2).c_str();
530                         row[harvid_list_columns.filename] = i->at(3).c_str();
531                 }
532         }
533
534         free(res);
535 }
536
537 void
538 AddVideoDialog::seek_preview()
539 {
540         if (preview_path.size() > 0)
541                 request_preview(preview_path);
542 }
543
544 void
545 AddVideoDialog::request_preview(std::string u)
546 {
547         std::string video_server_url = video_get_server_url(Config);
548
549         double video_file_fps;
550         long long int video_duration;
551         double video_start_offset;
552         double video_aspect_ratio;
553
554         int clip_width = PREVIEW_WIDTH;
555         int clip_height = PREVIEW_HEIGHT;
556         int clip_xoff, clip_yoff;
557
558         if (!video_query_info(video_server_url, u,
559                         video_file_fps, video_duration, video_start_offset, video_aspect_ratio))
560         {
561                 printf("image preview info request failed\n");
562                 // set_action_ok(false); // XXX only if docroot mismatch
563                 preview_path = "";
564                 pi_duration.set_text("-");
565                 pi_aspect.set_text("-");
566                 pi_fps.set_text("-");
567                 return;
568         }
569
570         if ((PREVIEW_WIDTH / (double)PREVIEW_HEIGHT) > video_aspect_ratio ) {
571                 clip_width = MIN(PREVIEW_WIDTH, rint(clip_height * video_aspect_ratio));
572         } else {
573                 clip_height = MIN(PREVIEW_HEIGHT, rint(clip_width / video_aspect_ratio));
574         }
575
576         pi_duration.set_text(string_compose("%1 sec", video_duration / video_file_fps));
577         pi_aspect.set_text(string_compose("%1", video_aspect_ratio));
578         pi_fps.set_text(string_compose("%1 fps", video_file_fps));
579
580         clip_xoff = (PREVIEW_WIDTH - clip_width)/2;
581         clip_yoff = (PREVIEW_HEIGHT - clip_height)/2;
582
583         char url[2048];
584         snprintf(url, sizeof(url), "%s%s?frame=%lli&w=%d&h=%di&file=%s&format=rgb"
585                 , video_server_url.c_str()
586                 , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/"
587                 , (long long) (video_duration * seek_slider.get_value() / 1000.0)
588                 , clip_width, clip_height, u.c_str());
589
590         char *data = curl_http_get(url, NULL);
591         if (!data) {
592                 printf("image preview request failed %s\n", url);
593                 imgbuf->fill(RGBA_TO_UINT(0,0,0,255));
594                 video_draw_cross(imgbuf);
595                 preview_path = "";
596         } else {
597                 Glib::RefPtr<Gdk::Pixbuf> tmp;
598                 tmp = Gdk::Pixbuf::create_from_data ((guint8*) data, Gdk::COLORSPACE_RGB, false, 8, clip_width, clip_height, clip_width*3);
599                 if (clip_width != PREVIEW_WIDTH || clip_height != PREVIEW_HEIGHT) {
600                         imgbuf->fill(RGBA_TO_UINT(0,0,0,255));
601                 }
602                 tmp->copy_area (0, 0, clip_width, clip_height, imgbuf, clip_xoff, clip_yoff);
603                 preview_path = u;
604                 free(data);
605         }
606         preview_image->set(imgbuf);
607         preview_image->show();
608 }
609
610 #endif /* WITH_VIDEOTIMELINE */