
Recherche avancée
Autres articles (48)
-
(Dés)Activation de fonctionnalités (plugins)
18 février 2011, parPour gérer l’ajout et la suppression de fonctionnalités supplémentaires (ou plugins), MediaSPIP utilise à partir de la version 0.2 SVP.
SVP permet l’activation facile de plugins depuis l’espace de configuration de MediaSPIP.
Pour y accéder, il suffit de se rendre dans l’espace de configuration puis de se rendre sur la page "Gestion des plugins".
MediaSPIP est fourni par défaut avec l’ensemble des plugins dits "compatibles", ils ont été testés et intégrés afin de fonctionner parfaitement avec chaque (...) -
Les tâches Cron régulières de la ferme
1er décembre 2010, parLa gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
Le super Cron (gestion_mutu_super_cron)
Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...) -
HTML5 audio and video support
13 avril 2011, parMediaSPIP 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 (5708)
-
How to Play AVI file in a Loop
10 octobre 2019, par samI 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;
}- 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.
- How can I play the video by passing the frame number instead of automatic loop ?
-
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 worldWhat 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();
 }
}



-
Play video using ffmpeg subprocess
17 juin 2023, par MCDThe following code stuck in the middle of the video. I want to play the video start at
start_seconds
and end atend_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 atend_second
. I usedcv2.set
but it took long time to play from start_second.