After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 673319 - Need to use \\\\ for filenames containing '\' when using gst-launch
Need to use \\\\ for filenames containing '\' when using gst-launch
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
unspecified
Other Linux
: Normal normal
: 0.11.x
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-04-01 20:28 UTC by Christophe Fergeau
Modified: 2016-05-28 18:42 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Christophe Fergeau 2012-04-01 20:28:35 UTC
I've been trying to run
gst-launch filesrc location="/home/teuf/Musique/Röyksopp - Melody A.M./10. Röyksopp - 40 Years Back\\Come.flac" !            decodebin name=decode ! audio/x-raw-int !            appsink name=sink sync=False emit-signals=True

(note the \\ in the filename). The file I'm trying to handle is '40 Years Back\Come.flac', the \\ in the command line is for shell escaping.
echo "40 Years Back\\Come.flac" gives me the expected '40 Years Back\Come.flac'

However, this does not work with GStreamer, it wants the \ to be escaped in the filename it gets, otherwise it will fail with "could not find 40 Years BackCome.flac"

This comes from the fact that gst_parse_unescape in gst/parse/types.h turns '\x' into 'x' whatever x is, so with a single '\', '\C' will be turned into 'C'. With '\\', it's turned into '\' as expected.

gst/gstparse.c has a _gst_parse_escape function which escapes \" as needed, but it doesn't do anything for '\'. This patch would handle escaping there and fixes the issues I'm seeing:

diff --git a/gst/gstparse.c b/gst/gstparse.c
index a2d3d3d..05d696e 100644
--- a/gst/gstparse.c
+++ b/gst/gstparse.c
@@ -197,7 +197,7 @@ _gst_parse_escape (const gchar * str)
   gstr = g_string_sized_new (strlen (str));
 
   while (*str) {
-    if (*str == ' ')
+    if ((*str == ' ') || (*str == '\\'))
       g_string_append_c (gstr, '\\');
     g_string_append_c (gstr, *str);
     str++;

However, changing this behaviour might be undesirable (for example http://sourceforge.net/projects/gsvideo/files/gsvideo/1.0/ says "Single backslashes are replaced by double backslashes to avoid path problems in gstreamer"), or this behaviour might even be on purpose, so let me know if I should make a proper git-formatted patch, or if this bug should be closed :)
Comment 1 Tim-Philipp Müller 2012-06-27 19:13:57 UTC
commit dd9fedb41f1ada8e1f8bd5346fccd3d068d543cb
Author: Christophe Fergeau <teuf@gnome.org>
Date:   Wed Jun 27 19:59:29 2012 +0100

    parse: escape \ with a \ as well, so that we don't lose the \ when unescaping
    
    If we have a file called Foo\Bar.ogg, there is no way to pass
    that filename properly to filesrc in gst_parse_launch(), since
    gst_parse_unescape() will just unescape \x to x.
    
    Not cherry-picking this into 0.10 since there are apparently
    apps that work around this problem and which would break if
    we fixed it there too.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=673319
Comment 2 Wim Taymans 2012-06-28 07:59:01 UTC
This breaks: 

gst-launch-1.0 udpsrc caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, sprop-parameter-sets=(string)\"Z2QAHqxtAUB7YCIAAAMAAgAAAwB5HixdQAA\\=\\,aO8yyLA\\=\", payload=(int)96, ssrc=(uint)846275340, timestamp-offset=(uint)2737692532, seqnum-offset=(uint)31335" ! rtpjitterbuffer ! rtph264depay ! avdec_h264 ! xvimagesink -v

where the caps are pasted from:

gst-launch-1.0 v4l2src ! x264enc tune=zerolatency intra-refresh=1 ! rtph264pay ! udpsink -v
Comment 3 Tim-Philipp Müller 2016-05-28 18:42:38 UTC
$ gst-launch-1.0 v4l2src ! x264enc tune=zerolatency intra-refresh=1 ! rtph264pay ! udpsink -v
...
udpsink0.sink: caps = application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, packetization-mode=(string)1, profile-level-id=(string)64001f, sprop-parameter-sets=(string)"Z2QAH6wjQCgC3YCIAAADAAgAAAMB5HjBlQ\=\=\,aO8yyLA\=", payload=(int)96, ssrc=(uint)1659706014, timestamp-offset=(uint)3252565718, seqnum-offset=(uint)27292, a-framerate=(string)30

$ gst-launch-1.0 -v udpsrc caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, packetization-mode=(string)1, profile-level-id=(string)64001f, sprop-parameter-sets=(string)"Z2QAH6wjQCgC3YCIAAADAAgAAAMB5HjBlQ\=\=\,aO8yyLA\=", payload=(int)96, ssrc=(uint)1659706014, timestamp-offset=(uint)3252565718, seqnum-offset=(uint)27292, a-framerate=(string)30' ! fakesink
...
  udpsrc0.src: caps = application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, packetization-mode=(string)1, profile-level-id=(string)64001f, sprop-parameter-sets=(string)"Z2QAH6wjQCgC3YCIAAADAAgAAAMB5HjBlQ\=\=\,aO8yyLA\=", payload=(int)96, ssrc=(uint)1659706014, timestamp-offset=(uint)3252565718, seqnum-offset=(uint)27292, a-framerate=(string)30