Recherche avancée

Médias (2)

Mot : - Tags -/media

Autres articles (82)

  • 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 ; (...)

  • Configuration spécifique pour PHP5

    4 février 2011, par

    PHP5 est obligatoire, vous pouvez l’installer en suivant ce tutoriel spécifique.
    Il est recommandé dans un premier temps de désactiver le safe_mode, cependant, s’il est correctement configuré et que les binaires nécessaires sont accessibles, MediaSPIP devrait fonctionner correctement avec le safe_mode activé.
    Modules spécifiques
    Il est nécessaire d’installer certains modules PHP spécifiques, via le gestionnaire de paquet de votre distribution ou manuellement : php5-mysql pour la connectivité avec la (...)

Sur d’autres sites (5319)

  • FFmpeg - record from stream terminating unexpectedly using kokorin/Jaffree ffmpeg wrapper for Java

    18 avril 2024, par pyrmon

    I am programming a Spring Boot Application using Maven and Java 21. I am trying to record a stream from a url and save it to a mkv file. I intend to do this with kokorin/Jaffree in version 2023.09.10. The recording seems to work ok, however longer videos are terminating unexpectedly. Sometimes after 5 minutes, other times an hour or even longer. Sometimes with Exit Code 0 and sometimes with 1.

    


    I have implemented the recording like this :

    


    @Override
    public void startRecording(RecordingSchedule recordingSchedule) {
        logger.info("Starting recording for schedule with filename {}", recordingSchedule.getFileName());

        String m3uUrl = recordingSchedule.getM3uUrl();
        LocalDateTime endTime = timeUtils.parseStringToLocalDateTime(recordingSchedule.getEndTime());
        LocalDateTime stopTime = endTime.plusSeconds(20);
        String timeToRecord = timeUtils.calculateTimeToRecord(stopTime);
        Path outputPath = Paths.get("/recordings/" + recordingSchedule.getFileName());

        try {
            FFmpeg.atPath()
                  .addInput(UrlInput.fromUrl(m3uUrl))
                  .addArgument("-xerror")
                  .addArguments("-reconnect", "5")
                  .addArguments("-reconnect_streamed", "5")
                  .addArguments("-reconnect_delay_max", "20")
                  .addArguments("-t", timeToRecord)
                  .addArguments("-c", "copy")
                  .addOutput(
                      UrlOutput.toPath(outputPath))
                  .setLogLevel(LogLevel.WARNING)
                  .execute();
            logger.info("Recording complete. Output file: {}", outputPath.toAbsolutePath());
        } catch (Exception e) {
            logger.error("Error recording M3U stream {}: {}", recordingSchedule.getFileName(), e.getMessage());
        }
    }


    


    And I am calling the method like this :
executorConfig.executorService().submit(() -> ffmpegService.startRecording(recording));

    


    Any ideas what I am doing wrong ?
Here are the log lines at the beginning and end of recording of the past two attempts :

    


    2024-04-18T00:54:48.689+02:00  INFO 1 --- [pool-2-thread-1] m.s.r.service.impl.FfmpegServiceImpl     : Starting recording for schedule with filename Example1.mkv
2024-04-18T00:54:48.697+02:00  WARN 1 --- [pool-2-thread-1] c.github.kokorin.jaffree.ffmpeg.FFmpeg   : ProgressListener isn't set, progress won't be reported
2024-04-18T00:54:48.698+02:00  INFO 1 --- [pool-2-thread-1] c.g.k.jaffree.process.ProcessHandler     : Command constructed:
ffmpeg -loglevel level+warning -i http://example.stream.url.com -n -xerror -reconnect 5 -reconnect_streamed 5 -reconnect_delay_max 20 -t 10771 -c copy /recordings/Example1.mkv
2024-04-18T00:54:48.698+02:00  INFO 1 --- [pool-2-thread-1] c.g.k.jaffree.process.ProcessHandler     : Starting process: ffmpeg
2024-04-18T00:54:48.701+02:00  INFO 1 --- [pool-2-thread-1] c.g.k.jaffree.process.ProcessHandler     : Waiting for process to finish
2024-04-18T01:31:02.633+02:00  WARN 1 --- [         StdErr] c.g.k.jaffree.process.BaseStdReader      : [h264 @ 0x559cd22dd940] [warning] Increasing reorder buffer to 2
2024-04-18T01:31:02.633+02:00  INFO 1 --- [pool-2-thread-1] c.g.k.jaffree.process.ProcessHandler     : Process has finished with status: 0
2024-04-18T01:31:02.734+02:00  INFO 1 --- [pool-2-thread-1] m.s.r.service.impl.FfmpegServiceImpl     : Recording complete. Output file: /recordings/Example1.mkv

