
Recherche avancée
Médias (2)
-
GetID3 - Bloc informations de fichiers
9 avril 2013, par
Mis à jour : Mai 2013
Langue : français
Type : Image
-
GetID3 - Boutons supplémentaires
9 avril 2013, par
Mis à jour : Avril 2013
Langue : français
Type : Image
Autres articles (105)
-
Les formats acceptés
28 janvier 2010, parLes commandes suivantes permettent d’avoir des informations sur les formats et codecs gérés par l’installation local de ffmpeg :
ffmpeg -codecs ffmpeg -formats
Les format videos acceptés en entrée
Cette liste est non exhaustive, elle met en exergue les principaux formats utilisés : h264 : H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 m4v : raw MPEG-4 video format flv : Flash Video (FLV) / Sorenson Spark / Sorenson H.263 Theora wmv :
Les formats vidéos de sortie possibles
Dans un premier temps on (...) -
Gestion de la ferme
2 mars 2010, parLa ferme est gérée dans son ensemble par des "super admins".
Certains réglages peuvent être fais afin de réguler les besoins des différents canaux.
Dans un premier temps il utilise le plugin "Gestion de mutualisation" -
ANNEXE : Les plugins utilisés spécifiquement pour la ferme
5 mars 2010, parLe site central/maître de la ferme a besoin d’utiliser plusieurs plugins supplémentaires vis à vis des canaux pour son bon fonctionnement. le plugin Gestion de la mutualisation ; le plugin inscription3 pour gérer les inscriptions et les demandes de création d’instance de mutualisation dès l’inscription des utilisateurs ; le plugin verifier qui fournit une API de vérification des champs (utilisé par inscription3) ; le plugin champs extras v2 nécessité par inscription3 (...)
Sur d’autres sites (7090)
-
how to send audio or video by packet though udp and sync the iamge and audio
24 janvier 2019, par Wei Wenhow to send part of video and audio from mp4 as packet though udp from server
Client will play the part of packet resevice.import java.awt.Dimension ; import java.awt.image.BufferedImage ; import
java.io.ByteArrayOutputStream ; import java.io.IOException ; import
java.io.ObjectOutputStream ; import java.math.BigInteger ; import
java.net.DatagramPacket ; import java.net.DatagramSocket ; import
java.net.ServerSocket ; import java.net.Socket ; import
java.nio.ByteBuffer ; import java.nio.ShortBuffer ; import
java.util.ArrayList ; import java.util.Arrays ; import
javax.imageio.ImageIO ; import javax.sound.sampled.AudioFileFormat ;
import javax.sound.sampled.AudioFormat ; import javax.swing.JTextArea ;import org.bytedeco.javacv.FFmpegFrameGrabber ; import
org.bytedeco.javacv.Frame ; import
org.bytedeco.javacv.Java2DFrameConverter ;import Enum.EType.ClientState ; import View.SingleDisplayWindow ;
import java.security.InvalidKeyException ; import
java.security.NoSuchAlgorithmException ; import java.util.Timer ; import
java.util.TimerTask ; import java.util.concurrent.CountDownLatch ;
import java.util.concurrent.ExecutionException ;import javax.crypto.BadPaddingException ; import
javax.crypto.IllegalBlockSizeException ; import
javax.crypto.NoSuchPaddingException ; import
org.bytedeco.javacv.FrameGrabber ;public class SCon private final static int PORT = 8888 ;
private final JTextArea TEXT_AREA ; private volatile
SingleDisplayWindow DISPLAY ; /////private final String BD_USER_NAME, DB_PASSWORD ; private Database
database ;private boolean isRunning ;
private RSA serverRSA, clientRSA ;
private int keyIndex, typeID = 0 ; private String mediatype = "" ;
private ArrayList sHandlers ;private FileStreamingThread fileStreamingThread ; private
VideoStreamingThread videoStreamingThread ; private BroadcastThread
broadcastThread ; private ConnectThread connectThread ;private volatile static byte[] currentVideoFrame = new byte[0],
currentAudioFrame = new byte[0] ; // current image musicpublic void run() startServer() ;
isRunning = true; fileStreamingThread = new
FileStreamingThread(videoFile) ; videoStreamingThread = new
VideoStreamingThread(videoFile) ;
//CountDownLatch latch = new CountDownLatch(1) ; fileStreamingThread.start() ; videoStreamingThread.start() ;
//latch.countDown() ;broadcastThread = new BroadcastThread(); broadcastThread.start();
connectThread = new ConnectThread(); connectThread.start(); }public void stop() isRunning = false ;
try { new Socket("localhost", PORT);
} catch (IOException e) { e.printStackTrace(); }
while (fileStreamingThread.isAlive()) {
}
while (broadcastThread.isAlive()) {
}
while (connectThread.isAlive()) {
}
for (SHandler sHandler : sHandlers) { sHandler.connectionClose();
} sHandlers.clear(); DISPLAY.dispose();
TEXT_AREA.append("\nServer stop\n"); }
private class VideoStreamingThread extends Thread { privateFFmpegFrameGrabber grabber ; // Used to extract frames from video file.
private Java2DFrameConverter converter ; // Used to convert frames to
image private int curIndex ; // Current key indexpublic VideoStreamingThread(String video_file) { videoFile =
videoFile ; grabber = new FFmpegFrameGrabber(videoFile) ;
converter = new Java2DFrameConverter() ; try
grabber.restart() ;} catch (FrameGrabber.Exception e) {
e.printStackTrace(); } curIndex = keyIndex; }
public void run() { try {
while (isRunning) {
curIndex = keyIndex;
Frame frame = null;
System.out.println("v1");
if ((frame = grabber.grab()) != null) { // Grab next frame from video file
if (frame.image != null) { // image frame
BufferedImage bi = converter.convert(frame); // convert frame to image
// Convert BufferedImage to byte[]
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(bi, "jpg", baos);
// Encrypt data and store as the current image of byte[] type
currentVideoFrame = ciphers[curIndex].doFinal(baos.toByteArray());
//////////////////
DISPLAY.setSize(new Dimension(bi.getWidth(), bi.getHeight()));
DISPLAY.updateImage(bi); // Display image
// Thread.sleep((long) ( 999 / grabber.getFrameRate()));
///////////////
typeID = 1;
mediatype = grabber.getFormat();
}
} else {
grabber.restart();
} // Restart when reached end of video
}
grabber.close();
} catch (IOException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
} //catch (InterruptedException e) {e.printStackTrace(); } }
public synchronized int getCurKeyIndex() { return curIndex; }
public synchronized void getVideoFile(String video_file) {
videoFile = video_file; grabber = newFFmpegFrameGrabber(video_file) ; converter = new
Java2DFrameConverter() ;try {
grabber.release();
grabber.restart();
} catch (FrameGrabber.Exception e) {
e.printStackTrace(); } } } private class FileStreamingThread extends Thread { private FFmpegFrameGrabbergrabber ; // Used to extract frames from video file. private int
curIndex ; // Current key indexpublic FileStreamingThread(String video_file) { videoFile =
videoFile ; grabber = new FFmpegFrameGrabber(videoFile) ; try
grabber.restart() ;} catch (FrameGrabber.Exception e) {
e.printStackTrace(); } curIndex = keyIndex; }
public void run() { try {
while (isRunning) {
curIndex = keyIndex;
Frame frame = null;
System.out.println("a2");
if ((frame = grabber.grabSamples()) != null) { // Grab next frame from video file
if (frame.samples != null) { // audio frame
// Encrypt audio
ShortBuffer channelSamplesShortBuffer = (ShortBuffer) frame.samples[0];
channelSamplesShortBuffer.rewind();
ByteBuffer outBuffer = ByteBuffer.allocate(channelSamplesShortBuffer.capacity() * 2);
for (int i = 0; i < channelSamplesShortBuffer.capacity(); i++) {
short val = channelSamplesShortBuffer.get(i);
outBuffer.putShort(val);
}
AudioFileFormat audiofileFormat = new AudioFileFormat(null, null, typeID);
AudioFormat audioFormat = new AudioFormat(44100, 16, 2, true, true);
//System.out.println(grabber.getSampleFormat());
// Encrypt data and store as the current audio of byte[] type
currentAudioFrame = ciphers[curIndex].doFinal(outBuffer.array());
DISPLAY.updateAudio(outBuffer.array(), grabber.getFormat()); // Display image audio
// Thread.sleep((long) (1000 / grabber.getSampleRate()));
// AudioFormat audioFormat = new AudioFormat(grabber.getSampleRate(), grabber.getAudioBitrate(),grabber.getAudioChannels(), true, true) ;
// DISPLAY.updateAudio(outBuffer.array(), audioFormat) ; //
Display image audio
outBuffer.clear() ;typeID = 2;
mediatype = grabber.getFormat();
}
} else {
grabber.restart();
} // Restart when reached end of video
}
grabber.close();
} catch (IOException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
} }
public synchronized int getCurKeyIndex() { return curIndex; }
public synchronized void getVideoFile(String video_file) {
videoFile = video_file; grabber = newFFmpegFrameGrabber(video_file) ;
try {
grabber.release();
grabber.restart();
} catch (FrameGrabber.Exception e) {
e.printStackTrace(); } } }public void setVideoFile(String videoFile) this.videoFile =
videoFile ;public void setThreadFile(String video_file)
fileStreamingThread.getVideoFile(video_file) ;
videoStreamingThread.getVideoFile(video_file) ;private class BroadcastThread extends Thread public void run()
while (isRunning)
Thread.yield() ;for (int i = 0; i < sHandlers.size(); i++) {
if (sHandlers.get(i).getClientState() == ClientState.R) {
sHandlers.get(i).setClientState(ClientState.W);
BroadcastWorker workerThread = new BroadcastWorker(sHandlers.get(i));
workerThread.start();
}
} } } }private class BroadcastWorker extends Thread SHandler sHandler =
null ;public BroadcastWorker(SHandler sHandler) { this.sHandler =
sHandler ;
public void run() { try {
DatagramSocket out = new DatagramSocket(); // used to send UDP packets
while (sHandler.getClientState() == ClientState.W) {
Thread.yield();
StreamFile s = new StreamFile(typeID, currentVideoFrame, currentAudioFrame, mediatype);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ObjectOutputStream os = new ObjectOutputStream(outputStream);
os.writeObject(s);
byte[] data = outputStream.toByteArray();
// Create and send UDP packet
DatagramPacket videoPacket = new DatagramPacket(data, data.length,
sHandler.getClientSocket().getInetAddress(),
Integer.parseInt(sHandler.getClientPort()));
out.send(videoPacket);
} } catch (IOException e) {
e.printStackTrace(); } } }private class ConnectThread extends Thread public void run()
TEXT_AREA.append("\nWaiting for clients’ connection.....\n") ;try {
ServerSocket serverSocket = new ServerSocket(PORT);
Socket clientSocket = null;
while (isRunning) {
clientSocket = serverSocket.accept();
if (isRunning) {
SHandler sHandler = new SHandler(clientSocket, serverRSA, clientRSA, sessionKeys[keyIndex],
TEXT_AREA);
sHandler.start();
sHandlers.add(sHandler);
}
}
serverSocket.close();
if (clientSocket != null) {
clientSocket.close();
}
} catch (IOException e) {
e.printStackTrace(); } } } }my audio and image not sync.
-
using Accord.Video.FFMPEG aka(AForge) give exception error paramter is not valid. how to solve it ?
12 avril 2023, par Sheron BlumentalI want to extract all the frames from a mp4 video file and display them on a pictureBox.


