
Recherche avancée
Autres articles (53)
-
La sauvegarde automatique de canaux SPIP
1er avril 2010, parDans le cadre de la mise en place d’une plateforme ouverte, il est important pour les hébergeurs de pouvoir disposer de sauvegardes assez régulières pour parer à tout problème éventuel.
Pour réaliser cette tâche on se base sur deux plugins SPIP : Saveauto qui permet une sauvegarde régulière de la base de donnée sous la forme d’un dump mysql (utilisable dans phpmyadmin) mes_fichiers_2 qui permet de réaliser une archive au format zip des données importantes du site (les documents, les éléments (...) -
(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 (...) -
Publier sur MédiaSpip
13 juin 2013Puis-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
Sur d’autres sites (10574)
-
Process vide files to take screen grabs in java spring boot
10 octobre 2023, par Haleema KhanI am using JavaCV library with ffmpeg bindings to process video files and taking screen grabs at specific frames.
Adding JavaCV library dependency to my spring project increases the size of my jar file from around 90Mb > 1+ Gb.
This is a big issue becuase my project is deployed on AWS elastic beanstalk that accepts a max size of 500 Mb for a jar file.


Need help to resolve this issue with the jar file or else any other alternate library that could do this.


What I tried : I have removed all accept the abosultely necessary dependencies in my project to reduce the jar size.
I have also tried to find alternate solutions but couldnt get anything.
My pom file looks like


<dependencies>
 
 <dependency>
 <groupid>org.springframework.boot</groupid>
 <artifactid>spring-boot-starter-data-jpa</artifactid>
 </dependency>
 <dependency>
 <groupid>com.google.oauth-client</groupid>
 <artifactid>google-oauth-client</artifactid>
 <version>1.32.1</version>
 </dependency>
 <dependency>
 <groupid>com.google.http-client</groupid>
 <artifactid>google-http-client</artifactid>
 <version>1.32.1</version>
 </dependency>
 
 <dependency>
 <groupid>org.springframework.boot</groupid>
 <artifactid>spring-boot-starter-oauth2-client</artifactid>
 </dependency>
 <dependency>
 <groupid>org.springframework.boot</groupid>
 <artifactid>spring-boot-starter-web</artifactid>
 </dependency>
 <dependency>
 <groupid>org.springframework.boot</groupid>
 <artifactid>spring-boot-starter-test</artifactid>
 <scope>test</scope>
 </dependency>
 
 <dependency>
 <groupid>org.bytedeco</groupid>
 <artifactid>javacv</artifactid>
 <version>1.5.9</version>
 </dependency>
 <dependency>
 <groupid>org.springframework.boot</groupid>
 <artifactid>spring-boot-starter-validation</artifactid>
 </dependency>
 <dependency>
 <groupid>org.apache.commons</groupid>
 <artifactid>commons-csv</artifactid>
 <version>1.10.0</version>
 </dependency>
 <dependency>
 <groupid>io.jsonwebtoken</groupid>
 <artifactid>jjwt</artifactid>
 <version>0.9.1</version>
 </dependency>
 
 <dependency>
 <groupid>mysql</groupid>
 <artifactid>mysql-connector-java</artifactid>
 </dependency>
 <dependency>
 <groupid>org.springframework.boot</groupid>
 <artifactid>spring-boot-devtools</artifactid>
 </dependency>
 <dependency>
 <groupid>org.projectlombok</groupid>
 <artifactid>lombok</artifactid>
 </dependency>
 <dependency>
 <groupid>org.springframework.boot</groupid>
 <artifactid>spring-boot-configuration-processor</artifactid>
 <optional>true</optional>
 </dependency>
 <dependency>
 <groupid>com.amazonaws</groupid>
 <artifactid>aws-java-sdk-s3</artifactid>
 <version>1.12.550</version>
 </dependency>
 
 <dependency>
 <groupid>commons-io</groupid>
 <artifactid>commons-io</artifactid>
 <version>2.6</version>
 </dependency>
 
 
 
 <dependency>
 <groupid>com.github.ozlerhakan</groupid>
 <artifactid>poiji</artifactid>
 <version>3.0.3</version>
 </dependency>
 <dependency>
 <groupid>org.springframework.cloud</groupid>
 <artifactid>spring-cloud-starter-aws</artifactid>
 <version>2.2.6.RELEASE</version>
 </dependency>
 <dependency>
 <groupid>org.springframework.cloud</groupid>
 <artifactid>spring-cloud-starter-aws-messaging</artifactid>
 <version>2.2.6.RELEASE</version>
 </dependency>
 </dependencies>```



-
why am i getting this error when using FFmpeg in a spring boot app on a mac intel device : SIGSEGV (0xb) at pc=0x000000013d71b0e0, pid=49777, tid=42755
19 juillet 2024, par Godwill ChristopherI am working with FFmpeg library in spring boot app to stream live recording from an ip camera via RSTP and save to S3 bucket but i am running into the error below.


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


SIGSEGV (0xb) at pc=0x000000013d71b0e0, pid=49777, tid=42755


JRE version : OpenJDK Runtime Environment Corretto-19.0.2.7.1 (19.0.2+7) (build 19.0.2+7-FR)
Java VM : OpenJDK 64-Bit Server VM Corretto-19.0.2.7.1 (19.0.2+7-FR, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, bsd-amd64)
Problematic frame :
C [libavutil.56.dylib+0xa0e0] av_strstart+0x10


No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
An error report file with more information is saved as :
/Users/CODA/Desktop/videoSaleService/hs_err_pid49777.log


If you would like to submit a bug report, please visit :
https://github.com/corretto/corretto-19/issues/
The crash happened outside the Java Virtual Machine in native code.
See problematic frame for where to report the bug.


Process finished with exit code 134 (interrupted by signal 6:SIGABRT)


public static void main(String[] args) {
 OkHttpClient client = new OkHttpClient();
 try (S3Client s3Client = S3Client.create()) {
 VideoService videoService = new VideoService(new VideoRepositoryImpl(),
 new S3Service(s3Client), new VideoExtractor(client), new ISApiClient());
 videoService.streamLiveVideoRSTP(System.out);
 } catch (IOException e) {
 log.error("Error occurred while streaming live video: {}", e.getMessage(), e);
 } catch (Exception e) {
 log.error("Unexpected error occurred: {}", e.getMessage(), e);
 }
}

public void streamLiveVideoRSTP(OutputStream outputStream) throws IOException {
 File tempFile = File.createTempFile("live_stream", ".mp4");

 try (InputStream inputStream = client.getLiveStreamingVideoRSTP();
 OutputStream fileOutputStream = new FileOutputStream(tempFile)) {
 byte[] buffer = new byte[4096];
 int bytesRead;
 while ((bytesRead = inputStream.read(buffer)) != -1) {
 outputStream.write(buffer, 0, bytesRead);
 fileOutputStream.write(buffer, 0, bytesRead);
 }
 } catch (Exception e) {
 log.error("Error occurred while streaming live video: {}", e.getMessage(), e);
 throw new IOException("Error occurred while streaming live video", e);
 }

 // Upload the captured video file to S3
 try {
 uploadStreamedVideoToS3(tempFile);
 } finally {
 if (tempFile.exists()) {
 if (!tempFile.delete()) {
 log.warn("Failed to delete temporary file: {}", tempFile.getAbsolutePath());
 }
 }
 }
}

private final BlockingQueue frameQueue = new ArrayBlockingQueue<>(10);

public ISApiClient() {
 new Thread(this::startGrabbingFrames).start();
}

public InputStream getLiveStreamingVideoRSTP() {
 return new InputStream() {
 private ByteArrayInputStream currentStream;

 @Override
 public int read() {
 if (currentStream == null || currentStream.available() == 0) {
 byte[] frame = frameQueue.poll();
 if (frame != null) {
 currentStream = new ByteArrayInputStream(frame);
 } else {
 return -1;
 }
 }
 return currentStream.read();
 }
 };
}

private void startGrabbingFrames() {
 try (FFmpegFrameGrabber frameGrabber = new FFmpegFrameGrabber(rtspUrl)) {
 frameGrabber.setOption("rtsp_transport", "tcp");
 frameGrabber.start();

 FFmpegFrameFilter frameFilter = new FFmpegFrameFilter("format=yuv420p",
 frameGrabber.getImageWidth(), frameGrabber.getImageHeight());
 frameFilter.setPixelFormat(frameGrabber.getPixelFormat());
 frameFilter.start();

 log.info("Started grabbing frames from RTSP stream.");

 while (true) {
 Frame frame = frameGrabber.grab();
 if (frame != null && frame.image != null) {
 log.info("Frame grabbed: width={} height={} timestamp={}",
 frame.imageWidth, frame.imageHeight, frame.timestamp);
 frameFilter.push(frame);
 Frame filteredFrame = frameFilter.pull();

 if (filteredFrame != null && filteredFrame.image != null) {
 log.info("Frame filtered: width={} height={} timestamp={}",
 filteredFrame.imageWidth, filteredFrame.imageHeight, filteredFrame.timestamp);
 byte[] imageBytes = convertFrameToBytes(filteredFrame);
 if (imageBytes.length > 0) {
 frameQueue.offer(imageBytes);
 log.info("Frame added to queue, queue size={}", frameQueue.size());
 }
 }
 }
 }
 } catch (IOException e) {
 log.error("Error grabbing frames: {}", e.getMessage(), e);
 }
}

private byte[] convertFrameToBytes(Frame frame) {
 if (frame == null || frame.image == null) {
 return new byte[0];
 }

 ByteBuffer byteBuffer = null;
 for (Object img : frame.image) {
 if (img instanceof ByteBuffer) {
 byteBuffer = (ByteBuffer) img;
 break;
 }
 }

 if (byteBuffer == null) {
 return new byte[0];
 }

 byte[] bytes = new byte[byteBuffer.remaining()];
 byteBuffer.get(bytes);
 return bytes;
}



-
I want to use FFmpeg in the spring boot
12 novembre 2024, par user25686647While creating the function to concatenate audio files with the Java Sound API, I found FFmpeg, which has already implemented the function beautifully with the library.
I want to make it possible to automatically install ffmpeg if I build it in the spring boot, and make it available in the spring boot.
But somehow it's installing, but I can't seem to read the route. I've been thinking about it for hours, but I can't figure out where the problem is. I need help


I tried both the absolute path and the relative path


package com.oreo.finalproject_5re5_be.audio;
import org.junit.jupiter.api.Test;
import java.io.*;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.Map;
import java.util.zip.ZipInputStream;

public class FFmpegBuildTest {
 @Test
 public void setFFmpeg() {
 String os = System.getProperty("os.name").toLowerCase();
 System.out.println("os = " + os);

 try {
 installFFmpeg();
 } catch (IOException e) {
 e.printStackTrace();
 }

 try {
 String ffmpegPath;
 if (os.contains("win")) {
 ffmpegPath = "C:/Users/user/Desktop/oreo/FinalProject_5RE5_BE/ffmpeg/ffmpeg-7.1-essentials_build/bin"; // Windows
 } else if (os.contains("mac")) {
 ffmpegPath = "ffmpeg/ffmpeg"; // Mac
 } else if (os.contains("nix") || os.contains("nux")) {
 ffmpegPath = "ffmpeg/ffmpeg"; // Linux
 } else {
 throw new UnsupportedOperationException("Unsupported OS: " + os);
 }

 ProcessBuilder processBuilder = new ProcessBuilder(ffmpegPath, "-version");
 Process process = processBuilder.start();

 BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
 String line;
 StringBuilder output = new StringBuilder();
 while ((line = reader.readLine()) != null) {
 output.append(line).append("\n");
 }

 int exitCode = process.waitFor();
 if (exitCode == 0) {
 System.out.println("FFmpeg is installed. Version info:");
 System.out.println(output);
 } else {
 System.out.println("FFmpeg is not installed or not found in PATH.");
 }
 } catch (IOException | InterruptedException e) {
 System.out.println("FFmpeg is not installed or not found in PATH.");
 }
 }

 public static void installFFmpeg() throws IOException {
 String downloadUrl;
 String ffmpegPath;

 String os = System.getProperty("os.name").toLowerCase();
 if (os.contains("win")) {
 downloadUrl = "https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip";
 ffmpegPath = "ffmpeg/bin/ffmpeg.exe";
 } else if (os.contains("mac")) {
 downloadUrl = "https://www.osxexperts.net/ffmpeg71arm.zip";
 ffmpegPath = "ffmpeg/ffmpeg";
 } else if (os.contains("nix") || os.contains("nux")) {
 downloadUrl = "https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-i686-static.tar.xz";
 ffmpegPath = "ffmpeg/ffmpeg";
 } else {
 throw new UnsupportedOperationException("Unsupported OS: " + os);
 }

 System.out.println("Downloading FFmpeg from " + downloadUrl);
 try (InputStream in = new URL(downloadUrl).openStream()) {
 Files.copy(in, Paths.get("ffmpeg_download.zip"), StandardCopyOption.REPLACE_EXISTING);
 }

 System.out.println("Extracting FFmpeg...");
 if (os.contains("win") || os.contains("mac")) {
 unzip("ffmpeg_download.zip", "ffmpeg");
 } else {
 untar("ffmpeg_download.tar.xz", "ffmpeg");
 }

 File ffmpegFile = new File(ffmpegPath);
 if (ffmpegFile.exists()) {
 System.out.println("FFmpeg installed successfully at " + ffmpegFile.getAbsolutePath());
 
 addFFmpegToPath(ffmpegFile.getParent());
 } else {
 System.out.println("Failed to install FFmpeg. Please check the download and extraction.");
 }
 }

 private static void addFFmpegToPath(String ffmpegDir) {
 Map env = System.getenv();
 String path = env.get("PATH");
 path = ffmpegDir + File.pathSeparator + path;
 System.setProperty("java.library.path", path);
 System.out.println("FFmpeg path added to PATH environment variable.");
 }

 private static void unzip(String zipFilePath, String destDir) throws IOException {
 File dir = new File(destDir);
 if (!dir.exists()) dir.mkdirs();

 byte[] buffer = new byte[1024];
 try (ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFilePath))) {
 var zipEntry = zis.getNextEntry();
 while (zipEntry != null) {
 if (zipEntry.getName().startsWith("__MACOSX") || zipEntry.isDirectory()) {
 zipEntry = zis.getNextEntry();
 continue;
 }
 File newFile = new File(destDir, zipEntry.getName());
 if (zipEntry.isDirectory()) {
 newFile.mkdirs();
 } else {
 File parent = newFile.getParentFile();
 if (!parent.exists()) parent.mkdirs();
 try (FileOutputStream fos = new FileOutputStream(newFile)) {
 int len;
 while ((len = zis.read(buffer)) > 0) {
 fos.write(buffer, 0, len);
 }
 }
 }
 zipEntry = zis.getNextEntry();
 }
 zis.closeEntry();
 }
 }
 
 private static void untar(String tarFilePath, String destDir) throws IOException {
 
 ProcessBuilder pb = new ProcessBuilder("tar", "-xJf", tarFilePath, "-C", destDir);
 Process process = pb.start();
 try {
 int exitCode = process.waitFor();
 if (exitCode != 0) {
 throw new IOException("Failed to extract tar.xz file. Exit code: " + exitCode);
 }
 } catch (InterruptedException e) {
 Thread.currentThread().interrupt();
 throw new IOException("Interrupted during tar extraction", e);
 }
 }
}