Posted By

rowntreerob on 02/15/12


Tagged

rtsp audio YouTube


Versions (?)

youtube rtsp CLI request - AUDIO TRACK only P2


 / Published in: Bash
 

URL: http://snipplr.com/view/57846/curl--rtsp-to-get-sdp-descriptor-for-media-stream/

From a std page containing youtube video, how could you drill down to the youtube rtsp for that specific video and then get just the audio track?

  1. --display the source from the page, even if it is flash, you should see the youtube videoID as below:
  2.  
  3. <param name="movie" value="http://www.youtube.com/v/kgfctMNeDtg?version=3&amp;feature=player_detailpage">
  4.  
  5. videoID=kgfctMNeDtg
  6.  
  7. --use the api in order to get the url for the yt:format=1 feed type containing the AMR-NB audio track. This is good quality at low bandwidth
  8.  
  9. REQ:
  10. https://gdata.youtube.com/feeds/api/videos/kgfctMNeDtg?fields=media%3Agroup%2Fmedia%3Acontent%5B%40yt%3Aformat%3D%221%22%5D&v=2
  11.  
  12. response:
  13. <entry xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/'
  14. xmlns:yt='http://gdata.youtube.com/schemas/2007'><media:group><media:content
  15. url='rtsp://v6.cache3.c.youtube.com/CiILENy73wIaGQnYDl7DtNwHkhMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp'
  16. type='video/3gpp' medium='video' expression='full' duration='1340' yt:format='1'/></media:group></entry>
  17.  
  18. --get the url tag from the above and use that url with a curl program -
  19. src at the URL above - to request the RTSP DESCRIBE which returns the SDP
  20. (detailed data on audio/video tracks) for the format type=1 video
  21.  
  22. $ ./rtsp_client.exe rtsp://v6.cache3.c.youtube.com/CiILENy73wIaGQnYDl7DtNwHkhMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp
  23.  
  24. rtsp://v6.cache3.c.youtube.com/CiILENy73wIaGQnYDl7DtNwHkhMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp
  25. * About to connect() to v6.cache3.c.youtube.com port 554 (#0)
  26. * Trying 74.125.213.85... * connected
  27. * Connected to v6.cache3.c.youtube.com (74.125.213.85) port 554 (#0)
  28. > OPTIONS rtsp://v6.cache3.c.youtube.com/CiILENy73wIaGQnYDl7DtNwHkhMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp RTSP/1.0
  29. CSeq: 1
  30.  
  31. < RTSP/1.0 200 OK
  32. RTSP/1.0 200 OK
  33. < Public: DESCRIBE, GET_PARAMETER, OPTIONS, PAUSE, PLAY, SETUP, SET_PARAMETER, TEARDOWN
  34. Public: DESCRIBE, GET_PARAMETER, OPTIONS, PAUSE, PLAY, SETUP, SET_PARAMETER, TEARDOWN
  35. < CSeq: 1
  36. CSeq: 1
  37. < Server: Google RTSP 1.0
  38. Server: Google RTSP 1.0
  39.  
  40. <
  41. * Connection #0 to host v6.cache3.c.youtube.com left intact
  42. OPTIONS Response Code: 200
  43.  
  44. * Re-using existing connection! (#0) with host v6.cache3.c.youtube.com
  45. * Connected to v6.cache3.c.youtube.com (74.125.213.85) port 554 (#0)
  46. > DESCRIBE rtsp://v6.cache3.c.youtube.com/CiILENy73wIaGQnYDl7DtNwHkhMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp RTSP/1.0
  47. CSeq: 2
  48. If-Modified-Since: Thu, 01 Jan 1970 00:00:00 GMT
  49. Accept: application/x-rtsp-mh, application/rtsl, application/sdp
  50.  
  51. < RTSP/1.0 200 OK
  52. RTSP/1.0 200 OK
  53. < Content-Type: application/sdp
  54. Content-Type: application/sdp
  55.  
  56. Content-Base: rtsp://v6.cache3.c.youtube.com/CiILENy73wIaGQnYDl7DtNwHkhMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp/
  57.  
  58. ***** SDP ******
  59. <
  60. v=0
  61. o=GoogleStreamer 1207646401 1781229825 IN IP4 74.125.213.85
  62. s=Video
  63. c=IN IP4 0.0.0.0
  64. b=AS:61
  65. t=0 0
  66. a=control:*
  67. a=range:npt=0-1339.133000
  68. m=video 0 RTP/AVP 98
  69. b=AS:49
  70. a=rtpmap:98 H263-2000/90000
  71. a=control:trackID=0
  72. a=cliprect:0,0,144,176
  73. a=framesize:98 176-144
  74. a=fmtp:98 profile=0;level=10
  75. m=audio 0 RTP/AVP 99
  76. b=AS:12
  77. a=rtpmap:99 AMR/8000/1
  78. a=control:trackID=1
  79. a=fmtp:99 octet-align
  80. * Connection #0 to host v6.cache3.c.youtube.com left intact
  81. DESCRIBE Response Code: 200
  82.  
  83. --m=audio section mentions encoding details
  84. 12K bandwidth
  85. AMR/8000/1 on track 1
  86.  
  87. -- and RTP packet details
  88. type 99 from rfc2198

Report this snippet  

You need to login to post a comment.