The exception happens after clicking the start button on the line :


var frame = videoReader.ReadVideoFrame();



the message


System.ArgumentException
 HResult=0x80070057
 Message=Parameter is not valid.
 Source=System.Drawing
 StackTrace:
 at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)
 at Accord.Video.FFMPEG.VideoFileReader.DecodeVideoFrame(BitmapData bitmapData)
 at Accord.Video.FFMPEG.VideoFileReader.readVideoFrame(Int32 frameIndex, BitmapData output)
 at Accord.Video.FFMPEG.VideoFileReader.ReadVideoFrame()
 at Extract_Frames.Form1.<getvideoframesasync>d__15.MoveNext() in D:\Csharp Projects\Extract Frames\Form1.cs:line 114
 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
 at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
 at Extract_Frames.Form1.d__17.MoveNext() in D:\Csharp Projects\Extract Frames\Form1.cs:line 151
</getvideoframesasync>


the full code


using Accord.IO;
using Accord.Video;
using Accord.Video.FFMPEG;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Extract_Frames
{
 public partial class Form1 : Form
 {
 Bitmap frame = null;
 Graphics frameGraphics = null;
 bool isVideoRunning = false;
 IProgress<bitmap> videoProgress = null;
 private CancellationTokenSource cts = null;
 private readonly object syncRoot = new object();
 private static long pause = 0;
 private int frameRate = 0;
 private List<bitmap> frames = new List<bitmap>();
 string fileName;

 public Form1()
 {
 InitializeComponent();
 
 }

 private void Form1_Load(object sender, EventArgs e)
 {

 }

 private void StopPlayback(bool cancel)
 {
 lock (syncRoot)
 {
 if (cancel) cts?.Cancel();
 cts?.Dispose();
 cts = null;
 }
 }

 int counter =1;
 private void Updater(Bitmap videoFrame)
 {
 frames.Add(videoFrame);

 label1.Text = "Current Frame Number : " + counter;
 trackBar1.Value = counter;
 counter++;

 //Size size = new Size(videoFrame.Width, videoFrame.Height);
 //pictureBox1.ClientSize = size;
 using (videoFrame) frameGraphics.DrawImage(videoFrame, Point.Empty);

 pictureBox1.Invalidate();
 }

 private async Task GetVideoFramesAsync(IProgress<bitmap> updater, string fileName, int intervalMs, CancellationToken token = default)
 {
 using (var videoReader = new VideoFileReader())
 {
 if (token.IsCancellationRequested) return;
 videoReader.Open(fileName);

 videoReader.ReadVideoFrame(1);
 trackBar1.Value = 1;

 label1.Text = "Current Frame Number : " + counter.ToString();

 while (true)
 {
 if (Interlocked.Read(ref pause) == 0)
 {
 var frame = videoReader.ReadVideoFrame();

 if (token.IsCancellationRequested || frame is null) break;
 updater.Report(frame);
 }
 await Task.Delay(frameRate).ConfigureAwait(false);
 }
 }
 }

 private void trackBar2_Scroll(object sender, EventArgs e)
 {
 frameRate = trackBar2.Value / 25;
 }

 private async void buttonStart_Click(object sender, EventArgs e)
 {
 string fileName = textBox1.Text;

 if (isVideoRunning) return;
 isVideoRunning = true;

 using (var videoReader = new VideoFileReader())
 {
 videoReader.Open(fileName);
 frame = new Bitmap(videoReader.Width + 2, videoReader.Height + 2);
 trackBar1.Maximum = (int)videoReader.FrameCount;
 }

 videoProgress = new Progress<bitmap>((bitmap) => Updater(bitmap));
 cts = new CancellationTokenSource();
 pictureBox1.Image = frame;
 try
 {
 frameGraphics = Graphics.FromImage(frame);
 // Set the fame rate to 25 frames per second
 //int frameRate = 1000 / 25;
 await GetVideoFramesAsync(videoProgress, fileName, frameRate, cts.Token);
 }
 finally
 {
 frameGraphics?.Dispose();
 StopPlayback(false);
 isVideoRunning = false;
 }
 }

 private void buttonPause_Click(object sender, EventArgs e)
 {
 if (pause == 0)
 {
 buttonPause.Text = "Resume";
 Interlocked.Increment(ref pause);
 }
 else
 {
 Interlocked.Decrement(ref pause);
 buttonPause.Text = "Pause";
 }
 }

 private void buttonStop_Click(object sender, EventArgs e)
 {
 StopPlayback(true);
 }

 protected override void OnFormClosing(FormClosingEventArgs e)
 {
 if (isVideoRunning) StopPlayback(true);
 pictureBox1.Image?.Dispose();
 base.OnFormClosing(e);
 }

 private void pictureBox1_Paint(object sender, PaintEventArgs e)
 {
 ControlPaint.DrawBorder(e.Graphics, pictureBox1.ClientRectangle, Color.Red, ButtonBorderStyle.Solid);
 }

 private void trackBar1_Scroll(object sender, EventArgs e)
 {
 pictureBox1.Image = frames[trackBar1.Value];
 }

 private void button1_Click(object sender, EventArgs e)
 {
 using (OpenFileDialog openFileDialog = new OpenFileDialog())
 {
 openFileDialog.InitialDirectory = "c:\\";
 openFileDialog.Filter = "video files (*.mp4)|*.mp4|All files (*.*)|*.*";
 openFileDialog.FilterIndex = 2;
 openFileDialog.RestoreDirectory = true;

 if (openFileDialog.ShowDialog() == DialogResult.OK)
 {
 //Get the path of specified file
 textBox1.Text = openFileDialog.FileName;
 }
 }
 }
 }
}
</bitmap></bitmap></bitmap></bitmap></bitmap>


