Commits

Anonymous committed 94d0920

Added timestamp representation. Trying to call repr seems to hang after
playback... due to the other threads grabbing and releasing the GIL all
the time.

  • Participants
  • Parent commits a0c3fc8
  • Branches tylerthemovie

Comments (0)

Files changed (2)

File src/_gmovie.c

     err = av_open_input_file(&ic, is->filename, is->iformat, 0, ap);
     if (err < 0) {
     	GRABGIL
-        PyErr_Format(PyExc_IOError, "There was a problem opening up %s", is->filename);
+        PyErr_Format(PyExc_IOError, "There was a problem opening up %s, due to %i", is->filename, err);
         RELEASEGIL
         ret = -1;
         goto fail;

File src/gmovie.c

     return 0;
 }   
 
- void _movie_dealloc(PyMovie *movie)
+void _movie_dealloc(PyMovie *movie)
 {
     stream_close(movie);
     movie->ob_type->tp_free((PyObject *) movie);
 }
 
- PyObject* _movie_repr (PyMovie *movie)
+char *format_timestamp(double pts, char *buf)
+{
+	int h, m;
+	double s;
+	if(pts/60 > 60)
+	{
+		h = (int)pts/3600;
+		pts = pts-h*3600;
+	}
+	else
+	{
+		h=0;
+	}
+	m=(int)pts/60;
+	if(m>0)
+	{
+		s = pts-m*60;
+	}
+	else
+	{
+		s = pts;
+		m=0;
+	}
+	//char buf[50];
+	if(h>0 && m>0)
+	{
+		PyOS_snprintf(buf, sizeof(buf), "%ih, %im, %fs", h, m, s);
+	}	
+	else if (m>0)
+	{
+		PyOS_snprintf(buf, sizeof(buf), "%im, %fs", m, s);
+	}
+	else if(s>0)
+	{
+		PyOS_snprintf(buf, sizeof(buf), "%fs", s);
+	}
+	else
+	{
+		PyOS_snprintf(buf, sizeof(buf), "0.0s");
+	}
+	return buf;
+}
+
+PyObject* _movie_repr (PyMovie *movie)
 {
     /*Eventually add a time-code call */
     DECLAREGIL
     GRABGIL
     Py_INCREF(movie);
-    char buf[100];
-    PyOS_snprintf(buf, sizeof(buf), "(Movie: %s)", movie->filename);
+    char buf[150];
+    char buf2[50];
+    PyOS_snprintf(buf, sizeof(buf), "(Movie: %s, %s)", movie->filename, format_timestamp(movie->pts, buf2));
     Py_DECREF(movie);
     PyObject *buffer = PyString_FromString(buf);
     RELEASEGIL