
Recherche avancée
Autres articles (49)
-
Mise à jour de la version 0.1 vers 0.2
24 juin 2013, parExplications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...) -
Personnaliser en ajoutant son logo, sa bannière ou son image de fond
5 septembre 2013, parCertains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;
-
Ecrire une actualité
21 juin 2013, parPrésentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
Vous pouvez personnaliser le formulaire de création d’une actualité.
Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)
Sur d’autres sites (8747)
-
JAVA Spring : Grabbing Image from a multipartFile video via FFMPEG JavaCV
29 août 2023, par Thanh Hiếu NguyễnI'm trying to achieve Grabbing a frame from a MultipartFile or URL and here's my attempt.


URL :


InputStream inputStream = new java.net.URL(video.getUrl()).openStream();

FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(inputStream);
grabber.start();

int frameRate = (int) grabber.getFrameRate();
int targetFrameNumber = (int) (frameRate * timeLengthSeconds);

grabber.setFrameNumber(targetFrameNumber);
Frame frame = grabber.grab();

grabber.stop();

if (frame != null) {
 Java2DFrameConverter converter = new Java2DFrameConverter();
 BufferedImage bufferedImage = converter.getBufferedImage(frame);
 ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
 ImageIO.write(bufferedImage, "jpeg", byteArrayOutputStream);
 byte[] bytes = byteArrayOutputStream.toByteArray();



MultipartFile :


byte[] videoBytes = video.getBytes();

FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(new ByteArrayInputStream(videoBytes));
int frameRate = (int) 30;
int targetFrameNumber = (int) (frameRate * timeLengthSeconds);

grabber.setFrameNumber(targetFrameNumber);
grabber.setVideoStream(10);
grabber.start();


Frame frame = grabber.grab();

grabber.stop();

if (frame != null) {
 Java2DFrameConverter converter = new Java2DFrameConverter();
 BufferedImage bufferedImage = converter.getBufferedImage(frame);
 ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
 ImageIO.write(bufferedImage, "jpeg", byteArrayOutputStream);
 byte[] bytes = byteArrayOutputStream.toByteArray();



Both of them generates an AUDIO type of Frame, so later I can't buffer an image out of it, tried different videos, frameRate, frameNumber, same result.


UPDATE :

So I manage to get the frame with following code

byte[] videoBytes = video.getBytes();
FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(new ByteArrayInputStream(videoBytes));
grabber.setFormat("mp4");
int frameRate = (int) grabber.getFrameRate();
int targetFrameNumber = (int) (frameRate * timeLengthSeconds);

grabber.setFrameNumber(targetFrameNumber);
grabber.setVideoStream(0);
grabber.start();


Frame frame = grabber.grabImage();

grabber.stop();



But another problem occurred


A fatal error has been detected by the Java Runtime Environment:

EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000001dd6cac79d6, pid=20824, tid=21048 
 JRE version: Java(TM) SE Runtime Environment 18.9 (11.0.12+8) (build 11.0.12+8-LTS-237)
 Java VM: Java HotSpot(TM) 64-Bit Server VM 18.9 (11.0.12+8-LTS-237, mixed mode, tiered, compressed oops, g1 gc, windows-amd64)
 Problematic frame:
 J 657 c1 jdk.internal.misc.Unsafe.getByte(J)B java.base@11.0.12 (7 bytes) @ 0x000001dd6cac79d6 [0x000001dd6cac79a0+0x0000000000000036]



Any help is appreciated !


-
Révision 18091 : Lorsuq’un formulaire ajax ajoute une action en queue, elle n’est pas declenchée ...
17 juin 2011, par cedric -Particulièrement critique si le site a peu de traffic. On procède donc à un appel du pipeline affichage_final, sur un texte vide, avec une globale html=false pour empecher toute tentative d’affichage, ce qui permet neanmoins de declencher des actions du type cron (...)
-
ffmpeg works fine most of the time in java except for this command (merging), and this command works fine directly in terminal
14 mai 2014, par Ron IWhen I run this from the command line it works (merges two videos side by side) :
/usr/local/bin/ffmpeg -i /Users/ron/Dropbox/JAMR/Technology/workspace/JAMR/sandbox/test.mov -i /Users/ron/Dropbox/JAMR/Technology/workspace/JAMR/sandbox/test1.mov -filter_complex "[0:v:0]pad=iw*2:ih[bg]; [bg][1:v:0]overlay=w" /Users/ron/Dropbox/JAMR/Technology/workspace/JAMR/sandbox/merged.mov
However, when I run it in java, I get this from the console :
[AVFilterGraph @ 0x7fd44ad00440] No such filter: '"'
Error configuring filters.here is the text I am returning (copied directly) which is what I am sending to be executed. It is exactly the same, except I use the escape character before the quote symbol, so a " becomes \" :
"/usr/local/bin/ffmpeg -i /Users/ron/Dropbox/JAMR/Technology/workspace/JAMR/sandbox/test.mov -i /Users/ron/Dropbox/JAMR/Technology/workspace/JAMR/sandbox/test1.mov -filter_complex \"[0:v:0]pad=iw*2:ih[bg]; [bg][1:v:0]overlay=w\" /Users/ron/Dropbox/JAMR/Technology/workspace/JAMR/sandbox/merged.mov";
All other ffmpeg tests have worked except this.... (the only one where I use a " character)
Can anyone figure it out ?