youtube rtsp CLI request - AUDIO TRACK only


/ Published in: Bash
Save to your folder(s)

youtube cloud to store a video clip where client app wants only amr-nb audio.
tactic to make good use of bandwidth over 3G...


Copy this code and paste it in your HTML
  1. $ ./openRTSP -a rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp | \
  2. ./mplayer -cache 8092 - -rawaudio channels=1:rate=8000:samplesize=2:format=0x73616D72
  3.  
  4. -- OR using 2 steps...
  5.  
  6. $ ./openRTSP -a rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp | cat > test_audio_only_rtsp
  7.  
  8. $ ../mplayer -rawaudio channels=1:rate=8000:samplesize=2:format=0x73616D72 test_audio_only_rtsp
  9.  
  10. play download on android client:
  11.  
  12. new Intent(Intent.ACTION_VIEW).setDataAndType(Uri.parse("file:///mnt/sdcard/test_audio_only_rtsp.3gpp"), "audio/amr");
  13.  
  14. --DESCRIPTION
  15.  
  16. rtsp session & protocol by 'openrtsp' ( DESCRIBE, SETUP, PLAY ) on just the audio track belonging to the .3gp container.
  17. pipe the raw stream to 'mplayer' which demuxes the combined RTP/encoded AUDIO .
  18. mplayer plays the audio after interval in which the entire clip streams thru cache.
  19.  
  20. implication - i could not figure out a shared buffer arraingement where its ready to play as soon as small buffer loads?? rather, the entire clip needs to load to cache BEFORE the player takes over.
  21.  
  22. --prereq
  23. http://code.google.com/apis/youtube/2.0/developers_guide_protocol_understanding_video_feeds.html <-- for the rtsp links
  24.  
  25. http://gdata.youtube.com/feeds/api/videos?orderby=updated&vq=$ID
  26. OR
  27. http://gdata.youtube.com/feeds/api/users/${user}/uploads?orderby=updated&vq=$ID <--- sample request
  28.  
  29. RESPONSE: excerpt covering rtsp links:
  30.  
  31. <media:content url='rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp'
  32. type='video/3gpp' medium='video' expression='full' duration='64' yt:format='1'/>
  33. <media:content url='rtsp://v4.cache4.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYESARFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp'
  34. type='video/3gpp' medium='video' expression='full' duration='64' yt:format='6'/><media:description
  35.  
  36. --NOTE:
  37. from feed response, parse for 'yt:format='1'' for low bandwidth and for mobile suitability
  38. So, in this instance, choose the v8.cache8 link as a connection to request using a Cli BASED rtsp client...
  39.  
  40. --Cygwin example using ( mplayer, openRTSP )... for amr-nb audio at 8000 rate
  41.  
  42. SDP INFO (audio only):
  43. m=audio 0 RTP/AVP 99
  44. b=AS:12 /*bandwidth mas =12kbs*/
  45. a=rtpmap:99 AMR/8000/1
  46. a=control:trackID=1
  47. a=fmtp:99 octet-align
  48.  
  49. codec details from header file used by 'mplayer':
  50.  
  51. {{ 0x726D6173, 87, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -0 }, /* fourccmap */
  52. { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* outfmt */
  53. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* outflags */
  54. { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* infmt */
  55. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* inflags */
  56. "ffamrnb", /* name */
  57. "AMR Narrowband", /* info */
  58. NULL, /* comment */
  59. "amrnb", /* dll */
  60. "ffmpeg", /* drv */
  61.  
  62. --- stdout FOR 2 STEP METHOD
  63.  
  64. $ ./openRTSP -a rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp | \
  65. cat > test_audio_only_rtsp
  66.  
  67. Opening connection to 74.125.212.247, port 554...
  68. ...remote connection opened
  69. Sending request: OPTIONS rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp RTSP/1.0
  70. CSeq: 2
  71. User-Agent: ./testProgs/openRTSP (LIVE555 Streaming Media v2011.07.08)
  72.  
  73.  
  74. Received 140 new bytes of response data.
  75. Received a complete OPTIONS response:
  76. RTSP/1.0 200 OK
  77. Public: DESCRIBE, GET_PARAMETER, OPTIONS, PAUSE, PLAY, SETUP, SET_PARAMETER, TEARDOWN
  78. CSeq: 2
  79. Server: Google RTSP 1.0
  80.  
  81.  
  82. Sending request: DESCRIBE rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp RTSP/1.0
  83. CSeq: 3
  84. User-Agent: ./testProgs/openRTSP (LIVE555 Streaming Media v2011.07.08)
  85. Accept: application/sdp
  86.  
  87.  
  88. Received 786 new bytes of response data.
  89. Received a complete DESCRIBE response:
  90. RTSP/1.0 200 OK
  91. Content-Type: application/sdp
  92. Cache-Control: must-revalidate
  93. Date: Wed, 13 Jul 2011 21:01:21 GMT
  94. Expires: Wed, 13 Jul 2011 21:01:21 GMT
  95. Last-Modified: Wed, 13 Jul 2011 21:01:21 GMT
  96. Content-Base: rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp/
  97. CSeq: 3
  98. Server: Google RTSP 1.0
  99. Content-Length: 406
  100.  
  101. v=0
  102. o=GoogleStreamer 1946436214 1631140309 IN IP4 74.125.212.247
  103. s=Video
  104. c=IN IP4 0.0.0.0
  105. b=AS:51
  106. t=0 0
  107. a=control:*
  108. a=range:npt=0-63.800000
  109. m=video 0 RTP/AVP 98
  110. b=AS:39
  111. a=rtpmap:98 H263-2000/90000
  112. a=control:trackID=0
  113. a=cliprect:0,0,144,176
  114. a=framesize:98 176-144
  115. a=fmtp:98 profile=0;level=10
  116. m=audio 0 RTP/AVP 99
  117. b=AS:12
  118. a=rtpmap:99 AMR/8000/1
  119. a=control:trackID=1
  120. a=fmtp:99 octet-align
  121.  
  122. Opened URL "rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp", returning a SDP description:
  123. v=0
  124. o=GoogleStreamer 1946436214 1631140309 IN IP4 74.125.212.247
  125. s=Video
  126. c=IN IP4 0.0.0.0
  127. b=AS:51
  128. t=0 0
  129. a=control:*
  130. a=range:npt=0-63.800000
  131. m=video 0 RTP/AVP 98
  132. b=AS:39
  133. a=rtpmap:98 H263-2000/90000
  134. a=control:trackID=0
  135. a=cliprect:0,0,144,176
  136. a=framesize:98 176-144
  137. a=fmtp:98 profile=0;level=10
  138. m=audio 0 RTP/AVP 99
  139. b=AS:12
  140. a=rtpmap:99 AMR/8000/1
  141. a=control:trackID=1
  142. a=fmtp:99 octet-align
  143.  
  144. Ignoring "video/H263-2000" subsession, because we''ve asked to receive a single audio session only
  145. Created receiver for "audio/AMR" subsession (client ports 64498-64499)
  146. Sending request: SETUP rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp/trackID=1 RTSP/1.0
  147. CSeq: 4
  148. User-Agent: ./testProgs/openRTSP (LIVE555 Streaming Media v2011.07.08)
  149. Transport: RTP/AVP;unicast;client_port=64498-64499
  150.  
  151.  
  152. Received 360 new bytes of response data.
  153. Received a complete SETUP response:
  154. RTSP/1.0 200 OK
  155. Session: 70cd7f38;timeout=90
  156. Transport: RTP/AVP;unicast;mode=play;client_port=64498-64499;server_port=10580-10581;source=74.125.212.247;ssrc=50DF166F
  157. Cache-Control: must-revalidate
  158. Date: Wed, 13 Jul 2011 21:01:23 GMT
  159. Expires: Wed, 13 Jul 2011 21:01:23 GMT
  160. Last-Modified: Wed, 13 Jul 2011 21:01:23 GMT
  161. CSeq: 4
  162. Server: Google RTSP 1.0
  163.  
  164.  
  165. Setup "audio/AMR" subsession (client ports 64498-64499)
  166. Outputting data from the "audio/AMR" subsession to 'stdout'
  167. Sending request: PLAY rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp/ RTSP/1.0
  168. CSeq: 5
  169. User-Agent: ./testProgs/openRTSP (LIVE555 Streaming Media v2011.07.08)
  170. Session: 70cd7f38
  171. Range: npt=0.000-63.800
  172.  
  173.  
  174. Received 265 new bytes of response data.
  175. Received a complete PLAY response:
  176. RTSP/1.0 200 OK
  177. Session: 70cd7f38;timeout=90
  178. Range: npt=0.000-63.800
  179. RTP-Info: url=rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp/trackID=1;seq=31872;rtptime=272756789
  180. CSeq: 5
  181. Server: Google RTSP 1.0
  182.  
  183.  
  184. Started playing session
  185. Receiving streamed data (for up to 68.800000 seconds)...
  186. Sending request: TEARDOWN rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp/ RTSP/1.0
  187. CSeq: 6
  188. User-Agent: ./testProgs/openRTSP (LIVE555 Streaming Media v2011.07.08)
  189. Session: 70cd7f38
  190.  
  191.  
  192. Received 72 new bytes of response data.
  193. Received a complete TEARDOWN response:
  194. RTSP/1.0 200 OK
  195. CSeq: 6
  196. Session: 70cd7f38
  197. Server: Google RTSP 1.0
  198.  
  199. ======= STEP 2
  200.  
  201. $ ./mplayer -rawaudio channels=1:rate=8000:samplesize=2:format=0x73616D72 test_audio_only_rtsp
  202.  
  203. MPlayer SVN-r33847-3.4.4 (C) 2000-2011 MPlayer Team
  204.  
  205. Playing test_audio_only_rtsp.
  206. Invalid seek to negative position ffffffffffffffff!
  207. libavformat file format detected.
  208. [amr @ 0x1c507f0] max_analyze_duration 5000000 reached at 5000000
  209. [amr @ 0x1c507f0] Estimating duration from bitrate, this may be inaccurate
  210. [lavf] stream 0: audio (amrnb), -aid 0
  211. Load subtitles in ./
  212. ==========================================================================
  213. Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
  214. AUDIO: 8000 Hz, 1 ch, floatle, 12.8 kbit/5.00% (ratio: 1600->32000)
  215. Selected audio codec: [ffamrnb] afm: ffmpeg (AMR Narrowband)
  216. ==========================================================================
  217. AO: [win32] 8000Hz 1ch s16le (2 bytes per sample)
  218. Video: no video
  219. Starting playback...
  220. A: 59.9 (59.8) of 63.6 (01:03.5) 0.0%
  221.  
  222.  
  223. Exiting... (End of file)

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.