Recherche avancée

Médias (91)

Autres articles (60)

  • List of compatible distributions

    26 avril 2011, par

    The table below is the list of Linux distributions compatible with the automated installation script of MediaSPIP. Distribution nameVersion nameVersion number Debian Squeeze 6.x.x Debian Weezy 7.x.x Debian Jessie 8.x.x Ubuntu The Precise Pangolin 12.04 LTS Ubuntu The Trusty Tahr 14.04
    If you want to help us improve this list, you can provide us access to a machine whose distribution is not mentioned above or send the necessary fixes to add (...)

  • Support audio et vidéo HTML5

    10 avril 2011

    MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
    Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
    Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
    Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)

  • 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 (...)

Sur d’autres sites (11510)

  • 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.

    


    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 :

    


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

    


    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>

    


  • How to Concatenate bunch of videos using python ?

    5 juillet 2023, par Saikat Chakraborty

    So, I have over 5000 small clips that I need to combine. To apply various custom filter over their names, I want to do it with python. I have the following code :

    


    import os
from moviepy.editor import *
os.chdir('D:/videos')
list1, list2 = os.listdir(), []

for i in list1: #filtering
    if i[-6:] != '-l.mp4' and i[-7:] != 'ALT.mp4':
        list2.append(i)
print('Getting Video Info:')

final = VideoFileClip(list2[0])


for i in range(1,len(list2)):
    final = concatenate_videoclips([final, VideoFileClip(list2[i])])
    print('\r' + str(i+1) + '/' + str(len(list2)), end='')


os.chdir('D:')
final.write_videofile('Merged.mp4')


    


    But the program is creating lots of processes and just after reading 150 clips it's crashing.
enter image description here
It keeps increasing !
Is there any easier way/alternative to do this ? Thanks !

    


    Edit :
    
I've tried using ffmpeg too, but concatenation removes the audio since concat protocol doesn't support .mp4 extension. In that case. Even if I convert all the files to .ts extension and try to concatenate them,WindowsError: [Error 206] The filename or extension is too long pops up because too many files are separated by |. I did the following changes after converting all the files to .ts format :

    


    import os
import ffmpeg
os.chdir('D:/videos')
list1 = os.listdir()
list2 = [i for i in list1 if i[-3:] == '.ts']
list2[0] = ffmpeg.input(list2[0])
for i in range(1, len(list2)):
    list2[i] = ffmpeg.concat(list2[i-1], ffmpeg.input(list2[i]))
    print('\r' + str(i) + '/' + str(len(list2)), end='')
ffmpeg.output(list2[-1], 'D:\Merged.mp4')
ffmpeg.run(list2[-1])


    


    But now I'm getting RecursionError: maximum recursion depth exceeded while calling a Python object.

    


  • How can I add a random watermark to a video during processing in Node.js and Express.js using FFmpeg ?

    3 avril 2023, par Ariful islam

    I want to add a watermark to a video that changes randomly during processing. I am using Node.js and Express.js with FFmpeg. Currently, I am able to add a static watermark to the video using the drawtext filter. However, I want to change the watermark text randomly every few seconds.

    


    How can I achieve this using FFmpeg in my Node.js and Express.js app ? Here's my current code :

    


    const email = 'name@gmail.com';
app.post('/addwatermark', upload.single('video'), (req, res) => {
const fileName = path.basename(req.file.path) + '.mp4';
const outputPath = `public/reduceSize/${fileName}`;
const outputPathWithWatermark = `public/reduceSize/${fileName}-wm.mp4`;
let watermarkPosition = { x: 10, y: 650 };

// Create the directory if it doesn't exist
const outputDir = path.dirname(outputPathWithWatermark);
if (!fs.existsSync(outputDir)) {
    fs.mkdirSync(outputDir, { recursive: true });
}

// Send a comment to keep the connection alive
res.write(': ping\n\n');

// Function to randomly generate watermark position
const changeWatermarkPosition = () => {
    watermarkPosition = { x: Math.floor(Math.random() * 100), y: Math.floor(Math.random() * 100) };
};

// Change watermark position every 5 seconds 
setInterval(changeWatermarkPosition, 5000);
const watermarkStyle = `-vf drawtext=text='${email}':x=(w-text_w-10):y=(h-text_h-10):fontcolor=white:fontsize=24:shadowcolor=black:shadowx=1:shadowy=1:box=1:y=${watermarkPosition.y}:fontcolor=red:fontsize=24:shadowcolor=black:shadowx=1:shadowy=1:box=1:boxcolor=black@0.5`

ffmpeg(req.file.path)
    .addOption(watermarkStyle)
    .output(outputPathWithWatermark)
    .videoCodec('libx264')
    .audioCodec('aac')
    .size('50%')
    .on('error', (err) => {
        console.error(`FFmpeg error: ${err.message}`);
        res.status(500).json({ message: err.message });
    })
    .on('progress', (progress) => {
        // Set the watermark position every 5 seconds randomly
        changeWatermarkPosition();

        const mb = progress.targetSize / 1024;
        const data = {
            message: `Processing: ${mb.toFixed(2)} MB converted`,
            watermark: `Adding watermark to video: ${progress.framesProcessed} frames processed`
        };
        console.log(data.message);
        res.write(`data: ${JSON.stringify(data)}\n\n`);

    })
    .on('end', () => {
        console.log(`Video successfully converted to ${outputPathWithWatermark}`);
        // Remove the temporary file
    })
    .run();
 });


    


    I want to secure my video from unauthorized person by using email in a video and the email will be move around the video randomly every 5 seconds.

    


    I have read this (Add dynamic watermark that randomly changes position over video React/Node) document but didn't get any solution.