2024-04-18T03:54:48.678+02:00  INFO 1 --- [pool-2-thread-2] m.s.r.service.impl.FfmpegServiceImpl     : Starting recording for schedule with filename Example2.mkv
2024-04-18T03:54:48.678+02:00  WARN 1 --- [pool-2-thread-2] c.github.kokorin.jaffree.ffmpeg.FFmpeg   : ProgressListener isn't set, progress won't be reported
2024-04-18T03:54:48.678+02:00  INFO 1 --- [pool-2-thread-2] c.g.k.jaffree.process.ProcessHandler     : Command constructed:
ffmpeg -loglevel level+warning -i http://example.stream.url.com/ -n -xerror -reconnect 5 -reconnect_streamed 5 -reconnect_delay_max 20 -t 11431 -c copy /recordings/Example2.mkv
2024-04-18T03:54:48.678+02:00  INFO 1 --- [pool-2-thread-2] c.g.k.jaffree.process.ProcessHandler     : Starting process: ffmpeg
2024-04-18T03:54:48.679+02:00  INFO 1 --- [pool-2-thread-2] c.g.k.jaffree.process.ProcessHandler     : Waiting for process to finish
2024-04-18T04:57:22.256+02:00  WARN 1 --- [         StdErr] c.g.k.jaffree.process.BaseStdReader      : [h264 @ 0x55707ba988c0] [warning] Increasing reorder buffer to 3
2024-04-18T04:58:47.455+02:00 ERROR 1 --- [         StdErr] c.g.k.jaffree.process.BaseStdReader      : [NULL @ 0x55707ba988c0] [error] Picture timing SEI payload too large
2024-04-18T04:58:47.456+02:00 ERROR 1 --- [         StdErr] c.g.k.jaffree.process.BaseStdReader      : [NULL @ 0x55707ba988c0] [error] non-existing PPS 1 referenced
2024-04-18T04:58:47.456+02:00  WARN 1 --- [         StdErr] c.g.k.jaffree.process.BaseStdReader      : [matroska @ 0x55707ba9a380] [warning] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
2024-04-18T04:58:47.456+02:00 ERROR 1 --- [         StdErr] c.g.k.jaffree.process.BaseStdReader      : [matroska @ 0x55707ba9a380] [error] Can't write packet with unknown timestamp
2024-04-18T04:58:47.463+02:00 ERROR 1 --- [         StdErr] c.g.k.jaffree.process.BaseStdReader      : [error] av_interleaved_write_frame(): Invalid argument
2024-04-18T04:58:47.463+02:00  INFO 1 --- [pool-2-thread-2] c.g.k.jaffree.process.ProcessHandler     : Process has finished with status: 1
2024-04-18T04:58:47.564+02:00 ERROR 1 --- [pool-2-thread-2] m.s.r.service.impl.FfmpegServiceImpl     : Error recording M3U stream Example2.mkv: Process execution has ended with non-zero status: 1. Check logs for detailed error message.


    


    They were supposed to run nearly 3 hours and the other one over 3 hours. And with the timestamps you can see that they are not running nearly as long.
Thank you for your help !

    


  • FFMPEG - copy the SPECIFED tracks only, ignore all others

    10 janvier 2024, par GDP

    I have some very strange MP4 files that we get regularly for processing created by Wowza. Neither FFMPEG or MEDIAINFO can detect that there are subtitles soft-coded in them, but they ARE there, I can extract them with ccextractor, and when they're played, the captions appear later in the video where the actually start in the timeline.

    


    I've tried every variation of copying with/without re-encoding, but all the answers show how to "omit" the subtitles with -sn such as these :

    


     ffmpeg -i 3078.mp4 -c copy -sn 3078_sn.mp4
 ffmpeg -i 3078.mp4 -c:v libx264 -c:a ac3 -map 0:v:0 -map 0:a:1 3078_sn.mp4
 ffmpeg -i 3078.mp4 -map 0:v:0 -map 0:a:0  -map -0:s -map -0:d  -c copy 3078_sn2.mp4 -y


    


    FFprobe :

    


    ffprobe 3078.mp4 -hide_banner
