<¤Ñ²´³q>

 

 

 

«ü¾É¦Ñ®v¡G

±iÄ_°ò

«ü¾É§U±Ð¡G

ªô«Ø³Ô

°ÑÁɶ¤­û¡G

³¯à±¿Å

»¯«Å¦w

 

¨t    §O¡G³q°T¤uµ{¾Ç¨t

 

¥Ø     ¿ý

±MÃDºK­n

¤@.. «e¨¥... 3

¤G.. ­ì²z¤ÀªR»P¨t²Î³]­p...

2.1.......... ­ì²z¤ÀªR...

2.2.......... ¨t²Î³]­p...

¤T.. ¹êÅçµ²ªG»P¤ñ¸û...

¥|.. µ²½×...

¤­.. ¹Î¶¤¦X§@¤è¦¡... 13

¤».. °Ñ¦Ò¤åÄm... 13

 

 


±MÃDºK­n

«Ø¥ß¤@­Ó¥HH.264½s¸Ñ½X¨Ãµ²¦X¦ê¬yªº§Y®É¼v¹³¶Ç¿éµ{¦¡¡A¥H¹F¦¨¤@­Ó¥i¥H¦³¼v¹³¶Ç¿é¡Aµø°T·|ij¡A»·ºÝºÊ±±µ¥¦hºØ¥i¯à¥Î³~ªºH.264¦ê¬y½s¸Ñ½X¼½©ñ¾¹¡A¨Ã¦b¤§«á¬ã¨sµ{¦¡ÂX¥R»P©µ¦ùªº¦UºØ¥Î³~¤§¥i¯à©Ê¡C

H.264¼v¹³½s¸Ñ½X»P¦h´CÅé§Y®É¦ê¬y¶Ç¿é¦p¤µ¤w³Q¼sªxªº§Q¥Îªº¦U­Ó¼h­±¡A¤£½×¬O¤â¾÷©Î¬O¼v­µ¤À¨Éºô¯¸³£¥i¨£¨ì³o¨Ç§Þ³NªºÂܸñ¡C¦]¦¹§Ú­Ì­p¹º±N³o¨âºØ§Þ³N¦P®É¹B¥Î©ó§Ú­Ì©Ò­n«Ø¥ßªº¼v¹³¶Ç¿é³nÅé¡A¹F¦¨¤@­Ó¹B¥ÎH.264½s¸Ñ½Xªº¦h´CÅé§Y®É¦ê¬y¶Ç¿é¼v¹³µ{¦¡¡A¦Ó¦¹µ{¦¡¤]±N¦]¬°¨Ï¥Î¤F³o¨âºØ§Þ³N¦Ó¦³¬Û·í¼sªxªº¥Î³~¡C

 

¤@¡B «e¨¥

­ì¥ý¤è¦V¬°H.264ªº¼v¹³½s¸Ñ½X¡A¹ê²{¤@­Ó¥i¦P®É±µ¦¬¡B¶Ç°e»P½s¸Ñ½X¼v¹³ªºµ{¦¡¡A¨ÃÅý¨â­Ó¨Ï¥ÎªÌ¥Î¦¹µ{¦¡¤¬¶Ç¡A¦P®É¾á¥ô¶Ç°eºÝ©M±µ¦¬ºÝ¡C¦ý³o²¦³º¥u¬O¤@¹ï¤@ªº¼v¹³¤¬¶Ç¡A¦b¹ê°µ¤è­±¡AÀ³¥Î¤£¬O«Ü¼s¡A©ó¬O¡A§Ú­Ì´N±N¨ä¥\¯à©µ¦ù¡A°µ¦¨¦h¹ï¦hªº¼v¹³¶Ç¿é¡A¨Ã¥Bµ²¦X¤å¦r¶Ç¿é¨t²Î¡A´N¦n¹³¦p¦Pµø°T·|ij¤@¯ëªº¥\¯à¡C

 

¤G¡B­ì²z¤ÀªR»P¨t²Î³]­p

2.1 ­ì²z¤ÀªR

­º¥ý¡A§Ú­Ì§Q¥Î¨ì³Ì°ò¥»ªº¶Ç°e­ì²z¡A±N¼v¹³¨Ó·½¸g¹L½s½X«á¶Ç°e¡A¦b±µ¦¬ºÝ¦³¤@¸Ñ½X¾¹¦A±N¨ä®i¥Ü¡C¦Ó¦b¶Ç°e¤¤¡A¬O¥ý¥HH.264ªº³W®æ½s½X¨Ã¥ÎRTP¹ê²{¼v¹³¦ê¬y¡C(¦pFig.2-1©Ò¥Ü)

 

Fig. 2-1  ¶Ç°e¥Ü·N¹Ï

¶Ç°e¤¤¡AserverºÝ©MclientºÝªºsocket¥²¶·­n¥ý¥´¶}¡A¤~¥i¥H¶Ç°e¸ê®Æ¡C

(¦pFig.2-2©Ò¥Ü)

Fig. 2-2  Socket ¥Ü·N¹Ï[5]

¦b½s½X®É¡A¥ý°µMotion Estimation¥h°»´úª«Å骺Åܤƶq¡A¥H¤Î Intra Prediction¹w´ú¤U¤@±iframe¡A°µ§¹¤§«á¤ñ¸û¦U¼Ò¦¡ªº¦nÃa¡A¿ï¾Ü¸û¦n¹w´ú¼Ò¦¡«á¦A¥h°µ Transform©M Quantization³Ì«á¦A°µEntropy Encode½s½X«á°e¥X¡C¦b¸Ñ½XºÝ«h±N½s½XºÝªº°Ê§@¤j­P¥H¬Û¤Ïªº¦¸§Ç¦A°µ¤@¦¸¡C (¦pFig.2-3, 4©Ò¥Ü)

 

Fig. 2-3  H.264 Encoder [1]

Fig. 2-4  H.264 Decoder [1]

 

¦b¼v¹³¤¤¡A§Ú­Ì»Ý­n¥Î¨ìRTP (Real-time Transport Protocol)¥H¤ÎRTCP (Real-time Transport Control Protocol)¨ó©wªºÀ°§U¤~¥i¥H¹F¨ì§Y®É¦ê¬y¼v­µªº¥Øªº (¦pFig.2-5©Ò¥Ü)

 

Fig. 2-5  RTP Session¥Ü·N¹Ï

 

2.2 ¨t²Î³]­p

¦pFig.2-6¡A­º¥ý«öInitialize¶s±Ò°ÊWebcam¨Ã³]©w¦n­n¶Ç°eªºframe rate¥H¤ÎQP¤j¤p¡A¦A«öStart¶s¡A«Ø¥ß¶Ç°eºÝ¥\¯àµ¥«Ý¨Ï¥ÎªÌ¥[¤J³s½u¡A³o®É¡A¨ä¥Lµ{¦¡¨Ï¥ÎªÌ¥u­n¿é¤J¦¹¨Ï¥ÎªÌªºIP¡A§Y¥i¬Ý¨ì¸Ó¶Ç°e¹L¨Óªº¼v¹³¡C¦Óµ{¦¡¥i¦P®É°õ¦æ±µ¦¬ºÝ»P¶Ç°eºÝªº¥\¯à¡A¤]´N¬O»¡¦bµ{¦¡¹ï¨ä¥L¨Ï¥ÎªÌ¶Ç°e¼v¹³ªº¦P®É¡A¤]¥i¹ï¨ä¥L¨Ï¥ÎªÌ­n¨D¼v¹³ªº¶Ç°e¡C¦p¦¹¤¬¬Û©¹¨Ó³Ì²×«K¹F¨ì¦h¹ï¦hµø°T·|ijªº¥Ø¼Ð¡C

 

Fig.2-6  µøµ¡°t¸m¹Ï

«ö¶s»¡©ú:

1.initialize : ­t³d±Ò°ÊÄá¼v¾÷¡A¨Ï¨ä¶}©lÄá¼v

2.start & stop all : ±Ò°Ê»P°±¤îserverºÝ

3.set parameter : ¨Ì¨Ï¥ÎªÌªºQP³ß¦n¥i§@½Õ¾ã

4.IP : ±ý³s½u¹ï¶HªºIP¦ì§}

5.connect : »P¤W­±¤è¶ôªºIP¦ì§}¶i¦æ³s½u

