Recherche avancée

Médias (1)

Mot : - Tags -/artwork

Autres articles (94)

  • Amélioration de la version de base

    13 septembre 2013

    Jolie sélection multiple
    Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
    Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...)

  • Menus personnalisés

    14 novembre 2010, par

    MediaSPIP utilise le plugin Menus pour gérer plusieurs menus configurables pour la navigation.
    Cela permet de laisser aux administrateurs de canaux la possibilité de configurer finement ces menus.
    Menus créés à l’initialisation du site
    Par défaut trois menus sont créés automatiquement à l’initialisation du site : Le menu principal ; Identifiant : barrenav ; Ce menu s’insère en général en haut de la page après le bloc d’entête, son identifiant le rend compatible avec les squelettes basés sur Zpip ; (...)

  • Soumettre bugs et patchs

    10 avril 2011

    Un logiciel n’est malheureusement jamais parfait...
    Si vous pensez avoir mis la main sur un bug, reportez le dans notre système de tickets en prenant bien soin de nous remonter certaines informations pertinentes : le type de navigateur et sa version exacte avec lequel vous avez l’anomalie ; une explication la plus précise possible du problème rencontré ; si possibles les étapes pour reproduire le problème ; un lien vers le site / la page en question ;
    Si vous pensez avoir résolu vous même le bug (...)

Sur d’autres sites (8566)

  • JAVA Spring : Grabbing Image from a multipartFile video via FFMPEG JavaCV

    29 août 2023, par Thanh Hiếu Nguyễn

    I'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 !

    


  • Process vide files to take screen grabs in java spring boot

    10 octobre 2023, par Haleema Khan

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

    &#xA;

  • 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 Christopher

    I 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.

    &#xA;

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

    &#xA;

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

    &#xA;

    JRE version : OpenJDK Runtime Environment Corretto-19.0.2.7.1 (19.0.2+7) (build 19.0.2+7-FR)&#xA;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)&#xA;Problematic frame :&#xA;C [libavutil.56.dylib+0xa0e0] av_strstart+0x10

    &#xA;

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

    &#xA;

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

    &#xA;

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

    &#xA;

    public static void main(String[] args) {&#xA;    OkHttpClient client = new OkHttpClient();&#xA;    try (S3Client s3Client = S3Client.create()) {&#xA;        VideoService videoService = new VideoService(new VideoRepositoryImpl(),&#xA;                new S3Service(s3Client), new VideoExtractor(client), new ISApiClient());&#xA;        videoService.streamLiveVideoRSTP(System.out);&#xA;    } catch (IOException e) {&#xA;        log.error("Error occurred while streaming live video: {}", e.getMessage(), e);&#xA;    } catch (Exception e) {&#xA;        log.error("Unexpected error occurred: {}", e.getMessage(), e);&#xA;    }&#xA;}&#xA;&#xA;public void streamLiveVideoRSTP(OutputStream outputStream) throws IOException {&#xA;    File tempFile = File.createTempFile("live_stream", ".mp4");&#xA;&#xA;    try (InputStream inputStream = client.getLiveStreamingVideoRSTP();&#xA;         OutputStream fileOutputStream = new FileOutputStream(tempFile)) {&#xA;        byte[] buffer = new byte[4096];&#xA;        int bytesRead;&#xA;        while ((bytesRead = inputStream.read(buffer)) != -1) {&#xA;            outputStream.write(buffer, 0, bytesRead);&#xA;            fileOutputStream.write(buffer, 0, bytesRead);&#xA;        }&#xA;    } catch (Exception e) {&#xA;        log.error("Error occurred while streaming live video: {}", e.getMessage(), e);&#xA;        throw new IOException("Error occurred while streaming live video", e);&#xA;    }&#xA;&#xA;    // Upload the captured video file to S3&#xA;    try {&#xA;        uploadStreamedVideoToS3(tempFile);&#xA;    } finally {&#xA;        if (tempFile.exists()) {&#xA;            if (!tempFile.delete()) {&#xA;                log.warn("Failed to delete temporary file: {}", tempFile.getAbsolutePath());&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;private final BlockingQueue frameQueue = new ArrayBlockingQueue&lt;>(10);&#xA;&#xA;public ISApiClient() {&#xA;    new Thread(this::startGrabbingFrames).start();&#xA;}&#xA;&#xA;public InputStream getLiveStreamingVideoRSTP() {&#xA;    return new InputStream() {&#xA;        private ByteArrayInputStream currentStream;&#xA;&#xA;        @Override&#xA;        public int read() {&#xA;            if (currentStream == null || currentStream.available() == 0) {&#xA;                byte[] frame = frameQueue.poll();&#xA;                if (frame != null) {&#xA;                    currentStream = new ByteArrayInputStream(frame);&#xA;                } else {&#xA;                    return -1;&#xA;                }&#xA;            }&#xA;            return currentStream.read();&#xA;        }&#xA;    };&#xA;}&#xA;&#xA;private void startGrabbingFrames() {&#xA;    try (FFmpegFrameGrabber frameGrabber = new FFmpegFrameGrabber(rtspUrl)) {&#xA;        frameGrabber.setOption("rtsp_transport", "tcp");&#xA;        frameGrabber.start();&#xA;&#xA;        FFmpegFrameFilter frameFilter = new FFmpegFrameFilter("format=yuv420p",&#xA;                frameGrabber.getImageWidth(), frameGrabber.getImageHeight());&#xA;        frameFilter.setPixelFormat(frameGrabber.getPixelFormat());&#xA;        frameFilter.start();&#xA;&#xA;        log.info("Started grabbing frames from RTSP stream.");&#xA;&#xA;        while (true) {&#xA;            Frame frame = frameGrabber.grab();&#xA;            if (frame != null &amp;&amp; frame.image != null) {&#xA;                log.info("Frame grabbed: width={} height={} timestamp={}",&#xA;                        frame.imageWidth, frame.imageHeight, frame.timestamp);&#xA;                frameFilter.push(frame);&#xA;                Frame filteredFrame = frameFilter.pull();&#xA;&#xA;                if (filteredFrame != null &amp;&amp; filteredFrame.image != null) {&#xA;                    log.info("Frame filtered: width={} height={} timestamp={}",&#xA;                            filteredFrame.imageWidth, filteredFrame.imageHeight, filteredFrame.timestamp);&#xA;                    byte[] imageBytes = convertFrameToBytes(filteredFrame);&#xA;                    if (imageBytes.length > 0) {&#xA;                        frameQueue.offer(imageBytes);&#xA;                        log.info("Frame added to queue, queue size={}", frameQueue.size());&#xA;                    }&#xA;                }&#xA;            }&#xA;        }&#xA;    } catch (IOException e) {&#xA;        log.error("Error grabbing frames: {}", e.getMessage(), e);&#xA;    }&#xA;}&#xA;&#xA;private byte[] convertFrameToBytes(Frame frame) {&#xA;    if (frame == null || frame.image == null) {&#xA;        return new byte[0];&#xA;    }&#xA;&#xA;    ByteBuffer byteBuffer = null;&#xA;    for (Object img : frame.image) {&#xA;        if (img instanceof ByteBuffer) {&#xA;            byteBuffer = (ByteBuffer) img;&#xA;            break;&#xA;        }&#xA;    }&#xA;&#xA;    if (byteBuffer == null) {&#xA;        return new byte[0];&#xA;    }&#xA;&#xA;    byte[] bytes = new byte[byteBuffer.remaining()];&#xA;    byteBuffer.get(bytes);&#xA;    return bytes;&#xA;}&#xA;

    &#xA;