[mov,mp4,m4a,3gp,3g2,mj2 @ 000001ef2bcd9e00] multiple fourcc not supported
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '3078.mp4':
  Metadata:
    major_brand     : f4v
    minor_version   : 0
    compatible_brands: isommp42m4v
    creation_time   : 2024-01-09T19:59:28.000000Z
  Duration: 02:17:18.47, start: 0.000000, bitrate: 2165 kb/s
  Stream #0:0[0x1](eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 1902 kb/s, 29.96 fps, 29.97 tbr, 90k tbn (default)
    Metadata:
     creation_time   : 2024-01-09T19:59:28.000000Z
     handler_name    : WowzaStreamingEngine
     vendor_id       : [0][0][0][0]
     encoder         : WowzaStreamingEngine
  Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 257 kb/s (default)
    Metadata:
     creation_time   : 2024-01-09T19:59:28.000000Z
     handler_name    : WowzaStreamingEngine
     vendor_id       : [0][0][0][0]
  Stream #0:2[0x3](eng): Data: none (amf0 / 0x30666D61), 1 kb/s (default)
    Metadata:
     creation_time   : 2024-01-09T19:59:28.000000Z
     handler_name    : WowzaStreamingEngine
Unsupported codec with id 0 for input stream 2


    


    The problem seems to be that FFMPEG isn't detecting they're there, and so copies them anyways. My assumption is that they're not stored in the header of the MP4 properly (or however that's done), so get because they're later detect, but weren't omitted when it checked the header (pure guesswork on that).

    


    So, is there a way to copy ONLY the video, regardless of whatEVER tracks may or not be in the file, then do the same for audio, and then merge the two single-track files ?

    


  • Decode multiple video on GPU (FFmpeg.autogen + C#)

    5 décembre 2024, par Sang Nguyen

    I'm trying to use the basic example about decoding video (FFmpeg.AutoGen.Example) in the FFmpeg.autogen 4.3.0.3 library https://github.com/Ruslan-B/FFmpeg.AutoGen to decode multiple videos on a GPU (AMD radeon R7 430). My main function is as follows :

    


     private static void Main(string[] args)
        {
            var url = @".\abc.mp4";
            for (int i = 0; i < 11; i++)
            {
                url = @"D:\video\abc" + i + ".mp4";
                new Thread(() =>
                {
                    DecodeAllFramesToImages(AVHWDeviceType.AV_HWDEVICE_TYPE_D3D11VA, url);
                }).Start();
            }
        }


    


    I try to decode video abc.mp4 with GPU Hardware Acceleration. However, an error occurs when i run thread count greater than 10. The error images is as follows :

    


      

    • "System.AccessViolationException : Attempted to read or write protected memory. This is often an indication that other memory." enter image description here
    • 


    • And in the console screen there is an error message "Failed to create D3D11VA video decoder" and "Failed setup for format d3d11 : hwaccel innitialisation returned error"
enter image description here.
    • 


    


    I'm new to the ffmpeg library recently, so I don't know the problem very well, I would love to have your help with this error !!

    


    private static unsafe void DecodeAllFramesToImages(AVHWDeviceType HWDevice, string url)
        {             
            using (var vsd = new VideoStreamDecoder(url,HWDevice))
            {
                Console.WriteLine($"codec name: {vsd.CodecName}");

                var info = vsd.GetContextInfo();
                info.ToList().ForEach(x => Console.WriteLine($"{x.Key} = {x.Value}"));

                var sourceSize = vsd.FrameSize;
                var sourcePixelFormat = HWDevice == AVHWDeviceType.AV_HWDEVICE_TYPE_NONE ? vsd.PixelFormat : GetHWPixelFormat(HWDevice);
                var destinationSize = sourceSize;
                var destinationPixelFormat = AVPixelFormat.AV_PIX_FMT_YUV420P;
                using (var vfc = new VideoFrameConverter(sourceSize, sourcePixelFormat, destinationSize, destinationPixelFormat))
                {
                    var frameNumber = 0;
                    while (vsd.TryDecodeNextFrame(out var frame))
                    {
                       //var convertedFrame = vfc.Convert(frame);                        
                       // using (var bitmap = new Bitmap(convertedFrame.width, convertedFrame.height, convertedFrame.linesize[0], PixelFormat.Format24bppRgb, (IntPtr) convertedFrame.data[0]))
                       // bitmap.Save($"frame.{frameNumber:D8}.jpg", ImageFormat.Jpeg);
                        
                        Console.WriteLine($"frame: {frameNumber}");
                        frameNumber++;
                    }
                }
            }
        }


    


    using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Runtime.InteropServices;

namespace FFmpeg.AutoGen.Example
{
    public sealed unsafe class VideoStreamDecoder : IDisposable
    {
        private readonly AVCodecContext* _pCodecContext;
        private readonly AVFormatContext* _pFormatContext;
        private readonly int _streamIndex;
        private readonly AVFrame* _pFrame;
        private readonly AVFrame* _receivedFrame;
        private readonly AVPacket* _pPacket;

        public VideoStreamDecoder(string url, AVHWDeviceType HWDeviceType = AVHWDeviceType.AV_HWDEVICE_TYPE_NONE)
        {
            _pFormatContext = ffmpeg.avformat_alloc_context();
            _receivedFrame = ffmpeg.av_frame_alloc();
            var pFormatContext = _pFormatContext;
            ffmpeg.avformat_open_input(&pFormatContext, url, null, null).ThrowExceptionIfError();
            ffmpeg.avformat_find_stream_info(_pFormatContext, null).ThrowExceptionIfError();
            AVCodec* codec = null;
            _streamIndex = ffmpeg.av_find_best_stream(_pFormatContext, AVMediaType.AVMEDIA_TYPE_VIDEO, -1, -1, &codec, 0).ThrowExceptionIfError();
            _pCodecContext = ffmpeg.avcodec_alloc_context3(codec);
            if (HWDeviceType != AVHWDeviceType.AV_HWDEVICE_TYPE_NONE)
            {
                ffmpeg.av_hwdevice_ctx_create(&_pCodecContext->hw_device_ctx, HWDeviceType, null, null, 0).ThrowExceptionIfError();
            }
            ffmpeg.avcodec_parameters_to_context(_pCodecContext, _pFormatContext->streams[_streamIndex]->codecpar).ThrowExceptionIfError();
            ffmpeg.avcodec_open2(_pCodecContext, codec, null).ThrowExceptionIfError();            
            CodecName = ffmpeg.avcodec_get_name(codec->id);
            FrameSize = new Size(_pCodecContext->width, _pCodecContext->height);
            PixelFormat = _pCodecContext->pix_fmt;
            _pPacket = ffmpeg.av_packet_alloc();
            _pFrame = ffmpeg.av_frame_alloc();
        }

        public string CodecName { get; }
        public Size FrameSize { get; }
        public AVPixelFormat PixelFormat { get; }

        public void Dispose()
        {
            ffmpeg.av_frame_unref(_pFrame);
            ffmpeg.av_free(_pFrame);

            ffmpeg.av_packet_unref(_pPacket);
            ffmpeg.av_free(_pPacket);

            ffmpeg.avcodec_close(_pCodecContext);
            var pFormatContext = _pFormatContext;
            ffmpeg.avformat_close_input(&pFormatContext);
        }

        public bool TryDecodeNextFrame(out AVFrame frame)
        {
            ffmpeg.av_frame_unref(_pFrame);
            ffmpeg.av_frame_unref(_receivedFrame);
            int error;
            do
            {
                try
                {
                    do
                    {
                        error = ffmpeg.av_read_frame(_pFormatContext, _pPacket);
                        if (error == ffmpeg.AVERROR_EOF)
                        {
                            frame = *_pFrame;
                            return false;
                        }

                        error.ThrowExceptionIfError();
                    } while (_pPacket->stream_index != _streamIndex);

                    ffmpeg.avcodec_send_packet(_pCodecContext, _pPacket).ThrowExceptionIfError();
                }
                finally
                {
                    ffmpeg.av_packet_unref(_pPacket);
                }

                error = ffmpeg.avcodec_receive_frame(_pCodecContext, _pFrame);
            } while (error == ffmpeg.AVERROR(ffmpeg.EAGAIN));
            error.ThrowExceptionIfError();
            if (_pCodecContext->hw_device_ctx != null)
            {
                ffmpeg.av_hwframe_transfer_data(_receivedFrame, _pFrame, 0).ThrowExceptionIfError();
                frame = *_receivedFrame;
            }
            else
            {
                frame = *_pFrame;
            }
            return true;
        }
        public IReadOnlyDictionary GetContextInfo()
        {
            AVDictionaryEntry* tag = null;
            var result = new Dictionary();
            while ((tag = ffmpeg.av_dict_get(_pFormatContext->metadata, "", tag, ffmpeg.AV_DICT_IGNORE_SUFFIX)) != null)
            {
                var key = Marshal.PtrToStringAnsi((IntPtr) tag->key);
                var value = Marshal.PtrToStringAnsi((IntPtr) tag->value);
                result.Add(key, value);
            }
            return result;
        }
    }
}