GNOME Bugzilla – Bug 673319
Need to use \\\\ for filenames containing '\' when using gst-launch
Last modified: 2016-05-28 18:42:38 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 :)
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
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
$ 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