6.accept : ¬O§_±µ¨ü»·ºÝ³s½u

7.disconnect : Â÷½u

8.chatroom : ²á¤Ñ«Ç°T®§Åã¥Üµøµ¡

(¤Á´««á¨£¹ÏFig.2-7)

 

Fig.2-7  ²á¤Ñ«Çµøµ¡¤¶­±

¬yµ{¹Ï

¶Ç°eºÝ                                 ±µ¦¬ºÝ

¤T¡B¹êÅçµ²ªG¤ñ¸û

­ìµ{¦¡¬°³q°T¹êÅç«Çªº¾Çªø¯d¤U¨Óªº¨Ï¥ÎPTZ(Pan, Tilt, Zoom)¤§¼v¹³ºÊ±±³nÅé¡A¦³µÛrate control¡AÅã¥Ü¬y¶q¡A©w®É¿ý¼v¡A±±¨îÄá¼v¾÷¨¤«×»PµJ¶Zµ¥¥\¯à¡C¦ý³o¨Ç¥\¯à»P§Ú­Ì«Ø¥ßµø°T·|ij³nÅ骺¥Ø¼ÐµLÃö¡A¥B¦¹µ{¦¡¦³³\¦h¦a¤è¤£²Å¦X§Ú­Ì©Ò»Ý¡A¨Ò¦p¡G

 

¾ã®M³nÅé¤À¬°¨â­Óµ{¦¡¡G¶Ç°eºÝ(Camera / Client)»P±µ¦¬ºÝ(Server)¡A¥B¨âµ{¦¡µLªk¦P®É¦b¦P¤@¥x¹q¸£¤W°õ¦æ¡A´Nºâ¥i°õ¦æ¡A¹ï¨Ï¥ÎªÌ¤]«D±`¤£¤è«K¡A¤£²Å¦X§Ú­Ì«Ø¥ßµø°T·|ijµ{¦¡ªº¥Ø¼Ð¡C

 

µ{¦¡ªº¶Ç°eºÝ¬°¤@¹ï¤@³æ¦V¼v¹³¶Ç°e¡A±µ¦¬ºÝ¬°¦h¹ï¤@ªº³æ¦V¼v¹³±µ¦¬¡A¤£²Å¦X§Ú­Ì·Q«Ø¥ßªº¦h¹ï¦hÂù¦V¼v¹³¶Ç¿éµø°T·|ij³nÅ骺¥Ø¼Ð¡C

 

¹êÅç¨BÆJ¡G

²Ä¤@¶¥¬q¡G¥Ñ©ó¥H¤W²z¥Ñ¡A§Ú­Ì¨M©w¬ã¨s¶Ç°eºÝ»P±µ¦¬ºÝªºµ{¦¡½X¡A¨Ã±N¤j³¡¤À»Pµø°T·|ijµLÃöªº¥\¯à²M°£¡A¥u¯d¤U°ò¥»ªºH.264½s¸Ñ½X»PRTP¦ê¬y¶Ç¿é¥\¯à¡C

²Ä¤G¶¥¬q¡G¬°¤F«K§Q¨Ï¥ÎªÌ»P¾ã¦X¼v¹³ªº¸Ñ½X»Pºô¸ô¶Ç¿é¡A§Ú­Ì§â³o¨âºÝªºµ{¦¡½X°µ¤@­Ó¾ã¦X¡A¹ê²{¤@­Ó«K§Qªº¼v¹³±µ¦¬»P¶Ç¿é¥­¥x¡C(¨£Fig.3-1)

 

Fig.3-1 ªì¨Bµ{¦¡¾ã¦X

 

²Ä¤T¶¥¬q¡G¦bªì¨Bªº¾ã¦X«á¡A§Ú­Ì¶}©l²`¤J¬ã¨s»P­×§ïµ{¦¡½X¡AÅýµ{¦¡¥i¹ï¦h­Ó¥Ø¼Ð¦P®É°õ¦æ¥H¤U°Ê§@(¨£Fig.3-2~7)¡G

WebCam§ì¨úªº¼v¹³°µH.264½s½X

¹ï3­Ó·|ij¦¨­ûRTP¦ê¬y¼v¹³¶Ç°e

±µ¦¬3­Ó·|ij¦¨­ûªºRTP¦ê¬y¼v¹³

¹ï¤w±µ¦¬ªºRTP¦ê¬y§@H.264¼v¹³¸Ñ½X

»P3­Ó·|ij¦¨­û¥æ´«±±¨î°T®§

 

Fig.3-2  A»PB¶i¦æ¤@¹ï¤@Âù¦V¼v¹³¶Ç¿é (Aµø¨¤)

 

Fig.3-3  A»PB¶i¦æ¤@¹ï¤@Âù¦V¼v¹³¶Ç¿é (Bµø¨¤)

 

¥H¤U¬°¦h¹ï¦hªº¶Ç¿é¤§¹êÅçµ²ªG¡A¦U¨Ï¥ÎªÌªº³sµ²ª¬ªp¨£ Fig.3-4

 

Fig.3-4  ¦h¹ï¦h¼v¹³¶Ç¿é´ú¸Õ¹Ï

 

Fig.3-5  Fig.3-4¤¤ªºHost Aµø¨¤

 

Fig.3-6  Fig.3-4¤¤ªºHost Bµø¨¤

 

Fig.3-7  Fig.3-4¤¤ªºHost Cµø¨¤

 

4¥x¹q¸£§ï.bmp

Fig.3-8  ¥þ¨t²Î»P¥þµø¨¤

 

¥|¡Bµ²½×

¦b¬ã¨s¤w«Ø¥ß¦nªº¦ê¬y½s¸Ñ½X¼v¹³µ{¦¡«á¡Aµoı¼v¹³½s¸Ñ½X»P§Y®É¦ê¬y¶Ç¿éªº·f°tªº½T¬O«D±`ªº½ÆÂø¡A¦Ó¥B§Ú­Ì¦b§â¶Ç°e»P±µ¦¬ªº¥\¯àµøµ¡¾ã¦X©ó¦P¤@µøµ¡ªº¶¥¬q¤W¹J¨ì¤F¬Û·í¤jªº§xÃø¡A¹³¬Oºô¸ô¸ê·½(port, socket, RTP session, bit rate(¥ÑQP»Pframe rate±±¨î))»P¹q¸£¸ê·½(°O¾ÐÅé)ªº¤À°t¡A¦Ó¥t¤@­Óµ{¦¡¤Wªº²~ÀV«h¬O­n«Ø¥ß¨Ãºû«ù¤@­Ó¥i¾aªº¦h¹ï¦hºô¸ô¶Ç¿é¡A¹³¬O©µ¿ð¦^À³©Î¬Oº|¥¢«Ê¥]µ¥ª¬ªpªº¸Ñ¨M¤èªk¡C¥Ñ©ó§Ú­Ì±q¨Ó¨S³B²z¹L³o»ò¤jªºµ{¦¡¡A­è¶}©l®É¬Æ¦Ü·P¨ì¤£ª¾±q¦ó¤U¤â¡A¦Ó¦bµ{¦¡½Xªº«Ø¥ß»Pdebug¤¤¡A§Ú­Ì¤]¹J¨ì¤F³\¦h°ÝÃD©M®À§é¡A³\¦h§ó¬O¥H«e·Q³£¨S·Q¹Lªº¡A¨Ã¦b¹Lµ{¤¤¾Ç¨ì¤F³\¦h³æ±q½Ò¥»¸ÌµLªk¾Ç¨ìªºª¾ÃÑ¡A¹ï©ó¹Î¶¤¦X§@»P¤u§@ºA«×µ¥¤è­±¤]¾Ç¨ì¤£¤Ö¡C²`²`ªº·P¨ì¦Û¤vªº­I´ºª¾ÃѤ£¨¬»P¤~²¨¾Ç²L¡C¦ý³Ì«á§Ú­ÌÁÙ¬O§JªA¤F³\¦h§Þ³N¤WªºÃøÃö¡A«Ø¥ß¤F¤@­Ó¨ã¦³¹ê¥Î©Êªº³nÅé¡A·P¨ì¤FµL¤ñªº¦¨´N·P¡C

 

¤­¡B¹Î¶¤¦X§@¤è¦¡

ÃD¥Ø¿ï¨ú:

¦]¬°H.264¼v¹³½s½X¡A¬O¥Ø«e«D±`¹ê¥Îªº½s½X§Þ³N¡A¦]¦¹§U±Ð´N«Øij§Ú­Ì¥i¥H©¹³o¤è¦V¥hµÛ¤â¡A©ó¬O´N·Q¨ì¤F¥i¥H§Q¥ÎH.264½s¸Ñ½X¨Ó°µ¼v¹³¶Ç¿é¡A¥H´£°ª¼v¹³«~½è¡A¨Ã¥B¦b²{¦b³o­Ó¥R¥¸ºô¸ôªº®É¥N¡A¼v¹³¶Ç¿é¥i¥H«D±`¹ê¥Î¡A´Nºâ¤§«á­n¦A©µ¦ù§Þ³Nªº¸Ü¡A¤]¬O«Ü¦nªº¤è¦V¡C

 

¹ê§@¶i¦æ:

¤u§@¤À°t:

µ{¦¡«ü¾É»P¨ó½Õ¾ã¦X: §U±Ð

Debug: ³¯à±¿Å¡B»¯«Å¦w

µ{¦¡½X¤F¸Ñ:  »¯«Å¦w¡B³¯à±¿Å

CameraºÝ: »¯«Å¦w

ServerºÝ: ³¯à±¿Å

CameraºÝ©MServerºÝ¾ã¦X:  ³¯à±¿Å¡B»¯«Å¦w

´ú¸Õ: »¯«Å¦w¡B³¯à±¿Å

 

°ÝÃD¸Ñ¨M:

1.¦b¤@¶}©l³s½u®É¡AQP(¼v¹³ªº¶q¤Æ°Ñ¼Æ)·|ÅÜ°Ê¡A¾É­P¼v¹³«~½è¤£¨Î¡C

-¦]¬°¼v¹³¤£ª¾¹D­nÅ¥¶Ç°eºÝµ¹ªºQP­ÈÁÙ¬O±µ¦¬ºÝ³]©wªºQP­È¡A©Ò¥H¤@«ß¥Ñ¶Ç°eºÝ¨M©wQP§Y¥i¡C

 

 

2.µLªk«Ø¥ß¦h¹ï¦h¼v¹³¶Ç¿é

¡½¾ã¦Xµ{¦¡ªº±µ¦¬ºÝ»P¶Ç°eºÝªº¥\¯à

¡¶¨âµ{¦¡½X¤¤Åܼƫŧi·|­«½Æ©w¸q¡A¶·­Ó§O³B²z

¡¶¨âµ{¦¡ªº±M®×Äݩʦ³¤£¦Pªº¦a¤è¡A»Ý¶iÄÝ©Ê­¶­×§ï

 

¡½«Ø¥ßÂù¦V¶Ç¿é

¡¶«Ø¥ß¨â­ÓRTP Session¡A¨Ã¥B­«·s©w¸q±µ¦¬©M¶Ç°eªºSocket

¡¶ÅýÂù¦V¶Ç¿éªº¨â¤è©w´Á¶Ç°e±±¨î°T®§(¨Ï¥ÎTCP¶Ç¿é)¡AÁקKºô¸ô¥X²{°ÝÃD¡C

 

¡½«Ø¥ß¤@¹ï¦h¼v¹³¶Ç¿é

¡¶¹ï¤£¦Pªº¥Ø¼Ð«Ø¥ßRTP session«á¡A¸Ñ¨M½Ä¬ð°ÝÃD

¡¶­×§ïµ{¦¡½X¡A¸Ñ¨Mµ{¦¡µLªk¤À¿ë¤£¦P¶Ç°eºÝ«È¤áªº°ÝÃD

¡¶¥u°µ¤@¦¸½s½X¨Ã¶Ç°eµ¹¤T­Ó¥Ø¼Ð¡A¸`¬Ù¨t²Î¸ê·½

 

¡½¤@¹ï¦h³s½u®É¡A«á¥[¤Jªº±µ¦¬ºÝ·|·í¾÷

¡¶¥Ñ©ó¤W¤@¬qªº²Ä¤TÂI©Ò´£¨ìªº¤èªk¡A³y¦¨¨Ï¥Îinter predictionªº frame §ä¤£¨ìreference¡A·|³y¦¨°O¾ÐÅé¿ù»~¡A¦]¦¹¡A·í¶Ç°eºÝ¦³·sªº±µ¦¬ºÝ¥[¤J¡A·|¹ï©Ò¦³ªº±µ¦¬ºÝ¡A°e¥X¨Ï¥Îintra predictionªºframe(¦]¬°¬O¦P¤@¥÷½s½X«áªº¼v¹³¶Çµ¹¤T­Ó¥Ø¼Ð)

 

 

3.Åܰʵøµ¡¤¶­±ªº°t¸m«á¼v¹³ªº¦ì¸m·|¶Ã¶]

-±±¨î¼v¹³¦ì¸mªº¨ç¦¡»P½sĶ¾¹¤¤ªº¬É­±°t¸m³]©w¤¬¬Û¿W¥ß

 

4.Â_½u«á­«³s¡Aµ{¦¡·|·í±¼©ÎµLªkÅã¥Ü

-±µ¦¬ºÝ·|­n¨D¶Ç°eºÝÃö³¬SOCKET»PRTP SESSION¤Î­««Ø¡A¨Ã¥B±N°O¾ÐÅé²M°®²b¡A±NÅܼÆÁÙ­ì

 

¹ê§@¤¤·s¼W³Ð·N:

²á¤Ñ«Ç

¦b¼v¹³¶Ç¿é®É¡Aı±o°£¤F¶Ç°e¼v¹³¤§¥~¡AÁÙ¥i¥H·s¼W¤å¦r¶Ç¿é¨t²Î¡A¨Ï¦U¨Ï¥ÎªÌ¥i¥H¤¬¶Ç¤å¦r¡A¨Ã¥B¨Ï¥ÎªÌ¥i¨Ì¦Û¤v³ß¦n¿é¤JID¡A¦b¶Ç¤å¦r®É¡A¤]¥i¼W¥[®¨®¨¸Ü(¥u¹ï³æ¤@¨Ï¥ÎªÌ)¡A©ÎµÛ¼s¼½¼Ò¦¡(°w¹ï©Ò¦³¨Ï¥ÎªÌ)

¦h¹ï¦h¼v¹³¶Ç¿é

¥»¨Ó¥u¬O·Q»¡¼v¹³¥i¥H¨â¨Ï¥ÎªÌ¤¬¶Ç´N¦n¡A«á¨Óı±o»¡¦pªG¥i¥H°µ¦¨¦h¹ï¦h¼v¹³¶Ç¿é¡A´N¦n¹³µø°T·|ij¤@¯ë¡A¤@¸s¤H¥i¥H¤¬¬Û¬Ý¨ì©¼¦¹¡A¦A°t¦X¤å¦r¶Ç¿é¡A´N¬O§Ú­Ì³Ì²×ªº¥Ø¼Ð¡C

 

¤»¡B°Ñ¦Ò¤åÄm

[1] RFC 3984, ¡§RTP Payload Format for H.264 Video¡¨

[2] JRTPLib - Reference Manual

(http://research.edm.uhasselt.be/~jori/page/index.php?n=CS.Jrtplib)

[3] x264 Options Explained Guide

(http://www.digital-digest.com/articles/x264_options_page1.html )

[4] Iain E. G. Richardson, ¡§H.264 and MPEG-4 Video Compression: Video Coding for Next-generation Multimedia,¡¨1st edition, Wiley. August 2003.

[5] J. Kurose, K. Ross, ¡§Computer Networking: A Top Down Approach Featuring the Internet,¡¨3rd edition. Addison-Wesley. July 2004.

 

 

 

 

 

 

 

 

¦^2009±MÃD