
Recherche avancée
Autres articles (37)
-
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 (...) -
Script d’installation automatique de MediaSPIP
25 avril 2011, parAfin de palier aux difficultés d’installation dues principalement aux dépendances logicielles coté serveur, un script d’installation "tout en un" en bash a été créé afin de faciliter cette étape sur un serveur doté d’une distribution Linux compatible.
Vous devez bénéficier d’un accès SSH à votre serveur et d’un compte "root" afin de l’utiliser, ce qui permettra d’installer les dépendances. Contactez votre hébergeur si vous ne disposez pas de cela.
La documentation de l’utilisation du script d’installation (...) -
Utilisation et configuration du script
19 janvier 2011, parInformations spécifiques à la distribution Debian
Si vous utilisez cette distribution, vous devrez activer les dépôts "debian-multimedia" comme expliqué ici :
Depuis la version 0.3.1 du script, le dépôt peut être automatiquement activé à la suite d’une question.
Récupération du script
Le script d’installation peut être récupéré de deux manières différentes.
Via svn en utilisant la commande pour récupérer le code source à jour :
svn co (...)
Sur d’autres sites (5472)
-
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);
 }
 }
}






-
Revision 37457 : en étant moins verbeux c’est mieux
20 avril 2010, par kent1@… — Logen étant moins verbeux c’est mieux