Recherche avancée

Médias (91)

Autres articles (96)

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

  • Multilang : améliorer l’interface pour les blocs multilingues

    18 février 2011, par

    Multilang est un plugin supplémentaire qui n’est pas activé par défaut lors de l’initialisation de MediaSPIP.
    Après son activation, une préconfiguration est mise en place automatiquement par MediaSPIP init permettant à la nouvelle fonctionnalité d’être automatiquement opérationnelle. Il n’est donc pas obligatoire de passer par une étape de configuration pour cela.

  • Des sites réalisés avec MediaSPIP

    2 mai 2011, par

    Cette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
    Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page.

Sur d’autres sites (7314)

  • Run docker container with FFMPEG rstp stream on websockets

    18 février, par bmvr

    I have create a node js application that uses ffmpeg with spawn node library.

    


    Here's the backend sample :

    


    const startStreamWs = (cameraId, rtsp_url) => {
  console.log(`Starting stream for camera: ${cameraId}`);

  const ffmpeg = spawn("ffmpeg", [
    "-rtsp_transport", "tcp", // Use TCP for reliable streaming
    "-i", rtsp_url,
    "-analyzeduration", "5000000",  // Increase analyzeduration
    "-probesize", "5000000",       // Increase probesize
    "-fflags", "nobuffer",         // Reduce buffering
    "-flags", "low_delay",         // Low latency
    "-strict", "experimental",
    "-max_delay", "200000",        // Reduce max delay for faster response
    "-bufsize", "2M",              // Buffer size for smoother streaming
    "-f", "mpegts",                // MPEG-TS container for streaming
    "-codec:v", "mpeg1video",         // MPEG-1 video codec
    "-s", "1280x720",              // Video resolution
    "-r", "25",                    // Frame rate (25 fps)
    "-b:v", "1500k",               // Bitrate for video
    "-maxrate", "2000k",           // Maximum bitrate
    "-bufsize", "2M",              // Buffer size (needed with maxrate)
    "-bf", "0",                    // Disable B-frames for lower latency
    "-an",                         // Disable audio
    "-"
]);


  ffmpeg.stdout.on("data", (data) => {
    if (cameraStreams[cameraId]) {
      console.log(`Data sent for camera ${cameraId}`);
      // Broadcast stream data to all connected clients
      for (const client of cameraStreams[cameraId].clients) {
        if (client.readyState === ws.OPEN) {
          client.send(data);
        }
      }
    }
  });

  ffmpeg.stderr.on("data", (data) => {
    console.error(`FFmpeg stderr (Camera ${cameraId}): ${data.toString()}`);
    logErrorToFile(data);
  });

  ffmpeg.on("close", (code) => {
    console.log(`FFmpeg process exited for Camera ${cameraId} with code ${code}`);
    if (cameraStreams[cameraId]) {
      // Close all remaining clients
      for (const client of cameraStreams[cameraId].clients) {
        client.close();
      }
      delete cameraStreams[cameraId];
    }
  });

  return ffmpeg;
};


    


    Front End Sample my angular component

    


    import { Component, OnDestroy, OnInit } from &#x27;@angular/core&#x27;;&#xA;import { FormsModule } from &#x27;@angular/forms&#x27;;&#xA;import { ActivatedRoute } from &#x27;@angular/router&#x27;;&#xA;&#xA;declare var JSMpeg: any; // Declare JSMpeg from the global script&#xA;&#xA;@Component({&#xA;  selector: &#x27;app-video-player&#x27;,&#xA;  templateUrl: &#x27;./video-player.component.html&#x27;,&#xA;  styleUrls: [&#x27;./video-player.component.css&#x27;],&#xA;  standalone: false&#xA;})&#xA;export class VideoPlayerComponent implements OnInit, OnDestroy {&#xA;  stepSize: number = 0.1;&#xA;  private player: any;&#xA;  cameraId: string | null = null;&#xA;  ws: WebSocket | null = null; &#xA;  wsUrl: string | null = null;&#xA;&#xA;  constructor(private route: ActivatedRoute) {&#xA;    this.cameraId = this.route.snapshot.paramMap.get(&#x27;id&#x27;);&#xA;    this.wsUrl = `ws://localhost:8085?cameraId=${this.cameraId}`;&#xA;    this.ws = new WebSocket(this.wsUrl);&#xA;  }&#xA;&#xA;  async ngOnInit(): Promise<void> {&#xA;    const canvas = document.getElementById(&#x27;videoCanvas&#x27;) as HTMLCanvasElement;&#xA;    this.player = new JSMpeg.Player(this.wsUrl, { canvas: canvas });&#xA;  }&#xA;&#xA;  async ngOnDestroy(): Promise<void> {&#xA;    this.ws?.close(1000, "Exiting");&#xA;  }&#xA;&#xA;  getStepSize(): number {&#xA;    return this.stepSize;&#xA;  }&#xA;}&#xA;&#xA;&#xA;</void></void>

    &#xA;

    On localhost is fine, once i containerize, it's not. I can serve the website but not the stream.&#xA;I have the same version FFMPEG 7.1 and the codec is available.&#xA;Although I run localhost macosx and unbutu on docker.

    &#xA;

  • WARN : Tried to pass invalid video frame, marking as broken : Your frame has data type int64, but we require uint8

    5 septembre 2019, par Tavo Diaz

    I am doing some Udemy AI courses and came across with one that "teaches" a bidimensional cheetah how to walk. I was doing the exercises on my computer, but it takes too much time. I decided to use Google Cloud to run the code and see the results some hours after. Nevertheless, when I run the code I get the following error " WARN : Tried to pass
    invalid video frame, marking as broken : Your frame has data type int64, but we require uint8 (i.e. RGB values from 0-255)".

    After the code is executed, I see into the folder and I don’t see any videos (just the meta info).

    Some more info (if it helps) :
    I have a 1 CPU (4g), SSD Ubuntu 16.04 LTS

    I have not tried anything yet to solve it because I don´t know what to try. Im looking for solutions on the web, but nothing I could try.

    This is the code

    import os
    import numpy as np
    import gym
    from gym import wrappers
    import pybullet_envs


    class Hp():
       def __init__(self):
           self.nb_steps = 1000
           self.episode_lenght =   1000
           self.learning_rate = 0.02
           self.nb_directions = 32
           self.nb_best_directions = 32
           assert self.nb_best_directions &lt;= self.nb_directions
           self.noise = 0.03
           self.seed = 1
           self.env_name = 'HalfCheetahBulletEnv-v0'


    class Normalizer():
       def __init__(self, nb_inputs):
           self.n = np.zeros(nb_inputs)
           self.mean = np.zeros(nb_inputs)
           self.mean_diff = np.zeros(nb_inputs)
           self.var = np.zeros(nb_inputs)

       def observe(self, x):
           self.n += 1.
           last_mean = self.mean.copy()
           self.mean += (x - self.mean) / self.n
           #abajo es el online numerator update
           self.mean_diff += (x - last_mean) * (x - self.mean)
           #abajo online computation de la varianza
           self.var = (self.mean_diff / self.n).clip(min = 1e-2)  

       def normalize(self, inputs):
           obs_mean = self.mean
           obs_std = np.sqrt(self.var)
           return (inputs - obs_mean) / obs_std

    class Policy():
       def __init__(self, input_size, output_size):
           self.theta = np.zeros((output_size, input_size))

       def evaluate(self, input, delta = None, direction = None):
           if direction is None:
               return self.theta.dot(input)
           elif direction == 'positive':
               return (self.theta + hp.noise * delta).dot(input)
           else:
               return (self.theta - hp.noise * delta).dot(input)

       def sample_deltas(self):
           return [np.random.randn(*self.theta.shape) for _ in range(hp.nb_directions)]

       def update (self, rollouts, sigma_r):
           step = np.zeros(self.theta.shape)
           for r_pos, r_neg, d in rollouts:
               step += (r_pos - r_neg) * d
           self.theta += hp.learning_rate / (hp.nb_best_directions * sigma_r) * step


    def explore(env, normalizer, policy, direction = None, delta = None):
       state = env.reset()
       done = False
       num_plays = 0.
       #abajo puede ser promedio de las rewards
       sum_rewards = 0
       while not done and num_plays &lt; hp.episode_lenght:
           normalizer.observe(state)
           state = normalizer.normalize(state)
           action = policy.evaluate(state, delta, direction)
           state, reward, done, _ = env.step(action)
           reward = max(min(reward, 1), -1)
           #abajo sería poner un promedio
           sum_rewards += reward
           num_plays += 1
       return sum_rewards

    def train (env, policy, normalizer, hp):
       for step in range(hp.nb_steps):
           #iniciar las perturbaciones deltas y los rewards positivos/negativos
           deltas = policy.sample_deltas()
           positive_rewards = [0] * hp.nb_directions
           negative_rewards = [0] * hp.nb_directions
           #sacar las rewards en la dirección positiva
           for k in range(hp.nb_directions):
               positive_rewards[k] = explore(env, normalizer, policy, direction = 'positive', delta = deltas[k])
           #sacar las rewards en dirección negativo
           for k in range(hp.nb_directions):
               negative_rewards[k] = explore(env, normalizer, policy, direction = 'negative', delta = deltas[k])
           #sacar todas las rewards para sacar la desvest
           all_rewards = np.array(positive_rewards + negative_rewards)
           sigma_r = all_rewards.std()
           #acomodar los rollauts por el max (r_pos, r_neg) y seleccionar la mejor dirección
           scores = {k:max(r_pos, r_neg) for k, (r_pos, r_neg) in enumerate(zip(positive_rewards, negative_rewards))}
           order = sorted(scores.keys(), key = lambda x:scores[x])[:hp.nb_best_directions]
           rollouts = [(positive_rewards[k], negative_rewards[k], deltas[k]) for k in order]
           #actualizar policy
           policy.update (rollouts, sigma_r)
           #poner el final reward del policy luego del update
           reward_evaluation = explore (env, normalizer, policy)
           print('Paso: ', step, 'Lejania: ', reward_evaluation)

    def mkdir(base, name):
       path = os.path.join(base, name)
       if not os.path.exists(path):
           os.makedirs(path)
       return path
    work_dir = mkdir('exp', 'brs')
    monitor_dir = mkdir(work_dir, 'monitor')

    hp = Hp()
    np.random.seed(hp.seed)
    env = gym.make(hp.env_name)
    env = wrappers.Monitor(env, monitor_dir, force = True)
    nb_inputs = env.observation_space.shape[0]
    nb_outputs = env.action_space.shape[0]
    policy = Policy(nb_inputs, nb_outputs)
    normalizer = Normalizer(nb_inputs)
    train(env, policy, normalizer, hp)
  • Error being thrown by ffmpeg and ffserver, not getting a stream

    2 novembre 2015, par rotheman

    i am trying to stream a file that I have in my directory using ffmpeg and ffserver. But an error occurs in both ffmpeg and ffserver. The following is my ffserver config file.

    HTTPPort 8092
    HTTPBindAddress 0.0.0.0
    MaxHTTPConnections 2000
    MaxClients 1000
    MaxBandwidth 2000
    CustomLog -
    #NoDaemon
    NoDefaults

    <feed>
     File /tmp/feed1.ffm
     FileMaxSize 20M
     ACL allow 127.0.0.1
    </feed>

    <stream>      
     Feed feed1.ffm            
     Format webm

     AudioCodec vorbis
     AudioBitRate 64            

     VideoCodec libvpx
     VideoSize 720x576          
     VideoFrameRate 25          
     AVOptionVideo flags +global_header  
     AVOptionVideo cpu-used 0
     AVOptionVideo qmin 10
     AVOptionVideo qmax 42
     AVOptionVideo quality good
     AVOptionAudio flags +global_header
     PreRoll 15
     StartSendOnKey
     VideoBitRate 400
     AudioSampleRate 44100          
    </stream>

    I am able to start ffserver properly with no problems but when i try to serve ffserver with a file using ffmpeg, this happens

    ffmpeg -i sam.webm http://127.0.0.1:8092/feed1.ffm -vcodec copy
     ffmpeg version N-72738-g7630cce Copyright (c) 2000-2015 the FFmpeg developers
     built with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
     configuration: --enable-libvpx --enable-libvorbis --enable-libx264 --enable-gpl --enable-nonfree
     libavutil      54. 27.100 / 54. 27.100
     libavcodec     56. 41.100 / 56. 41.100
     libavformat    56. 36.100 / 56. 36.100
     libavdevice    56.  4.100 / 56.  4.100
     libavfilter     5. 16.101 /  5. 16.101
     libswscale      3.  1.101 /  3.  1.101
     libswresample   1.  2.100 /  1.  2.100
     libpostproc    53.  3.100 / 53.  3.100
     Trailing options were found on the commandline.
     Input #0, matroska,webm, from 'sam.webm':
     Metadata:
       title           : Sintel Trailer
       encoder         : Lavf56.25.101
     Duration: 00:00:52.21, start: 0.000000, bitrate: 305 kb/s
     Stream #0:0: Video: vp8, yuv420p, 854x480, SAR 1:1 DAR 427:240, 24 fps, 24 tbr, 1k tbn, 1k tbc (default)
    Stream #0:1: Audio: vorbis, 48000 Hz, stereo, fltp (default)
    [libvpx @ 0x367e180] v1.3.0
    Output #0, ffm, to 'http://127.0.0.1:8092/feed1.ffm':
    Metadata:
     title           : Sintel Trailer
     creation_time   : now
     encoder         : Lavf56.36.100
    Stream #0:0: Audio: vorbis (libvorbis), 44100 Hz, stereo, fltp, 64 kb/s (default)
    Metadata:
     encoder         : Lavc56.41.100 libvorbis
    Stream #0:1: Video: vp8 (libvpx), yuv420p, 720x576 [SAR 427:300 DAR 427:240], q=10-42, 400 kb/s, 24 fps, 1000k tbn, 25 tbc (default)
    Metadata:
     encoder         : Lavc56.41.100 libvpx
    Stream mapping:
     Stream #0:1 -> #0:0 (vorbis (native) -> vorbis (libvorbis))
     Stream #0:0 -> #0:1 (vp8 (native) -> vp8 (libvpx))
    Press [q] to stop, [?] for help
    av_interleaved_write_frame(): Connection reset by peer
       Last message repeated 2 times
      frame=   14 fps=0.0 q=0.0 Lsize=      16kB time=00:00:00.56 bitrate= 234.1kbits/s dup=1 drop=0    
      video:1kB audio:2kB subtitle:0kB other streams:0kB global headers:4kB muxing overhead: 327.780670%
      Conversion failed!

    And this is the message i get in ffserver when this error happens in ffmpeg.

    ffserver
    ffserver version N-72738-g7630cce Copyright (c) 2000-2015 the FFmpeg developers
    built with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
    configuration: --enable-libvpx --enable-libvorbis --enable-libx264 --enable-gpl --enable-nonfree
    libavutil      54. 27.100 / 54. 27.100
    libavcodec     56. 41.100 / 56. 41.100
    libavformat    56. 36.100 / 56. 36.100
    libavdevice    56.  4.100 / 56.  4.100
    libavfilter     5. 16.101 /  5. 16.101
    libswscale      3.  1.101 /  3.  1.101
    libswresample   1.  2.100 /  1.  2.100
    libpostproc    53.  3.100 / 53.  3.100
    Mon Jun  8 18:38:28 2015 FFserver started.
    Mon Jun  8 18:38:40 2015 127.0.0.1 - - [GET] "/feed1.ffm HTTP/1.1" 200 4175
    Mon Jun  8 18:38:40 2015 [NULL @ 0x29878a0]Missing key or no key/value separator found after key 'pkt_timebase'
    Mon Jun  8 18:38:40 2015 Feed '/tmp/feed1.ffm' stream number does not match registered feed
    Mon Jun  8 18:38:40 2015 127.0.0.1 - - [POST] "/feed1.ffm HTTP/1.1" 200 4096

    Can someone please help me ?