-
dynamically update image in video stream using ffmpeg
1er mars 2021, par omega1I have the following ffmpeg command which works, but I would like image3.jpg to update every 30 seconds (image3.jpg changes every 30 seconds). I read that I needed to move the file from a .tmp file image3.jpg.tmp to image3.jpg but this is not working either.


The script places a few images on screen and takes an audio stream as its input and then outputs to a RMTP server, all works except image3.jpg only updates if I stop the ffmpeg command and restart it (which I cannot do as it is a live stream).


I'm also struggling with where to add a
drawtext
within thefilter_complex
section if anyone could help with that also ?

Thanks.


ffmpeg \
 -stream_loop -1 \
 -re -y \
 -i image1.png \
 -i image2.png \
 -i image3.jpg \
 -i http://audio_stream \
 -filter_complex "[1]scale=1200:280:force_original_aspect_ratio=decrease:-1[wm]; [0][wm]overlay=1:1[bg]; [2]scale=150:635:force_original_aspect_ratio=decrease:-1[wm1]; [bg][wm1]overlay=W-w-1:1" \
 -crf 10 \
 -profile:v baseline \
 -s 1280x720 \
 -bufsize 6000k \
 -vb 400k \
 -maxrate 1500k \
 -deinterlace \
 -vcodec libx264 \
 -preset veryfast \
 -g 300 \
 -r 5 \
 -f flv \
 rtmp://rmtp_server