/ Published in: Bash
youtube cloud to store a video clip where client app wants only amr-nb audio.
tactic to make good use of bandwidth over 3G...
tactic to make good use of bandwidth over 3G...
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$ ./openRTSP -a rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp | \ ./mplayer -cache 8092 - -rawaudio channels=1:rate=8000:samplesize=2:format=0x73616D72 -- OR using 2 steps... $ ./openRTSP -a rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp | cat > test_audio_only_rtsp $ ../mplayer -rawaudio channels=1:rate=8000:samplesize=2:format=0x73616D72 test_audio_only_rtsp play download on android client: new Intent(Intent.ACTION_VIEW).setDataAndType(Uri.parse("file:///mnt/sdcard/test_audio_only_rtsp.3gpp"), "audio/amr"); --DESCRIPTION rtsp session & protocol by 'openrtsp' ( DESCRIBE, SETUP, PLAY ) on just the audio track belonging to the .3gp container. pipe the raw stream to 'mplayer' which demuxes the combined RTP/encoded AUDIO . mplayer plays the audio after interval in which the entire clip streams thru cache. 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. --prereq http://code.google.com/apis/youtube/2.0/developers_guide_protocol_understanding_video_feeds.html <-- for the rtsp links http://gdata.youtube.com/feeds/api/videos?orderby=updated&vq=$ID OR http://gdata.youtube.com/feeds/api/users/${user}/uploads?orderby=updated&vq=$ID <--- sample request RESPONSE: excerpt covering rtsp links: <media:content url='rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='64' yt:format='1'/> <media:content url='rtsp://v4.cache4.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYESARFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='64' yt:format='6'/><media:description --NOTE: from feed response, parse for 'yt:format='1'' for low bandwidth and for mobile suitability So, in this instance, choose the v8.cache8 link as a connection to request using a Cli BASED rtsp client... --Cygwin example using ( mplayer, openRTSP )... for amr-nb audio at 8000 rate SDP INFO (audio only): m=audio 0 RTP/AVP 99 b=AS:12 /*bandwidth mas =12kbs*/ a=rtpmap:99 AMR/8000/1 a=control:trackID=1 a=fmtp:99 octet-align codec details from header file used by 'mplayer': {{ 0x726D6173, 87, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -0 }, /* fourccmap */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* outfmt */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* outflags */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, /* infmt */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* inflags */ "ffamrnb", /* name */ "AMR Narrowband", /* info */ NULL, /* comment */ "amrnb", /* dll */ "ffmpeg", /* drv */ --- stdout FOR 2 STEP METHOD $ ./openRTSP -a rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp | \ cat > test_audio_only_rtsp Opening connection to 74.125.212.247, port 554... ...remote connection opened Sending request: OPTIONS rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp RTSP/1.0 CSeq: 2 User-Agent: ./testProgs/openRTSP (LIVE555 Streaming Media v2011.07.08) Received 140 new bytes of response data. Received a complete OPTIONS response: RTSP/1.0 200 OK Public: DESCRIBE, GET_PARAMETER, OPTIONS, PAUSE, PLAY, SETUP, SET_PARAMETER, TEARDOWN CSeq: 2 Server: Google RTSP 1.0 Sending request: DESCRIBE rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp RTSP/1.0 CSeq: 3 User-Agent: ./testProgs/openRTSP (LIVE555 Streaming Media v2011.07.08) Accept: application/sdp Received 786 new bytes of response data. Received a complete DESCRIBE response: RTSP/1.0 200 OK Content-Type: application/sdp Cache-Control: must-revalidate Date: Wed, 13 Jul 2011 21:01:21 GMT Expires: Wed, 13 Jul 2011 21:01:21 GMT Last-Modified: Wed, 13 Jul 2011 21:01:21 GMT Content-Base: rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp/ CSeq: 3 Server: Google RTSP 1.0 Content-Length: 406 v=0 o=GoogleStreamer 1946436214 1631140309 IN IP4 74.125.212.247 s=Video c=IN IP4 0.0.0.0 b=AS:51 t=0 0 a=control:* a=range:npt=0-63.800000 m=video 0 RTP/AVP 98 b=AS:39 a=rtpmap:98 H263-2000/90000 a=control:trackID=0 a=cliprect:0,0,144,176 a=framesize:98 176-144 a=fmtp:98 profile=0;level=10 m=audio 0 RTP/AVP 99 b=AS:12 a=rtpmap:99 AMR/8000/1 a=control:trackID=1 a=fmtp:99 octet-align Opened URL "rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp", returning a SDP description: v=0 o=GoogleStreamer 1946436214 1631140309 IN IP4 74.125.212.247 s=Video c=IN IP4 0.0.0.0 b=AS:51 t=0 0 a=control:* a=range:npt=0-63.800000 m=video 0 RTP/AVP 98 b=AS:39 a=rtpmap:98 H263-2000/90000 a=control:trackID=0 a=cliprect:0,0,144,176 a=framesize:98 176-144 a=fmtp:98 profile=0;level=10 m=audio 0 RTP/AVP 99 b=AS:12 a=rtpmap:99 AMR/8000/1 a=control:trackID=1 a=fmtp:99 octet-align Ignoring "video/H263-2000" subsession, because we''ve asked to receive a single audio session only Created receiver for "audio/AMR" subsession (client ports 64498-64499) Sending request: SETUP rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp/trackID=1 RTSP/1.0 CSeq: 4 User-Agent: ./testProgs/openRTSP (LIVE555 Streaming Media v2011.07.08) Transport: RTP/AVP;unicast;client_port=64498-64499 Received 360 new bytes of response data. Received a complete SETUP response: RTSP/1.0 200 OK Session: 70cd7f38;timeout=90 Transport: RTP/AVP;unicast;mode=play;client_port=64498-64499;server_port=10580-10581;source=74.125.212.247;ssrc=50DF166F Cache-Control: must-revalidate Date: Wed, 13 Jul 2011 21:01:23 GMT Expires: Wed, 13 Jul 2011 21:01:23 GMT Last-Modified: Wed, 13 Jul 2011 21:01:23 GMT CSeq: 4 Server: Google RTSP 1.0 Setup "audio/AMR" subsession (client ports 64498-64499) Outputting data from the "audio/AMR" subsession to 'stdout' Sending request: PLAY rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp/ RTSP/1.0 CSeq: 5 User-Agent: ./testProgs/openRTSP (LIVE555 Streaming Media v2011.07.08) Session: 70cd7f38 Range: npt=0.000-63.800 Received 265 new bytes of response data. Received a complete PLAY response: RTSP/1.0 200 OK Session: 70cd7f38;timeout=90 Range: npt=0.000-63.800 RTP-Info: url=rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp/trackID=1;seq=31872;rtptime=272756789 CSeq: 5 Server: Google RTSP 1.0 Started playing session Receiving streamed data (for up to 68.800000 seconds)... Sending request: TEARDOWN rtsp://v8.cache8.c.youtube.com/CigLENy73wIaHwlcw_gs85OUchMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp/ RTSP/1.0 CSeq: 6 User-Agent: ./testProgs/openRTSP (LIVE555 Streaming Media v2011.07.08) Session: 70cd7f38 Received 72 new bytes of response data. Received a complete TEARDOWN response: RTSP/1.0 200 OK CSeq: 6 Session: 70cd7f38 Server: Google RTSP 1.0 ======= STEP 2 $ ./mplayer -rawaudio channels=1:rate=8000:samplesize=2:format=0x73616D72 test_audio_only_rtsp MPlayer SVN-r33847-3.4.4 (C) 2000-2011 MPlayer Team Playing test_audio_only_rtsp. Invalid seek to negative position ffffffffffffffff! libavformat file format detected. [amr @ 0x1c507f0] max_analyze_duration 5000000 reached at 5000000 [amr @ 0x1c507f0] Estimating duration from bitrate, this may be inaccurate [lavf] stream 0: audio (amrnb), -aid 0 Load subtitles in ./ ========================================================================== Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders AUDIO: 8000 Hz, 1 ch, floatle, 12.8 kbit/5.00% (ratio: 1600->32000) Selected audio codec: [ffamrnb] afm: ffmpeg (AMR Narrowband) ========================================================================== AO: [win32] 8000Hz 1ch s16le (2 bytes per sample) Video: no video Starting playback... A: 59.9 (59.8) of 63.6 (01:03.5) 0.0% Exiting... (End of file)