Ir al contenido


Foto

Emitir en vivo desde camara conectada a la pc


  • Por favor identifícate para responder
3 respuestas en este tema

#1 giulichajari

giulichajari

    Advanced Member

  • Miembros
  • PipPipPip
  • 477 mensajes

Escrito 15 noviembre 2017 - 05:00

Quiero desarrollar una web para transmitir un torneo de pool.

La web tendria la grilla de jugadores con los puntajes y a su vez deberia tener una emision de lo que toma la camara, por ejemploi una webcam conectada a la pc que este filmando la mesa de pool.

Porque en Argentina hacemos torneos en distintas ciudades, y la gente transmite por facebook(que no esta mal) y estan constantemente preguntando como van y demas.

A su vez si quiero poner los nombres de los jugadores y puntos en pantalla se puede? como hacen en los partidos en la tv?

Muchas gracias


  • 0

#2 giulichajari

giulichajari

    Advanced Member

  • Miembros
  • PipPipPip
  • 477 mensajes

Escrito 16 noviembre 2017 - 10:40

Encontre esta libreria y funciona con un video guardado en la pc o servidor. Pero tendria que poder transmitir en directo:

Modo de uso:


php
  1. <?php
  2. /**
  3.  * Description of VideoStream
  4.  
  5.  */
  6. class VideoStream
  7. {
  8. private $path = "";
  9. private $stream = "";
  10. private $buffer = 102400;
  11. private $start = -1;
  12. private $end = -1;
  13. private $size = 0;
  14.  
  15. function __construct($filePath)
  16. {
  17. $this->path = $filePath;
  18. }
  19.  
  20. /**
  21.   * Open stream
  22.   */
  23. private function open()
  24. {
  25. if (!($this->stream = fopen($this->path, 'rb'))) {
  26. die('Could not open stream for reading');
  27. }
  28.  
  29. }
  30.  
  31. /**
  32.   * Set proper header to serve the video content
  33.   */
  34. private function setHeader()
  35. {
  36. header("Content-Type: video/mp4");
  37. header("Cache-Control: max-age=2592000, public");
  38. header("Expires: ".gmdate('D, d M Y H:i:s', time()+2592000) . ' GMT');
  39. header("Last-Modified: ".gmdate('D, d M Y H:i:s', @filemtime($this->path)) . ' GMT' );
  40. $this->start = 0;
  41. $this->size = filesize($this->path);
  42. $this->end = $this->size - 1;
  43. header("Accept-Ranges: 0-".$this->end);
  44.  
  45. if (isset($_SERVER['HTTP_RANGE'])) {
  46.  
  47. $c_start = $this->start;
  48. $c_end = $this->end;
  49.  
  50. list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2);
  51. if (strpos($range, ',') !== false) {
  52. header('HTTP/1.1 416 Requested Range Not Satisfiable');
  53. header("Content-Range: bytes $this->start-$this->end/$this->size");
  54. }
  55. if ($range == '-') {
  56. $c_start = $this->size - substr($range, 1);
  57. }else{
  58. $range = explode('-', $range);
  59. $c_start = $range[0];
  60.  
  61. $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $c_end;
  62. }
  63. $c_end = ($c_end > $this->end) ? $this->end : $c_end;
  64. if ($c_start > $c_end || $c_start > $this->size - 1 || $c_end >= $this->size) {
  65. header('HTTP/1.1 416 Requested Range Not Satisfiable');
  66. header("Content-Range: bytes $this->start-$this->end/$this->size");
  67. }
  68. $this->start = $c_start;
  69. $this->end = $c_end;
  70. $length = $this->end - $this->start + 1;
  71. fseek($this->stream, $this->start);
  72. header('HTTP/1.1 206 Partial Content');
  73. header("Content-Length: ".$length);
  74. header("Content-Range: bytes $this->start-$this->end/".$this->size);
  75. }
  76. else
  77. {
  78. header("Content-Length: ".$this->size);
  79. }
  80.  
  81. }
  82.  
  83. /**
  84.   * close curretly opened stream
  85.   */
  86. private function end()
  87. {
  88. fclose($this->stream);
  89. }
  90.  
  91. /**
  92.   * perform the streaming of calculated range
  93.   */
  94. private function stream()
  95. {
  96. $i = $this->start;
  97. while(!feof($this->stream) && $i <= $this->end) {
  98. $bytesToRead = $this->buffer;
  99. if(($i+$bytesToRead) > $this->end) {
  100. $bytesToRead = $this->end - $i + 1;
  101. }
  102. $data = fread($this->stream, $bytesToRead);
  103. echo $data;
  104. flush();
  105. $i += $bytesToRead;
  106. }
  107. }
  108.  
  109. /**
  110.   * Start streaming video content
  111.   */
  112. function start()
  113. {
  114. $this->open();
  115. $this->setHeader();
  116. $this->stream();
  117. $this->end();
  118. }
  119. }
  120. ?>


php
  1. <?php
  2. include('VideoStream.php');
  3. $filePath='D:/Videos Musicales/03. Ozuna - Se Preparó ( Video Oficial ) - Odisea.mp4';
  4. $stream = new VideoStream($filePath);
  5. $stream->start();
  6.  
  7.  
  8. ?>


  • 0

#3 sir.dev.a.lot

sir.dev.a.lot

    Advanced Member

  • Miembros
  • PipPipPip
  • 545 mensajes
  • Location127.0.0.1

Escrito 18 noviembre 2017 - 06:14

En HTML5 con 3 / 4 Lineas de codigo muestras un video desde tu Servidor.

 

Porque no pruebas HTML5, tiene WebSocket que te permite manejar Streaming, Te Prueba ?

 

Saludos!


  • 0

#4 giulichajari

giulichajari

    Advanced Member

  • Miembros
  • PipPipPip
  • 477 mensajes

Escrito 19 noviembre 2017 - 07:00

En HTML5 con 3 / 4 Lineas de codigo muestras un video desde tu Servidor.

 

Porque no pruebas HTML5, tiene WebSocket que te permite manejar Streaming, Te Prueba ?

 

Saludos!

Entiendo..lo estoy viendo..Pero igual tengo que contratar un hosting en el futuro..porque miles de personas deben poder verlo..mas adelante comento como voy..Gracias amigo

 

encontre esto:


html5
  1. <canvas id="videoCanvas" width="640" height="480">
  2. <p>
  3. Please use a browser that supports the Canvas Element, like
  4. <a href="http://www.google.com/chrome">Chrome</a>,
  5. <a href="http://www.mozilla.com/firefox/">Firefox</a>,
  6. <a href="http://www.apple.com/safari/">Safari</a> or Internet Explorer 10
  7. </p>
  8. </canvas>
  9. <script type="text/javascript" src="jsmpg.js"></script>
  10. <script type="text/javascript">
  11. // Setup the WebSocket connection and start the player
  12. var client = new WebSocket( 'ws://example.com:8084/' );
  13.  
  14. var canvas = document.getElementById('videoCanvas');
  15. var player = new jsmpeg(client, {canvas:canvas});
  16. </script>


  • 0




IP.Board spam blocked by CleanTalk.