Recherche avancée

Médias (91)

Autres articles (58)

  • La sauvegarde automatique de canaux SPIP

    1er avril 2010, par

    Dans le cadre de la mise en place d’une plateforme ouverte, il est important pour les hébergeurs de pouvoir disposer de sauvegardes assez régulières pour parer à tout problème éventuel.
    Pour réaliser cette tâche on se base sur deux plugins SPIP : Saveauto qui permet une sauvegarde régulière de la base de donnée sous la forme d’un dump mysql (utilisable dans phpmyadmin) mes_fichiers_2 qui permet de réaliser une archive au format zip des données importantes du site (les documents, les éléments (...)

  • HTML5 audio and video support

    13 avril 2011, par

    MediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
    The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
    For older browsers the Flowplayer flash fallback is used.
    MediaSPIP allows for media playback on major mobile platforms with the above (...)

  • De l’upload à la vidéo finale [version standalone]

    31 janvier 2010, par

    Le chemin d’un document audio ou vidéo dans SPIPMotion est divisé en trois étapes distinctes.
    Upload et récupération d’informations de la vidéo source
    Dans un premier temps, il est nécessaire de créer un article SPIP et de lui joindre le document vidéo "source".
    Au moment où ce document est joint à l’article, deux actions supplémentaires au comportement normal sont exécutées : La récupération des informations techniques des flux audio et video du fichier ; La génération d’une vignette : extraction d’une (...)

Sur d’autres sites (9440)

  • Can't correctly decode an image frame using PyAV

    17 avril 2023, par Martin Blore

    I'm trying to simply encode and decode a capture frame from the web-cam. I want to be able to send this over TCP but at the moment I'm having trouble performing this just locally.

    


    Here's my code that simply takes the frame from the web-cam, encodes, then decodes, and displays the two images in a new window. The two images look like this :

    


    1

    


    Here's the code :

    


    import struct
import cv2
import socket
import av
import time
import os

class PerfTimer:
    def __init__(self, name):
        self.name = name

    def __enter__(self):
        self.start_time = time.perf_counter()

    def __exit__(self, type, value, traceback):
        end_time = time.perf_counter()
        print(f"'{self.name}' taken:", end_time - self.start_time, "seconds.")

os.environ['AV_PYTHON_AVISYNTH'] = 'C:/ffmpeg/bin'

socket_enabled = False
sock = None
if socket_enabled:
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    print("Connecting to server...")
    sock.connect(('127.0.0.1', 8000))

# Set up video capture.
print("Opening web cam...")
cap = cv2.VideoCapture(0, cv2.CAP_DSHOW)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 800)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 600)

# Initialize the encoder.
encoder = av.CodecContext.create('h264', 'w')
encoder.width = 800
encoder.height = 600
encoder.pix_fmt = 'yuv420p'
encoder.bit_rate = 5000

# Initialize the decoder.
decoder = av.CodecContext.create('h264', 'r')
decoder.width = 800
decoder.height = 600
decoder.pix_fmt = 'yuv420p'
decoder.bit_rate = 5000

