clarify missing ffmpeg messages
[ardour.git] / gtk2_ardour / transcode_ffmpeg.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 #include <stdio.h>
21 #include <string.h>
22 #include <sstream>
23 #include <sys/types.h>
24
25 #include "pbd/error.h"
26 #include "pbd/convert.h"
27 #include "pbd/file_utils.h"
28 #include "gui_thread.h"
29
30 #include "transcode_ffmpeg.h"
31 #include "utils_videotl.h"
32 #include "video_tool_paths.h"
33
34 #include "i18n.h"
35
36 using namespace PBD;
37 using namespace VideoUtils;
38
39 TranscodeFfmpeg::TranscodeFfmpeg (std::string f)
40         : infile(f)
41 {
42         probeok = false;
43         ffexecok = false;
44         m_duration = 0;
45         m_avoffset = m_lead_in = m_lead_out = 0;
46         m_width = m_height = 0;
47         m_aspect = m_fps = 0;
48         m_sar = "";
49 #if 1 /* tentative debug mode */
50         debug_enable = false;
51 #endif
52
53         if (!ArdourVideoToolPaths::transcoder_exe(ffmpeg_exe, ffprobe_exe)) {
54                 warning << string_compose(
55                                 _(
56                                         "ffmpeg installation was not found on this system.\n"
57                                         "%1 requires ffmpeg and ffprobe from ffmpeg.org - version 1.1 or newer.\n"
58                                         "Video import and export is not possible until you install tools.\n"
59                                         "\n"
60                                         "The tools are included with the %1 releases from ardour.org "
61                                         "and also available with the video-server at http://x42.github.com/harvid/\n"
62                                         "\n"
63                                         "Important: the files need to be installed in $PATH and named ffmpeg_harvid and ffprobe_harvid.\n"
64                                         "If you already have a suitable ffmpeg installation on your system, we recommend creating "
65                                         "symbolic links from ffmpeg to ffmpeg_harvid and from ffprobe to ffprobe_harvid.\n"
66                                         "\n"
67                                         "see also http://manual.ardour.org/video-timeline/setup/"
68                                  ), PROGRAM_NAME) << endmsg;
69                 return;
70         }
71         ffexecok = true;
72
73         if (infile.empty() || !probe()) {
74                 return;
75         }
76         probeok = true;
77 }
78
79 TranscodeFfmpeg::~TranscodeFfmpeg ()
80 {
81   ;
82 }
83
84 bool
85 TranscodeFfmpeg::probe ()
86 {
87         ffoutput = "";
88         char **argp;
89         argp=(char**) calloc(7,sizeof(char*));
90         argp[0] = strdup(ffprobe_exe.c_str());
91         argp[1] = strdup("-print_format");
92         argp[2] = strdup("csv=nk=0");
93         argp[3] = strdup("-show_format");
94         argp[4] = strdup("-show_streams");
95         argp[5] = strdup(infile.c_str());
96         argp[6] = 0;
97         ffcmd = new ARDOUR::SystemExec(ffprobe_exe, argp);
98         ffcmd->ReadStdout.connect_same_thread (*this, boost::bind (&TranscodeFfmpeg::ffprobeparse, this, _1 ,_2));
99         ffcmd->Terminated.connect (*this, invalidator (*this), boost::bind (&TranscodeFfmpeg::ffexit, this), gui_context());
100         if (ffcmd->start(1)) {
101                 ffexit();
102                 return false;
103         }
104
105         /* wait for ffprobe process to exit */
106         ffcmd->wait();
107
108         /* wait for interposer thread to copy all data.
109          * SystemExec::Terminated is emitted and ffcmd set to NULL */
110         int timeout = 300; // 1.5 sec
111         while (ffcmd && --timeout > 0) {
112                 Glib::usleep(5000);
113                 ARDOUR::GUIIdle();
114         }
115         if (timeout == 0 || ffoutput.empty()) {
116                 return false;
117         }
118
119         /* parse */
120
121         std::vector<std::vector<std::string> > lines;
122         ParseCSV(ffoutput, lines);
123         double timebase = 0;
124         m_width = m_height = 0;
125         m_fps = m_aspect = 0;
126         m_duration = 0;
127         m_sar.clear();
128         m_codec.clear();
129         m_audio.clear();
130
131 #define PARSE_FRACTIONAL_FPS(VAR) \
132         { \
133                 std::string::size_type pos; \
134                 VAR = atof(value); \
135                 pos = value.find_first_of('/'); \
136                 if (pos != std::string::npos) { \
137                         VAR = atof(value.substr(0, pos)) / atof(value.substr(pos+1)); \
138                 } \
139         }
140
141         for (std::vector<std::vector<std::string> >::iterator i = lines.begin(); i != lines.end(); ++i) {
142                 if (i->at(0) == X_("format")) {
143                         /* format,filename,#streams,format-name,format-long-name,start-time,duration,size,bitrate */
144                 } else
145                 if (i->at(0) == X_("stream")) {
146                         if (i->at(5) == X_("codec_type=video") && m_width == 0) {
147
148                                 for (std::vector<std::string>::iterator kv = i->begin(); kv != i->end(); ++kv) {
149                                         const size_t kvsep = kv->find('=');
150                                         if(kvsep == std::string::npos) continue;
151                                         std::string key = kv->substr(0, kvsep);
152                                         std::string value = kv->substr(kvsep + 1);
153
154                                         if (key == X_("index")) {
155                                                 m_videoidx = atoi(value);
156                                         } else if (key == X_("width")) {
157                                                 m_width = atoi(value);
158                                         } else if (key == X_("height")) {
159                                                 m_height = atoi(value);
160                                         } else if (key == X_("codec_name")) {
161                                                 if (!m_codec.empty()) m_codec += " ";
162                                                 m_codec += value;
163                                         } else if (key == X_("codec_long_name")) {
164                                                 if (!m_codec.empty()) m_codec += " ";
165                                                 m_codec += "[" + value + "]";
166                                         } else if (key == X_("codec_tag_string")) {
167                                                 if (!m_codec.empty()) m_codec += " ";
168                                                 m_codec += "(" + value + ")";
169                                         } else if (key == X_("r_frame_rate")) {
170                                                 PARSE_FRACTIONAL_FPS(m_fps)
171                                         } else if (key == X_("avg_frame_rate") && m_fps == 0) {
172                                                 PARSE_FRACTIONAL_FPS(m_fps)
173                                         } else if (key == X_("time_base")) {
174                                                 PARSE_FRACTIONAL_FPS(timebase)
175                                         } else if (key == X_("timecode") && m_duration == 0) {
176                                                 int h,m,s; char f[32];
177                                                 if (sscanf(i->at(16).c_str(), "%d:%d:%d:%32s",&h,&m,&s,f) == 4) {
178                                                         m_duration = (ARDOUR::framecnt_t) floor(m_fps * (
179                                                                         h * 3600.0
180                                                                 + m * 60.0
181                                                                 + s * 1.0
182                                                                 + atoi(f) / pow((double)10, (int)strlen(f))
183                                                         ));
184                                                 }
185                                         } else if (key == X_("duration_ts") && m_fps == 0 && timebase !=0 ) {
186                                                 m_duration = atof(value) * m_fps * timebase;
187                                         } else if (key == X_("duration") && m_fps != 0 && m_duration == 0) {
188                                                 m_duration = atof(value) * m_fps;
189                                         } else if (key == X_("sample_aspect_ratio")) {
190                                                 std::string::size_type pos;
191                                                 pos = value.find_first_of(':');
192                                                 if (pos != std::string::npos && atof(value.substr(pos+1)) != 0) {
193                                                         m_sar = value;
194                                                         m_sar.replace(pos, 1, "/");
195                                                 }
196                                         } else if (key == X_("display_aspect_ratio")) {
197                                                 std::string::size_type pos;
198                                                 pos = value.find_first_of(':');
199                                                 if (pos != std::string::npos && atof(value.substr(pos+1)) != 0) {
200                                                         m_aspect = atof(value.substr(0, pos)) / atof(value.substr(pos+1));
201                                                 }
202                                         }
203                                 }
204
205                                 if (m_aspect == 0) {
206                                         m_aspect = (double)m_width / (double)m_height;
207                                 }
208
209                         } else if (i->at(5) == X_("codec_type=audio")) { /* new ffprobe */
210                                 FFAudioStream as;
211                                 for (std::vector<std::string>::iterator kv = i->begin(); kv != i->end(); ++kv) {
212                                         const size_t kvsep = kv->find('=');
213                                         if(kvsep == std::string::npos) continue;
214                                         std::string key = kv->substr(0, kvsep);
215                                         std::string value = kv->substr(kvsep + 1);
216
217                                         if (key == X_("channels")) {
218                                                 as.channels   = atoi(value);
219                                         } else if (key == X_("index")) {
220                                                 as.stream_id  = value;
221                                         } else if (key == X_("codec_long_name")) {
222                                                 if (!as.name.empty()) as.name += " ";
223                                                 as.name += value;
224                                         } else if (key == X_("codec_name")) {
225                                                 if (!as.name.empty()) as.name += " ";
226                                                 as.name += value;
227                                         } else if (key == X_("sample_fmt")) {
228                                                 if (!as.name.empty()) as.name += " ";
229                                                 as.name += "FMT:" + value;
230                                         } else if (key == X_("sample_rate")) {
231                                                 if (!as.name.empty()) as.name += " ";
232                                                 as.name += "SR:" + value;
233                                         }
234
235                                 }
236                                 m_audio.push_back(as);
237                         }
238                 }
239         }
240         /* end parse */
241
242 #if 0 /* DEBUG */
243         printf("FPS: %f\n", m_fps);
244         printf("Duration: %lu frames\n",(unsigned long)m_duration);
245         printf("W/H: %ix%i\n",m_width, m_height);
246         printf("aspect: %f\n",m_aspect);
247         printf("codec: %s\n",m_codec.c_str());
248         if (m_audio.size() > 0) {
249                 for (AudioStreams::iterator it = m_audio.begin(); it < m_audio.end(); ++it) {
250                         printf("audio: %s - %i channels\n",(*it).stream_id.c_str(), (*it).channels);
251                 }
252         } else {
253           printf("audio: no audio streams in file.\n");
254         }
255 #endif
256
257         return true;
258 }
259
260 TranscodeFfmpeg::FFSettings
261 TranscodeFfmpeg::default_encoder_settings ()
262 {
263         TranscodeFfmpeg::FFSettings ffs;
264         ffs.clear();
265         ffs["-vcodec"] = "mpeg4";
266         ffs["-acodec"] = "ac3";
267         ffs["-b:v"] = "5000k";
268         ffs["-b:a"] = "160k";
269         return ffs;
270 }
271
272 TranscodeFfmpeg::FFSettings
273 TranscodeFfmpeg::default_meta_data ()
274 {
275         TranscodeFfmpeg::FFSettings ffm;
276         ffm.clear();
277         ffm["comment"] = "Created with " PROGRAM_NAME;
278         return ffm;
279 }
280
281 char *
282 TranscodeFfmpeg::format_metadata (std::string key, std::string value)
283 {
284         size_t start_pos = 0;
285         std::string v1 = value;
286         while((start_pos = v1.find_first_not_of(
287                         "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789(),.\"'",
288                         start_pos)) != std::string::npos)
289         {
290                 v1.replace(start_pos, 1, "_");
291                 start_pos += 1;
292         }
293
294         start_pos = 0;
295         while((start_pos = v1.find("\"", start_pos)) != std::string::npos) {
296                 v1.replace(start_pos, 1, "\\\"");
297                 start_pos += 2;
298         }
299
300         size_t len = key.length() + v1.length() + 4;
301         char *mds = (char*) calloc(len, sizeof(char));
302 #ifdef PLATFORM_WINDOWS
303         /* SystemExec::make_wargs() adds quotes around the complete argument
304          * windows uses CreateProcess() with a parameter string
305          * (and not an array list of separate arguments)
306          */
307         snprintf(mds, len, "%s=%s", key.c_str(), v1.c_str());
308 #else
309         snprintf(mds, len, "%s=\"%s\"", key.c_str(), v1.c_str());
310 #endif
311         return mds;
312 }
313
314 bool
315 TranscodeFfmpeg::encode (std::string outfile, std::string inf_a, std::string inf_v, TranscodeFfmpeg::FFSettings ffs, TranscodeFfmpeg::FFSettings meta, bool map)
316 {
317 #define MAX_FFMPEG_ENCODER_ARGS (100)
318         char **argp;
319         int a=0;
320
321         argp=(char**) calloc(MAX_FFMPEG_ENCODER_ARGS,sizeof(char*));
322         argp[a++] = strdup(ffmpeg_exe.c_str());
323         if (m_avoffset < 0 || m_avoffset > 0) {
324                 std::ostringstream osstream; osstream << m_avoffset;
325                 argp[a++] = strdup("-itsoffset");
326                 argp[a++] = strdup(osstream.str().c_str());
327         }
328         argp[a++] = strdup("-i");
329         argp[a++] = strdup(inf_v.c_str());
330
331         argp[a++] = strdup("-i");
332         argp[a++] = strdup(inf_a.c_str());
333
334         for(TranscodeFfmpeg::FFSettings::const_iterator it = ffs.begin(); it != ffs.end(); ++it) {
335                 argp[a++] = strdup(it->first.c_str());
336                 argp[a++] = strdup(it->second.c_str());
337         }
338         for(TranscodeFfmpeg::FFSettings::const_iterator it = meta.begin(); it != meta.end(); ++it) {
339                 argp[a++] = strdup("-metadata");
340                 argp[a++] = format_metadata(it->first.c_str(), it->second.c_str());
341         }
342
343         if (m_fps > 0) {
344                 m_lead_in  = rint (m_lead_in * m_fps) / m_fps;
345                 m_lead_out = rint (m_lead_out * m_fps) / m_fps;
346         }
347
348         if (m_lead_in != 0 && m_lead_out != 0) {
349                 std::ostringstream osstream;
350                 argp[a++] = strdup("-vf");
351                 osstream << X_("color=c=black:s=") << m_width << X_("x") << m_height << X_(":d=") << m_lead_in;
352                 if (!m_sar.empty()) osstream << X_(":sar=") << m_sar;
353                 osstream << X_(" [pre]; ");
354                 osstream << X_("color=c=black:s=") << m_width << X_("x") << m_height << X_(":d=") << m_lead_out;
355                 if (!m_sar.empty()) osstream << X_(":sar=") << m_sar;
356                 osstream << X_(" [post]; ");
357                 osstream << X_("[pre] [in] [post] concat=n=3");
358                 argp[a++] = strdup(osstream.str().c_str());
359         } else if (m_lead_in != 0) {
360                 std::ostringstream osstream;
361                 argp[a++] = strdup("-vf");
362                 osstream << X_("color=c=black:s=") << m_width << X_("x") << m_height << X_(":d=") << m_lead_in;
363                 if (!m_sar.empty()) osstream << X_(":sar=") << m_sar;
364                 osstream << X_(" [pre]; ");
365                 osstream << X_("[pre] [in] concat=n=2");
366                 argp[a++] = strdup(osstream.str().c_str());
367         } else if (m_lead_out != 0) {
368                 std::ostringstream osstream;
369                 argp[a++] = strdup("-vf");
370                 osstream << X_("color=c=black:s=") << m_width << X_("x") << m_height << X_(":d=") << m_lead_out;
371                 if (!m_sar.empty()) osstream << X_(":sar=") << m_sar;
372                 osstream << X_(" [post]; ");
373                 osstream << X_("[in] [post] concat=n=2");
374                 argp[a++] = strdup(osstream.str().c_str());
375         }
376
377         if (map) {
378                 std::ostringstream osstream;
379                 argp[a++] = strdup("-map");
380                 osstream << X_("0:") << m_videoidx;
381                 argp[a++] = strdup(osstream.str().c_str());
382                 argp[a++] = strdup("-map");
383                 argp[a++] = strdup("1:0");
384         }
385
386         argp[a++] = strdup("-y");
387         argp[a++] = strdup(outfile.c_str());
388         argp[a] = (char *)0;
389         assert(a<MAX_FFMPEG_ENCODER_ARGS);
390         /* Note: these are free()d in ~SystemExec */
391 #if 1 /* DEBUG */
392         if (debug_enable) { /* tentative debug mode */
393         printf("EXPORT ENCODE:\n");
394         for (int i=0; i< a; ++i) {
395           printf("%s ", argp[i]);
396         }
397         printf("\n");
398         }
399 #endif
400
401         ffcmd = new ARDOUR::SystemExec(ffmpeg_exe, argp);
402         ffcmd->ReadStdout.connect_same_thread (*this, boost::bind (&TranscodeFfmpeg::ffmpegparse_v, this, _1 ,_2));
403         ffcmd->Terminated.connect (*this, invalidator (*this), boost::bind (&TranscodeFfmpeg::ffexit, this), gui_context());
404         if (ffcmd->start(2)) {
405                 ffexit();
406                 return false;
407         }
408         return true;
409 }
410
411 bool
412 TranscodeFfmpeg::extract_audio (std::string outfile, ARDOUR::framecnt_t /*samplerate*/, unsigned int stream)
413 {
414         if (!probeok) return false;
415   if (stream >= m_audio.size()) return false;
416
417         char **argp;
418         int i = 0;
419
420         argp=(char**) calloc(15,sizeof(char*));
421         argp[i++] = strdup(ffmpeg_exe.c_str());
422         argp[i++] = strdup("-i");
423         argp[i++] = strdup(infile.c_str());
424 #if 0 /* ffmpeg write original samplerate, use a3/SRC to resample */
425         argp[i++] = strdup("-ar");
426         argp[i] = (char*) calloc(7,sizeof(char)); snprintf(argp[i++], 7, "%"PRId64, samplerate);
427 #endif
428         argp[i++] = strdup("-ac");
429         argp[i] = (char*) calloc(3,sizeof(char)); snprintf(argp[i++], 3, "%i", m_audio.at(stream).channels);
430         argp[i++] = strdup("-map");
431         argp[i] = (char*) calloc(8,sizeof(char)); snprintf(argp[i++], 8, "0:%s", m_audio.at(stream).stream_id.c_str());
432         argp[i++] = strdup("-vn");
433         argp[i++] = strdup("-acodec");
434         argp[i++] = strdup("pcm_f32le");
435         argp[i++] = strdup("-y");
436         argp[i++] = strdup(outfile.c_str());
437         argp[i++] = (char *)0;
438         /* Note: argp is free()d in ~SystemExec */
439 #if 1 /* DEBUG */
440         if (debug_enable) { /* tentative debug mode */
441         printf("EXTRACT AUDIO:\n");
442         for (int i=0; i< 14; ++i) {
443           printf("%s ", argp[i]);
444         }
445         printf("\n");
446         }
447 #endif
448
449         ffcmd = new ARDOUR::SystemExec(ffmpeg_exe, argp);
450         ffcmd->ReadStdout.connect_same_thread (*this, boost::bind (&TranscodeFfmpeg::ffmpegparse_a, this, _1 ,_2));
451         ffcmd->Terminated.connect (*this, invalidator (*this), boost::bind (&TranscodeFfmpeg::ffexit, this), gui_context());
452         if (ffcmd->start(2)) {
453                 ffexit();
454                 return false;
455         }
456         return true;
457 }
458
459
460 bool
461 TranscodeFfmpeg::transcode (std::string outfile, const int outw, const int outh, const int kbitps)
462 {
463         if (!probeok) return false;
464
465         char **argp;
466         int bitrate = kbitps;
467         int width = outw;
468         int height = outh;
469
470         if (width < 1 || width > m_width) { width = m_width; } /* don't allow upscaling */
471         if (height < 1 || height > m_height) { height = floor(width / m_aspect); }
472
473         if (bitrate == 0) {
474                 const double bitperpixel = .7; /* avg quality */
475                 bitrate = floor(m_fps * width * height * bitperpixel / 10000.0);
476         } else {
477                 bitrate = bitrate / 10;
478         }
479         if (bitrate < 10)  bitrate = 10;
480         if (bitrate > 1000) bitrate = 1000;
481
482         argp=(char**) calloc(16,sizeof(char*));
483         argp[0] = strdup(ffmpeg_exe.c_str());
484         argp[1] = strdup("-i");
485         argp[2] = strdup(infile.c_str());
486         argp[3] = strdup("-b:v");
487         argp[4] = (char*) calloc(7,sizeof(char)); snprintf(argp[4], 7, "%i0k", bitrate);
488         argp[5] = strdup("-s");
489         argp[6] = (char*) calloc(10,sizeof(char)); snprintf(argp[6], 10, "%ix%i", width, height);
490         argp[7] = strdup("-y");
491         argp[8] = strdup("-vcodec");
492         argp[9] = strdup("mjpeg");
493         argp[10] = strdup("-an");
494         argp[11] = strdup("-intra");
495         argp[12] = strdup("-g");
496         argp[13] = strdup("1");
497         argp[14] = strdup(outfile.c_str());
498         argp[15] = (char *)0;
499         /* Note: these are free()d in ~SystemExec */
500 #if 1 /* DEBUG */
501         if (debug_enable) { /* tentative debug mode */
502         printf("TRANSCODE VIDEO:\n");
503         for (int i=0; i< 15; ++i) {
504           printf("%s ", argp[i]);
505         }
506         printf("\n");
507         }
508 #endif
509         ffcmd = new ARDOUR::SystemExec(ffmpeg_exe, argp);
510         ffcmd->ReadStdout.connect_same_thread (*this, boost::bind (&TranscodeFfmpeg::ffmpegparse_v, this, _1 ,_2));
511         ffcmd->Terminated.connect (*this, invalidator (*this), boost::bind (&TranscodeFfmpeg::ffexit, this), gui_context());
512         if (ffcmd->start(2)) {
513                 ffexit();
514                 return false;
515         }
516         return true;
517 }
518
519 void
520 TranscodeFfmpeg::cancel ()
521 {
522         if (!ffcmd || !ffcmd->is_running()) { return;}
523         ffcmd->write_to_stdin("q");
524 #ifdef PLATFORM_WINDOWS
525         Sleep(1000);
526 #else
527         sleep (1);
528 #endif
529         if (ffcmd) {
530           ffcmd->terminate();
531         }
532 }
533
534 void
535 TranscodeFfmpeg::ffexit ()
536 {
537         delete ffcmd;
538         ffcmd=0;
539         Finished(); /* EMIT SIGNAL */
540 }
541
542 void
543 TranscodeFfmpeg::ffprobeparse (std::string d, size_t /* s */)
544 {
545         ffoutput+=d;
546 }
547
548 void
549 TranscodeFfmpeg::ffmpegparse_a (std::string d, size_t /* s */)
550 {
551         const char *t;
552         int h,m,s; char f[7];
553         ARDOUR::framecnt_t p = -1;
554
555         if (!(t=strstr(d.c_str(), "time="))) { return; }
556
557         if (sscanf(t+5, "%d:%d:%d.%s",&h,&m,&s,f) == 4) {
558                 p = (ARDOUR::framecnt_t) floor( 100.0 * (
559                       h * 3600.0
560                     + m * 60.0
561                     + s * 1.0
562                     + atoi(f) / pow((double)10, (int)strlen(f))
563                 ));
564                 p = p * m_fps / 100.0;
565                 if (p > m_duration ) { p = m_duration; }
566                 Progress(p, m_duration); /* EMIT SIGNAL */
567         } else {
568                 Progress(0, 0); /* EMIT SIGNAL */
569         }
570 }
571
572 void
573 TranscodeFfmpeg::ffmpegparse_v (std::string d, size_t /* s */)
574 {
575         if (strstr(d.c_str(), "ERROR") || strstr(d.c_str(), "Error") || strstr(d.c_str(), "error")) {
576                 warning << "ffmpeg-error: " << d << endmsg;
577         }
578         if (strncmp(d.c_str(), "frame=",6)) {
579 #if 1 /* DEBUG */
580                 if (debug_enable) {
581                         d.erase(d.find_last_not_of(" \t\r\n") + 1);
582                   printf("ffmpeg: '%s'\n", d.c_str());
583                 }
584 #endif
585                 Progress(0, 0); /* EMIT SIGNAL */
586                 return;
587         }
588         ARDOUR::framecnt_t f = atol(d.substr(6));
589         if (f == 0) {
590                 Progress(0, 0); /* EMIT SIGNAL */
591         } else {
592                 Progress(f, m_duration); /* EMIT SIGNAL */
593         }
594 }