ãã®åéã®å°é家ã§ã¯ãªãããšãããã«äºçŽããŸãããæè¿ã®çµéšã®ã¿ãå ±æããããšæããŸãã
ãŠãŒã¶ãŒããµãŒããŒã«ã¢ããããŒãããå€ãã®ãã¡ã€ã«ãåçã§ããAndroidã¢ããªã±ãŒã·ã§ã³ãå®è£ ããã¿ã¹ã¯ã«çŽé¢ããŠãããšæ³åããŠãã ããã YouTubeããã©ãã¯ãžã£ãã¯ãšã³ãŒããã¯ã§äœæããŸãã ãããè¡ãã«ã¯ãå°ãªããšã2ã€ã®åé¡ã解決ããå¿ èŠããããŸãããããªãAndroidã§ãµããŒããããŠãã圢åŒã«å€æãããªã¢ãŒããœãŒã¹ãããããªãåçããŸãã ãããã®ã¿ã¹ã¯ã®äž¡æ¹ãããã«è©³ããæ€èšããŸãããã
ãããªå€æ
ãããã£ãŠã Androidããã€ã¹ã§åç»ãåçããåã«ããã®åç»ããµããŒããããŠãã圢åŒã«ãã©ã³ã¹ã³ãŒãããå¿ èŠããããŸãã Androidã®ããã¥ã¡ã³ãã«ã¯ããããã®åã圢åŒã®ãªã¹ããæ確ã«ç€ºãããŠããŸãã
ãŠãŒã¶ãŒããµãŒãã¹ã«ã¢ããããŒããããã¡ã€ã«ããã©ã³ã¹ã³ãŒãããããTVãã¥ãŒããŒããã¹ããªãŒã ãèšé²ããã«ã¯ãæ¥çã®äºå®äžã®æšæºã§ããç¹å¥ãªãŠãŒãã£ãªãã£ffmpegã®å©ããå¿ èŠã§ãã ãããã€ã³ã¹ããŒã«ããããã®è©³çŽ°ãªæé ã¯ãåãååã®ãããžã§ã¯ãã®ãŠã§ããµã€ãã§èŠã€ããããšãã§ããŸãã
çŸåšïŒç§ã®æèŠã§ã¯ïŒãããªãä¿åããæãäžè¬çãªæ¹æ³ã¯ã H.264 AVCã³ãŒããã¯ã䜿çšããMP4ã³ã³ãããŒã§ãã å®éãç§ãã¡ã¯ããããæ€èšããŸãã
ãŸãã Androidã¯H.264ã³ãŒããã¯ã®ãã¹ãŠã®æ©èœããµããŒãããŠããã®ã§ã¯ãªããç¹å®ã®ã»ããïŒ ããŒã¹ã©ã€ã³ãããã¡ã€ã« ïŒBPïŒãšåŒã°ãããããã¡ã€ã«ïŒã®ã¿ããµããŒãããŠããããšã«æ³šæããŠãã ããã ãããã£ãŠãããšãã°ã BPã«ã¯CABACãB-Framesãªã©ã®äŸ¿å©ãªH.264æ©èœã¯å«ãŸããŠããŸããã
ç§ãã¡ã«ãšã£ãŠãããã¯ããããªããšã³ã³ãŒããããšãã«ãããã®æ©èœã䜿çšããå Žåããã®ãããªãåçããããã«Androidã¯å¿ èŠãªãããšãæå³ããŸãã ã䜿ãã®æºåž¯é»è©±ãååã«åŒ·åã§ããããã³ããŒãè¿œå ã®ã³ãŒããã¯ã®ã€ã³ã¹ããŒã«ãšãµããŒããæ åœããŠããå Žåã¯å¯èœã§ããã ããšãã°ã ã¡ã€ã³ãããã¡ã€ã«ã®ãããªã¯ã Samsung Galaxy SIIã§åé¡ãªãåçã§ããŸãã éåžžã®ã¯ã©ã¹ã®é»è©±ïŒ Samsung Galaxy Aceãªã© ïŒã§ã¯ããããªãåçã§ããªãããšã«é¢ããã¡ãã»ãŒãžãšã logcatã®èª€ã£ãã³ãŒããã¯ã®ã³ãŒããã¯ã®ãšã©ãŒã衚瀺ãããŸã ã
ããããçè«ããå®è·µã«ç§»ããŸãããã ãããªãå§çž®ããã«ã¯ã次ã®ã³ãã³ããå®è¡ããå¿ èŠããããŸãã
ffmpeg -i in.3gp -f mp4
-vcodec libx264 -vprofileããŒã¹ã©ã€ã³-bïŒv 1500K
-acodec libfaac -bïŒ128k -ar 44100 -ac 2
-y out.mp4
åãã©ã¡ãŒã¿ãŒãããã«è©³ããæ€èšããŠã¿ãŸãããã
- -i srcå ¥åïŒãã©ã³ã¹ã³ãŒãïŒãã¡ã€ã«ã
- -f mp4ã¯ãããªã³ã³ããã䜿çšããŸããã
- -vcodec libx264ã¯ãããªã³ãŒããã¯ã䜿çšããŸããã
- -vprofile䜿çšãããããŒã¹ã©ã€ã³ãããã¡ã€ã«ã
- -bïŒv 1500Kãããã¬ãŒã;
- -acodec libfaacã¯ãªãŒãã£ãªã³ãŒããã¯ã䜿çšããŸããã
- -bïŒ128kãªãŒãã£ãªãããã¬ãŒãã
- -ar 44100ã®é³ã®åšæ³¢æ°;
- -ac 2ã€ã®ãªãŒãã£ãªã¹ããªãŒã æ°ã
- åºåãã¡ã€ã«ãäžæžããã-yãã©ã°ã
ãŸãããããã¡ã€ã«ãæå®ããã«ã -x264optsãã©ã¡ãŒã¿ãŒã䜿çšããŠå¿ èŠãªH.264ã³ãŒããã¯ãªãã·ã§ã³ãæ瀺çã«æå¹/ç¡å¹ã«ããŠã BPæ¡ä»¶ãæºããããã«ããããšãã§ããŸãã ããããããã¯æ人ã®ããã®æèšã§ãã
ãããªé ä¿¡
ãªã¢ãŒããµãŒããŒãããããªãåçããæãç°¡åãªæ¹æ³ã¯ãäžæã¹ãã¬ãŒãžã«ããŠã³ããŒãããŠããŒã«ã«ã§åçããããšã§ãã ããããçŸä»£ã®ãããªé²ç»ã®ãµã€ãºãèæ ®ãããšãããã¯éžæè¢ã§ã¯ãªãããšã誰ããç解ããŠãããšæããŸãã
ã©ãããïŒ Androidãã©ãããã©ãŒã ã¯ã次ã®ãã¯ãããžãŒ/ãããã³ã«ã®ãã€ãã£ããµããŒããæäŸããŸãã
- HTTP / HTTPSããã°ã¬ãã·ãã¹ããªãŒãã³ã°;
- HTTP / HTTPSã©ã€ãã¹ããªãŒãã³ã°;
- RTSPïŒRTPãSDPïŒ;
ããããé çªã«èããŠã¿ãŸãããã
ããã°ã¬ãã·ãã¹ããªãŒãã³ã°
åŸæ¥ã®WebãµãŒããŒã䜿çšããŠãããªãé ä¿¡ããæãç°¡åãªæ¹æ³ã¯ãåºæ¬çã«ã¯ã HTTPïŒSïŒãããã³ã«ã䜿çšããŠäºåã«æºåããããã¡ã€ã«ãããŠã³ããŒãããããšã§ãã ãã®å Žåã®ãã¹ãŠã®ãœã«ãã¯ãããŠã³ããŒãã®çµäºæã«ãã¡ã€ã«ã®åçãéå§ãããªãããšã§ãããã ããååãªããŒã¿ãããŠã³ããŒãããããšããã«ïŒäžéšã®ãããã¡ãŒããã£ã±ãã«ãªããŸãïŒã
ããã§ã MP4ã³ã³ããã䜿çšããå Žåããã¡ã€ã«ãäœæããŠããããªã¹ããªãŒã ã«é¢ããã¡ã¿ããŒã¿ïŒ moov atoms ïŒããã¡ã€ã«ã®å é ïŒ ftyp atomã®åŸïŒããããªããŒã¿ïŒ mdat atomïŒã®åã«é 眮ãããããã«ããå¿ èŠããããŸãã ããã¯ã qt-faststartãŠãŒãã£ãªãã£ã§ãã¡ã€ã«ãåŠçããããšã§å®è¡ã§ããŸãã
qt-faststart output.mp4 result.mp4
ããã°ã¬ãã·ãã¹ããªãŒãã³ã°ã®äž»ãªåé¡ã¯ããããªãæããããªãç¬éã«å·»ãæ»ããªãããšãããã€ã¹ã«ååãªç©ºã容éãããããšãWebãµãŒããŒã«ãããªãããŠã³ããŒãããå€æ°ã®ãèèªãã¯ã©ã€ã¢ã³ãããµããŒãããå¿ èŠãããããšã§ãã
ãã®ãã¯ãããžãŒã䜿çšããåçã¯ãAndroidãã©ãããã©ãŒã ã§ãã€ãã£ãã«ãµããŒããããŠããŸãã æšæºã®MediaPlayerã¯ã©ã¹ã䜿çšããŠããªã¢ãŒããã¡ã€ã«ãç°¡åã«åçã§ããŸãïŒãã ããéä¿¡ãã£ãã«ãããã€ã¹ã®ãã¯ãŒãããã³ç©ºãé åã®å¯çšæ§ã¯äŸå€ã§ãïŒã
æ¬äŒŒã¹ããªãŒãã³ã°
ãã®ãã¯ãããžãŒã¯ã ããã°ã¬ãã·ãã¹ããªãŒãã³ã°ã®è«ççãªæ¡åŒµæ©èœã§ããããã®äž»ãªåé¡ã®1ã€ã§ããããŸã ããŠã³ããŒããããŠããªããã©ã°ã¡ã³ããžã®å·»ãæ»ãã解決ã§ããŸãã H.264 / AACã³ãŒããã¯ãåããMP4 / FLVã³ã³ããã«é©çšå¯èœã
ãã®å Žåã®ããã°ã¬ãã·ãã¹ããªãŒãã³ã°ãšã®å¯äžã®éãã¯ãGETèŠæ±ã®ã¿ã€ã ã¹ã¿ã³ããèæ ®ããŠãå¿ èŠãªãããªãã¡ã€ã«ã®ãã©ã°ã¡ã³ããè¿ãç¹å¥ãªWebãµãŒããŒãå¿ èŠã§ãããšããäºå®ã§ãã ãã®ãããªWebãµãŒããŒã®äŸãšããŠã¯ãåœç¶ngx_http_mp4_moduleãæã€Orthodox NGINXããããŸã ã
Androidã§ã®ãã®æšæºã®ãµããŒãã«é¢ããå ¬åŒæ å ±ã¯èŠã€ãããŸããã§ããã ãã ããçµéšçã«ã¯ãå°ãªããšãHTC Desireããã³Samsung Galaxy SIIããã€ã¹ã«ååšããããšãããããŸããã ãã ããã䜿ãã®ããã€ã¹ã«ãã€ãã£ããµããŒãããªããŠãã MX Playerãªã©ã®ãµãŒãããŒãã£ãã¬ãŒã€ãŒããã€ã§ã䜿çšã§ãããšããäºå®ã«æ³šæãåèµ·ããããšæããŸããMXPlayerã¯ãåžæããã¿ã€ã ã¹ã¿ã³ãã§ãããªãã©ã°ã¡ã³ããããŠã³ããŒãããã³åçããããžãã¯ãç¬ç«ããŠå®è£ ããå·»ãæ»ããæŽçã§ããããã«ããŸãã
ã©ã€ãã¹ããªãŒãã³ã°
Appleã®éåžžã«éæšæºã®ããŒã¿è»¢éãããã³ã«ã ãã®æ¬è³ªã¯ã M3U8圢åŒã®ç¹å¥ãªãã¡ã€ã«ãã¬ã€ãªã¹ãã«ãã£ãŠãåæ£ãã¡ã€ã«ãå€ãã®å°ããªéšåã«ãçæãããããšããäºå®ã«èŠçŽãããŸãã ããŒã¿è»¢éã¯HTTPïŒSïŒãä»ããŠè¡ãããŸã ã
ãã®å Žåãããã€ã¹ã®å·»ãæ»ããšç©ºãé åã«åé¡ã¯ãããŸããã ããã«ãç¹å®ã®æ¡ä»¶äžã§ã¯ãåçäžã®ãããªã®å質ãéžæããæ©äŒããããŸãã
ãã ããåé¡ãçºçããŸãã ãã¡ã€ã«ããã«ãããããŠãã¬ã€ãªã¹ããäœæããã«ã¯ããµãŒããŒäžã®ããã»ããµãªãœãŒã¹ãæéãããã³ã¹ããŒã¹ãå¿ èŠã§ãã åã®äŸã®ããã«ããã¡ã€ã«ããããã¯ãŒã¯ã«ãããŒããã£ã¹ãããã«ã¯ãHTTPãµãŒããŒãå¿ èŠã§ãïŒè¿œå ã¢ãžã¥ãŒã«ãªãïŒã
VLCã䜿çšããŠããããªãã¡ã€ã«ãã èŠéã ãããšãã§ããŸãã
vlc -I dummy /path/to/pornofilm.mpg vlcïŒ// quit --sout '#transcode {width = 320ãheight = 240ãfps = 25ãvcodec = h264ãvb = 256ãvenc = x264 {audããããã¡ã€ã«=ããŒã¹ã©ã€ã³ãã¬ãã«= 30ãkeyint = 30ãref = 1}ãacodec = mp3ãab = 96}ïŒstd {access = livehttp {seglen = 10ãdelsegs = falseãnumsegs = 0ãindex = / path / to /web/server/root/pornofilm.m3u8,index-url=http://localhost/pornofilm/stream-########.tsasket,mux=ts{use-key-frames},dst= /path/to/web/server/root/pornofilm/stream-#########.ts} '
ãã®ãããªãã¡ã€ã«ã¯ã localhost / pornofilm.m3u8 URLã§åçã§ããŸã ã
ããŒãžã§ã³3.0以éãAndroidã®ãã€ãã£ãã¬ãã«ã§ã®HTTPã©ã€ãã¹ããªãŒãã³ã°ã®ãµããŒããæäŸãããŠããŸã ã ãµãŒãããŒãã£ã®ãã¬ãŒã€ãŒïŒ DicePlayer ã MX Player ïŒã䜿çšããŠãwikiããå€æãããšãããŒãžã§ã³2.2ãããµããŒããåããããšãã§ããŸãã
ãªã¢ã«ã¿ã€ã ã¹ããªãŒãã³ã°ãããã³ã«ïŒRTSPïŒ
ãããªäŒéå°çšã«èšèšãããã¹ããŒããã«ã¢ããªã±ãŒã·ã§ã³å±€ãããã³ã« ã ã³ãã³ã圢åŒã¯HTTPã«éåžžã«äŒŒãŠããŸã ã ã³ãã³ãèªäœã¯ãåŸæ¥ã®ã«ã»ããã¬ã³ãŒããŒã®ãã¿ã³ã«äŒŒãŠããŸãïŒPLAYãPAUSEãRECORDãªã©ã
HTTPã©ã€ãã¹ããªãŒãã³ã°ãšã¯ç°ãªãã RTSPã§ã¯ãã¡ã€ã«ãå°ããªéšåã«åå²ããŠãã¬ã€ãªã¹ããã³ã³ãã€ã«ããå¿ èŠã¯ãããŸããã ãã¡ã€ã«ã®å¿ èŠãªéšåãçæããããã®å Žã§ã¯ã©ã€ã¢ã³ãã«æž¡ãããŸãã VLCãRTSPãµãŒããŒãšããŠäœ¿çšã§ããŸãã
RTSPãããã³ã«èªäœã¯ããŒã¿è»¢éã®æ¹æ³ã決å®ããã®ã§ã¯ãªãããããä»ã®ãããã³ã«ã«å§ä»»ããããšã«æ³šæããŠãã ããã ããšãã°ã RTPã§ãã RTPãä»ããŠãã¡ã€ã«ããããŒããã£ã¹ãããã«ã¯ã次ã®ãã©ã¡ãŒã¿ãŒã䜿çšããŠVLCãéå§ããå¿ èŠããããŸãã
vlc -vvv /path/to/pornofilm.mp4 --sout '#rtp {dst = localhostãport = 1234ãsdp = rtspïŒ// localhostïŒ8080 / pornofilm.sdp}'
ãã ãã衚瀺ãããŠãŒã¶ãŒã®å¯çšæ§ã«é¢ä¿ãªããåå¥ã®ããŒãã䜿çšããŠåãã¡ã€ã«ã®ããã»ã¹ãäžããã®ã¯æããªããšã§ãã
RTSPãããã³ã«ã«æ»ãããããªããªã³ããã³ãã§åçããŸãïŒVidoe On DemandïŒã VLCãRTSPãµãŒããŒãšããŠäœ¿çšããŠVODãåçããã«ã¯ãæåã«RTSPãµãŒããŒãšTelnetã€ã³ã¿ãŒãã§ã€ã¹ã®å±æ§ãæå®ããŠVLCãéå§ããå¿ èŠããããŸãã
vlc -vvv -I telnet --telnet-password 123 --rtsp-host 127.0.0.1 --rtsp-port 5554
ãã®åŸããµãŒããŒã®å®è¡äžã«ããµãŒããŒãæ§æããå¿ èŠããããŸãã ããã¯ã telnet 'aã䜿çšããŠæã䟿å©ã«å®è¡ãããŸãããã®ã¢ãããŒãã«ããããªã³ã¶ãã©ã€ã§æ§æã§ããããã§ãã
æ°ãããã«ãVODãæå¹ã«ãªããŸãã
ãã«ãå ¥åã®ã»ããã¢ãã/path/to/pornofilm.mpg
ãããªïŒAndroidãã©ãããã©ãŒã ãå«ãïŒãåçããã«ã¯ãURL rtspïŒ// localhostïŒ5554 / pornofilmã§èŠæ±ããå¿ èŠããããŸã ã
æ¬ ç¹ã®1ã€ã¯ã HTTPããã¹ãŠã®ãã¡ã€ã¢ãŠã©ãŒã«ããã³ãããã·ã§ãã°ãã°éããããšããäºå®ã§ã... RTSPã§ã¯ ãæåŠãèš±å¯ããªã·ãŒã®å Žåããã¹ãŠãç°ãªããŸãã
ããã«ã RTSPãµãŒããŒã䜿çšããŠãµãŒããŒäžã®ãã¡ã€ã«ãè¿œå /åé€ããå Žåããã®æ§æïŒvodã®ãªã¹ãïŒãæŽæ°ããå¿ èŠããããŸãã ã¯ããããã«ã¯telnetããããŸãããWebãµãŒããŒã®ãã£ã¬ã¯ããªãããã¡ã€ã«ãåã«ã¢ããããŒããŸãã¯åé€ãããããããã«å°é£ã§ãã
ãã®ãã¯ãããžãŒã䜿çšããåçã¯ãAndroidãã©ãããã©ãŒã ã§ãã€ãã£ãã«ãµããŒããããŠããŸãã ããšãã°ãåãæšæºMediaPlayerã¯ã©ã¹ã䜿çšããŸã ã
ãã«ããã£ã¹ã
å€ãã®äººã¯ã ãã«ããã£ã¹ãã¯Androidã§ã¯æ©èœããªããšèããŠããŸãã ããã¯å®å šã«çå®ã§ã¯ãããŸããã
ãŸããã»ãšãã©ã®å Žåãäžå¿ èŠãªäœæ¥ã§ããã€ã¹ãªãœãŒã¹ãããŒãããªãããã«ãããã©ã«ãã§ç¡å¹ã«ãªã£ãŠããŸãã åã«ãªã³ã«ããããšãã§ããŸãã
第äºã«ãã¯ã-ããªãå°è±¡çãªæ°ã®ããã€ã¹ã§ã¯ããã¹ãŠãç¡å¹ã«ãªã£ãŠããããæ£ããåäœããŸããã ã€ã³ã¿ãŒãããäžã§ãããªãã¯å€ãã®æ¶ãšããã€ãã®è§£æ±ºçããèŠã€ããããšãã§ããŸã ã
ãã ããå®è·µã瀺ãããã«ã Android㧠ãã«ããã£ã¹ããããªãåçã§ããŸãã ç§ã®å Žåãæè¿ãªãªãŒã¹ãããAndroidåã VLCããŒã¿çã¯ãã®ã¿ã¹ã¯ã«ããŸã察åŠããŸããã
ããã«ã VLCãµãŒããŒã䜿çšãããšã ãã«ããã£ã¹ãã®åçãåžžã«HLSã«æžããããšãã§ããŸã ã
vlc -I dummy udpïŒ//@192.168.20.1ïŒ1234 vlcïŒ// quit --sout '#transcode {width = 320ãheight = 240ãfps = 25ãvcodec = h264ãvb = 256ãvenc = x264 { audããããã¡ã€ã«=ããŒã¹ã©ã€ã³ãã¬ãã«= 30ãkeyint = 30ãref = 1}ãacodec = mp3ãab = 96}ïŒstd {access = livehttp {seglen = 10ãdelsegs = falseãnumsegs = 0ãindex = / path /to/web/server/root/multicast-porno.m3u8,index-url=http://localhost/multicast-porno/stream-#########.tsasket,mux=ts{use-key -frames}ãdst = / path / to / web / server / root / multicast-porno / stream-########ãts} '
ãŸãã¯RTSPïŒ
æ°ãããã«ããã£ã¹ããã«ãVODãæå¹
ãã«ããã£ã¹ããã«ãå ¥åudpã®ã»ããã¢ããïŒ//@192.168.20.1ïŒ1234
ãã¬ã€ã€ãŒã«udpïŒ//@192.168.20.1ïŒ1234ã®åœ¢åŒã®URLãæž¡ãããšã§ãããã€ã¹ã§ãã«ããã£ã¹ããåçããããšãã§ããŸãã
äœãéžã¶ã
ãããªåœ¢åŒïŒ H.264 BP / MP4 ïŒã§ãã¹ãŠãæãããªå Žåãé ä¿¡æ¹æ³ã§ã¯åé¡ã解決ããŸããã ããããã«é·æãšçæããããŸãã
ãŸããéåžžã®ããã°ã¬ãã·ãã¹ããªãŒãã³ã°ãåé€ããŸã ã ã¯ããããã¯ãã€ã§ãã©ãã§ãåäœããŸããããã¡ã€ã«å šäœãå·»ãæ»ãããããŠã³ããŒããããããããšã®æ¬ åŠã¯ãã§ã«å€ãããŸãã
次ã«é£ã³ç«ã€åè£ã¯ã©ã€ãã¹ããªãŒãã³ã°ã§ãã ãã®äž»ãªæ¬ ç¹ã¯ãããŒãžã§ã³3.0以éã®Androidã®ãã€ãã£ããµããŒãã§ãã ãŸããããŒãžã§ã³2.x ã®ãŠãŒã¶ãŒã®80ïŒ ä»¥äžãç¡èŠããããšã¯éžæè¢ã§ã¯ãããŸããã ããã§ã¯ããµãŒãããŒãã£ã®ãã¬ãŒã€ãŒãèŠãããšãã§ããŸãããç¬èªã®å®è£ ãè¡ãããšãã§ããŸãïŒæ®å¿µãªããã HLSããµããŒãããããã®ç¡æã®éçºã¯èŠã€ãããŸããã§ããïŒã
ãããŠãç§ãæåŸã«æ¶ãã®ã¯RTSPã§ãã ã¯ãããããªå°çšã«èšèšããããããã³ã«ã§ãã ã¯ãããã®äœ¿çšã¯ã€ããªãã®ãŒçã«çå®ã§ãã ãããã2ã€ã®ãã€ã³ãããããŸãã ãŸãããµãŒããŒæ§æãåžžã«æŽæ°ããå¿ èŠããããŸãã 第äºã«ã HTTPã¯ãã€ã§ãã©ãã§ããªãŒãã³ã§ããã RTSP / RTPã«ã€ããŠã¯èšããŸããã
å人çã«ã¯ã æ¬äŒŒã¹ããªãŒãã³ã°ã«çŠç¹ãåœãŠãŸã ã ãã¡ã€ã«å šäœãããŠã³ããŒãããã«å·»ãæ»ãããšãã§ããŸãã å¿ èŠãªã®ã¯ãWebãµãŒããŒãå°ãæ§æããããšã ãã§ãã