issue with spaces in filesink location

Antonio Ospite ao2 at ao2.it
Thu Dec 9 21:54:17 UTC 2021


On Thu, 9 Dec 2021 18:56:50 +0100
Pablo Rodríguez via gstreamer-devel
<gstreamer-devel at lists.freedesktop.org> wrote:

> Dear list,
> 
> I have the following sample:
> 
[...]
> 
> My error should have a simple fix, but how can I get that filesink
> accepts URI to set the output file?

filesink accepts locations as local paths, not URIs, it will convert
the filename to a URI internally, as you can see if you set
GST_DEBUG=filesink:4, but this is a detail.

> Otherwise, GStreamer seems to have problems with spaces in filenames.
> 
> Sorry for the very basic question,  but I don’t have any idea on what I
> am missing.
> 

I think in this case it's just a string quoting issue with
Gst.parse_launch:


--- test.py.orig	2021-12-09 22:35:28.799918078 +0100
+++ test.py	2021-12-09 22:41:13.674250115 +0100
@@ -11,8 +11,7 @@ Gst.init(sys.argv)
 class wreck:
     def __init__(self):
 
-        # ~ self.audiofilename = sys.argv[1]
-        self.audiofilename = sys.argv[1].replace(" ", "%20")
+        self.audiofilename = sys.argv[1]
 
         self.win = Gtk.Window(Gtk.WindowType.TOPLEVEL)
 
@@ -24,7 +23,7 @@ class wreck:
 
         self.win.connect('key-press-event', self.key_press_event)
 
-        self.player = Gst.parse_launch("autoaudiosrc ! audio/x-raw !  wavenc ! filesink location=" + self.audiofilename)
+        self.player = Gst.parse_launch("autoaudiosrc ! audio/x-raw !  wavenc ! filesink location=\"" + self.audiofilename + "\"")
 
         bus = self.player.get_bus()
 
@@ -36,7 +35,6 @@ class wreck:
         if t == Gst.MessageType.EOS:
             self.player.set_state(Gst.State.NULL)
             Gtk.main_quit()
-            os.rename(self.audiofilename, self.audiofilename.replace("%20", " "))
         elif t == Gst.MessageType.ERROR:
             err, debug = message.parse_error()
             print ("Error: %s" % err, debug)


Ciao,
   Antonio

-- 
Antonio Ospite
https://ao2.it
https://twitter.com/ao2it

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?


More information about the gstreamer-devel mailing list