FAQ  •  Register  •  Login

ffmpeg with rtmp and parameters with spaces

<<

jules

DLNA master

Posts: 173

Joined: Sat Feb 02, 2013 10:21 am

Post Sat Feb 02, 2013 1:26 pm

ffmpeg with rtmp and parameters with spaces

hey,

i've been trying to tackle the implementation of a justin/twitch.tv plugin from knowledge i acquired from writing a script that creates a command line to pipe output from rtmpdump to vlc. the latter works fine.

i'm having an issue with the syntax of the ffmpeg call though: ffmpeg takes information from rtmp streams with this syntax:

  Code:
ffmpeg -i "rtmp://<ip> app=<path> playpath=<some string> swfUrl=<swf's url> swfVfy=1 live=1 jtv=<jtv token>"


now, all of the parameters are known to me. the problem is the makeup of the jtv token: it's a JSON string that CANNOT be passed any differently than the way it is retrieved from the server. so no taking out spaces or anything. it looks similar to this:

  Code:
52544314439a0c88d583f06f727bb1339965fbc2:{\"swfDomains\": [\"justin.tv\", \"jtvx.com\", \"xarth.com\", \"twitchtv.com\", \"twitch.tv\", \"newjtv.com\", \"jtvnw.net\", \"wdtinc.com\", \"imapweather.com\", \"facebook.com\", \"starcrafting.com\"], \"streamName\": \"jtv_cRCoqV_xjommpbt_\", \"expiration\": 1359813036.9245951, \"server\": \"video14-2.ams01\"}


it includes the following: spaces and double quotation marks. using single quotation marks ( ' ) for values is not valid JSON.

as you can see, i've already escaped the quotation marks as they'd interfer with the quotation mark of the command line. the problem is that i don't know how to encapsulate that string so that it reads jtv="<jtv-string>", but that all three sets of quotation mark levels are still retained. like this (aside from the fact that this would obviously be incorrect):
  Code:
ffmpeg -i "rtmp... jtv="somestuff:{ "foo": "bar" }""

i need the additional level of quotation marks because there are spaces in that jtv token, which will cause ffmpeg to interpret them as additional parameters to the rtmp uri. i've tried single quotation marks ( ' ) to encapsulate the jtv string, but that gave me the same error.

any ideas?
<<

jules

DLNA master

Posts: 173

Joined: Sat Feb 02, 2013 10:21 am

Post Sat Feb 02, 2013 8:23 pm

Re: ffmpeg with rtmp and parameters with spaces

alright, i found a solution.

the above example would have to look like this:
  Code:
ffmpeg -i "rtmp://<ip> app=<path> playpath=<some string> swfUrl=<swf's url> swfVfy=1 live=1 jtv=52544314439a0c88d583f06f727bb1339965fbc2:{\"swfDomains\":\20[\"justin.tv\",\20\"jtvx.com\",\20\"xarth.com\",\20\"twitchtv.com\",\20\"twitch.tv\",\20\"newjtv.com\",\20\"jtvnw.net\",\20\"wdtinc.com\",\20\"imapweather.com\",\20\"facebook.com\",\20\"starcrafting.com\"],\20\"streamName\":\20\"jtv_cRCoqV_xjommpbt_\",\20\"expiration\":\201359813036.9245951,\20\"server\":\20\"video14-2.ams01\"}"


in summary:
  • no quotation marks around the jtv value
  • replace spaces by \20 (ascii code for space).

this at least works under windows, i'll check out how it'd do in a plugin.

Return to Plugin development

Who is online

Users browsing this forum: No registered users and 17 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.