Recherche avancée

Médias (0)

Mot : - Tags -/metadatas

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (112)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

  • Encoding and processing into web-friendly formats

    13 avril 2011, par

    MediaSPIP automatically converts uploaded files to internet-compatible formats.
    Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
    Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
    Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
    All uploaded files are stored online in their original format, so you can (...)

  • Ajouter des informations spécifiques aux utilisateurs et autres modifications de comportement liées aux auteurs

    12 avril 2011, par

    La manière la plus simple d’ajouter des informations aux auteurs est d’installer le plugin Inscription3. Il permet également de modifier certains comportements liés aux utilisateurs (référez-vous à sa documentation pour plus d’informations).
    Il est également possible d’ajouter des champs aux auteurs en installant les plugins champs extras 2 et Interface pour champs extras.

Sur d’autres sites (7207)

  • Play video using ffmpeg subprocess

    17 juin 2023, par MCD

    The following code stuck in the middle of the video. I want to play the video start at start_seconds and end at end_seconds.

    


    import subprocess
import cv2
import numpy as np
import subprocess

def play_video_with_ffmpeg(video_path, start_seconds, end_seconds):
print(start_seconds)

    # Set the desired frame size
    width = 920
    height = 600
    
    # Set the window position
    print("here")
    window_x = 600  # X position
    window_y = 10  # Y position
    cv2.namedWindow('Video Player', cv2.WINDOW_NORMAL)
    cv2.moveWindow('Video Player', window_x, window_y)
    
    # Build the ffmpeg command to skip to the desired start time and end time
    command = [
        'ffmpeg',
        '-ss', str(start_seconds),
        '-i', video_path,
        '-t', str((end_seconds - start_seconds)),
        '-vf', f'scale={width}:{height}',
        '-r', '30',
        '-f', 'image2pipe',
        '-pix_fmt', 'bgr24',
        '-vcodec', 'rawvideo',
        '-'
    ]
    
    # Open a subprocess to execute the ffmpeg command
    process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    
    # Create a buffer to hold the frame data
    buffer_size = width * height * 3
    frame_buffer = bytearray(buffer_size)
    
    while process.poll() is None:
        # Read the frame from the subprocess stdout into the buffer
        bytes_read = process.stdout.readinto(frame_buffer)
    
        if bytes_read == buffer_size:
            # Convert the frame buffer to a numpy array
            frame = np.frombuffer(frame_buffer, dtype='uint8').reshape((height, width, 3))
    
            # Resize the frame
            frame_resized = cv2.resize(frame, (width, height), interpolation=cv2.INTER_AREA)
    
            # Display the frame
            cv2.imshow('Video Player', frame_resized)
    
            if cv2.waitKey(1) & 0xFF == ord('q'):
                break
    
    process.stdout.close()
    process.stderr.close()
    cv2.destroyAllWindows()


    


    I expect to play the video start from start_second and end at end_second. I used cv2.set but it took long time to play from start_second.

    


  • Could you please guide me on how to play a single sample of an audio file in C# using FFmpeg ?

    11 juillet 2023, par hello world

    What is the recommended approach for playing a single sample of an audio file in C# using FFmpeg ? I would like to incorporate FFmpeg into my C# application to play a specific sample from an audio file. Could someone provide an example or guide me on how to achieve this ? Any help would be appreciated.

    


    using System;
using System.Diagnostics;

public class AudioPlayer
{
    private string ffmpegPath;

    public AudioPlayer(string ffmpegPath)
    {
        this.ffmpegPath = ffmpegPath;
    }

    public void PlayAudioSample(string audioFilePath, TimeSpan samplePosition)
    {
        // Prepare FFmpeg process
        Process ffmpegProcess = new Process();
        ffmpegProcess.StartInfo.FileName = ffmpegPath;
        ffmpegProcess.StartInfo.Arguments = $"-ss {samplePosition} -i \"{audioFilePath}\" -t 1 -acodec pcm_s16le -f wav -";
        ffmpegProcess.StartInfo.RedirectStandardOutput = true;
        ffmpegProcess.StartInfo.RedirectStandardError = true;
        ffmpegProcess.StartInfo.UseShellExecute = false;
        ffmpegProcess.StartInfo.CreateNoWindow = true;

        // Start FFmpeg process
        ffmpegProcess.Start();

        // Play audio sample
        using (var audioOutput = new NAudio.Wave.WaveOutEvent())
        {
            using (var audioStream = new NAudio.Wave.RawSourceWaveStream(ffmpegProcess.StandardOutput.BaseStream, new NAudio.Wave.WaveFormat(44100, 16, 2)))
            {
                audioOutput.Init(audioStream);
                audioOutput.Play();
                while (audioOutput.PlaybackState == NAudio.Wave.PlaybackState.Playing)
                {
                    System.Threading.Thread.Sleep(100);
                }
            }
        }

        // Wait for FFmpeg process to exit
        ffmpegProcess.WaitForExit();
    }
}


    


  • How to Play AVI file in a Loop

    10 octobre 2019, par sam

    I am using ffMpeg to play AVI file.

    This is my code where i am reading the frame..

    i define my structure

    typedef struct {

       AVFormatContext *fmt_ctx;
       int stream_idx;
       AVStream *video_stream;
       AVCodecContext *codec_ctx;
       AVCodec *decoder;
       AVPacket *packet;
       AVFrame *av_frame;
       AVFrame *gl_frame;
       struct SwsContext *conv_ctx;
       GLuint frame_tex;
    }AppData;

    This is how i read frame.

    bool readFrame(AppData *data)
    {
       do {
           if (av_read_frame(data->fmt_ctx, data->packet) < 0) {
               av_free_packet(data->packet);
               return false;
           }

           if (data->packet->stream_index == data->stream_idx)
           {
               int frame_finished = 0;

               if (avcodec_decode_video2(data->codec_ctx, data->av_frame, &frame_finished,
                   data->packet) < 0) {
                   av_free_packet(data->packet);
                   return false;
               }

               if (frame_finished)
               {
                   if (!data->conv_ctx)
                   {
                       data->conv_ctx = sws_getContext(data->codec_ctx->width,
                           data->codec_ctx->height, data->codec_ctx->pix_fmt,
                           data->codec_ctx->width, data->codec_ctx->height, AV_PIX_FMT_RGBA,
                           SWS_BICUBIC, NULL, NULL, NULL);
                   }

                   sws_scale(data->conv_ctx, data->av_frame->data, data->av_frame->linesize, 0,
                       data->codec_ctx->height, data->gl_frame->data, data->gl_frame->linesize);

                   glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, data->codec_ctx->width,
                       data->codec_ctx->height, GL_RGBA, GL_UNSIGNED_BYTE,
                       data->gl_frame->data[0]);

               }

           }
           av_free_packet(data->packet);

       } while (data->packet->stream_index != data->stream_idx);

       return true;

    }
    1. Currently the video plays and stops at the last frame, how can I reset the frame number to start frame once the whole video is played.
    2. How can I play the video by passing the frame number instead of automatic loop ?