print("Streaming...")
while(cap.isOpened()):
    
    # Capture the frame from the camera.
    ret, orig_frame = cap.read()

    cv2.imshow('Source Video', orig_frame)

    # Convert to YUV.
    img_yuv = cv2.cvtColor(orig_frame, cv2.COLOR_BGR2YUV_I420)

    # Create a video frame object from the num py array.
    video_frame = av.VideoFrame.from_ndarray(img_yuv, format='yuv420p')

    with PerfTimer("Encoding") as p:
        encoded_frames = encoder.encode(video_frame)

    # Sometimes the encode results in no frames encoded, so lets skip the frame.
    if len(encoded_frames) == 0:
        continue

    print(f"Decoding {len(encoded_frames)} frames...")

    for frame in encoded_frames:
        encoded_frame_bytes = bytes(frame)

        if socket_enabled:
            # Get the size of the encoded frame in bytes
            size = struct.pack('code>

    


  • I need to create a streaming app Where videos store in aws S3

    27 juillet 2023, par abuzar zaidi

    I need to create a video streaming app. where my videos will store in S3 and the video will stream from the backend. Right now I am trying to use ffmpeg in the backend but it does not work properly.

    


    what am I doing wrong in this code ? And if ffmpeg not support streaming video that store in aws s3 please suggest other options.

    


    Backend

    


    const express = require('express');
const aws = require('aws-sdk');
const ffmpeg = require('fluent-ffmpeg');
const cors = require('cors'); 
const app = express();

//   Set up AWS credentials
aws.config.update({
accessKeyId: '#######################',
secretAccessKey: '###############',
region: '###############3',
});

const s3 = new aws.S3();
app.use(cors());

app.get('/stream', (req, res) => {
const bucketName = '#######';
const key = '##############'; // Replace with the key/path of the video file in the S3 bucket
const params = { Bucket: bucketName, Key: key };
const videoStream = s3.getObject(params).createReadStream();

// Transcode to HLS format
 const hlsStream = ffmpeg(videoStream)
.format('hls')
.outputOptions([
  '-hls_time 10',
  '-hls_list_size 0',
  '-hls_segment_filename segments/segment%d.ts',
 ])
.pipe(res);

// Transcode to DASH format and pipe the output to the response
ffmpeg(videoStream)
.format('dash')
.outputOptions([
  '-init_seg_name init-stream$RepresentationID$.mp4',
  '-media_seg_name chunk-stream$RepresentationID$-$Number%05d$.mp4',
 ])
.output(res)
.run();
});

const port = 5000;
app.listen(port, () => {
console.log(`Server running on http://localhost:${port}`);
});


    


    Frontend

    


        import React from &#x27;react&#x27;;&#xA;&#xA;    const App = () => {&#xA;     const videoUrl = &#x27;http://localhost:3000/api/playlist/runPlaylist/6c3e7af45a3b8a5caf2fef17a42ef9a0&#x27;; //          Replace with your backend URL&#xA;Please list down solution or option i can use here&#xA;    const videoUrl = &#x27;http://localhost:5000/stream&#x27;;&#xA;         return (&#xA;      <div>&#xA;      <h1>Video Streaming Example</h1>&#xA;      <video controls="controls">&#xA;        <source src="{videoUrl}" type="video/mp4"></source>&#xA;        Your browser does not support the video tag.&#xA;      </video>&#xA;    </div>&#xA;     );&#xA;     };&#xA;&#xA;    export default App;&#xA;

    &#xA;

  • Can't correctly decode an image frame using OpenCV

    15 avril 2023, par Martin Blore

    I'm trying to simply encode and decode a capture frame from the web-cam. I want to be able to send this over TCP but at the moment I'm having trouble performing this just locally.

    &#xA;

    Here's my code that simply takes the frame from the web-cam, encodes, then decodes, and displays the two images in a new window. The two images look like this :

    &#xA;

    https://i.imgur.com/dGSlmrH.png

    &#xA;

    Here's the code :

    &#xA;

    import struct&#xA;import cv2&#xA;import socket&#xA;import av&#xA;import time&#xA;import os&#xA;&#xA;class PerfTimer:&#xA;    def __init__(self, name):&#xA;        self.name = name&#xA;&#xA;    def __enter__(self):&#xA;        self.start_time = time.perf_counter()&#xA;&#xA;    def __exit__(self, type, value, traceback):&#xA;        end_time = time.perf_counter()&#xA;        print(f"&#x27;{self.name}&#x27; taken:", end_time - self.start_time, "seconds.")&#xA;&#xA;os.environ[&#x27;AV_PYTHON_AVISYNTH&#x27;] = &#x27;C:/ffmpeg/bin&#x27;&#xA;&#xA;socket_enabled = False&#xA;sock = None&#xA;if socket_enabled:&#xA;    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)&#xA;    print("Connecting to server...")&#xA;    sock.connect((&#x27;127.0.0.1&#x27;, 8000))&#xA;&#xA;# Set up video capture.&#xA;print("Opening web cam...")&#xA;cap = cv2.VideoCapture(0, cv2.CAP_DSHOW)&#xA;cap.set(cv2.CAP_PROP_FRAME_WIDTH, 800)&#xA;cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 600)&#xA;&#xA;# Initialize the encoder.&#xA;encoder = av.CodecContext.create(&#x27;h264&#x27;, &#x27;w&#x27;)&#xA;encoder.width = 800&#xA;encoder.height = 600&#xA;encoder.pix_fmt = &#x27;yuv420p&#x27;&#xA;encoder.bit_rate = 5000&#xA;&#xA;# Initialize the decoder.&#xA;decoder = av.CodecContext.create(&#x27;h264&#x27;, &#x27;r&#x27;)&#xA;decoder.width = 800&#xA;decoder.height = 600&#xA;decoder.pix_fmt = &#x27;yuv420p&#x27;&#xA;decoder.bit_rate = 5000&#xA;&#xA;print("Streaming...")&#xA;while(cap.isOpened()):&#xA;    &#xA;    # Capture the frame from the camera.&#xA;    ret, orig_frame = cap.read()&#xA;&#xA;    cv2.imshow(&#x27;Source Video&#x27;, orig_frame)&#xA;&#xA;    # Convert to YUV.&#xA;    img_yuv = cv2.cvtColor(orig_frame, cv2.COLOR_BGR2YUV_I420)&#xA;&#xA;    # Create a video frame object from the num py array.&#xA;    video_frame = av.VideoFrame.from_ndarray(img_yuv, format=&#x27;yuv420p&#x27;)&#xA;&#xA;    with PerfTimer("Encoding") as p:&#xA;        encoded_frames = encoder.encode(video_frame)&#xA;&#xA;    # Sometimes the encode results in no frames encoded, so lets skip the frame.&#xA;    if len(encoded_frames) == 0:&#xA;        continue&#xA;&#xA;    print(f"Decoding {len(encoded_frames)} frames...")&#xA;&#xA;    for frame in encoded_frames:&#xA;        encoded_frame_bytes = bytes(frame)&#xA;&#xA;        if socket_enabled:&#xA;            # Get the size of the encoded frame in bytes&#xA;            size = struct.pack(&#x27;code>

    &#xA;