Recherche avancée

Médias (0)

Mot : - Tags -/content

Aucun média correspondant à vos critères n’est disponible sur le site.

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

  • Les sons

    15 mai 2013, par
  • Gestion de la ferme

    2 mars 2010, par

    La ferme est gérée dans son ensemble par des "super admins".
    Certains réglages peuvent être fais afin de réguler les besoins des différents canaux.
    Dans un premier temps il utilise le plugin "Gestion de mutualisation"

Sur d’autres sites (5986)

  • C# server problem with FFmpeg Visual Studio 2022

    16 mai 2024, par seanofdead

    Hello everyone I've spent countless hours on my server I'm trying to create that will share video from one stream to another client computer. That is the goal anyway. I'm using Visual Studio 2022 most recent update. Currently this is my code

    


    using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Threading.Tasks;
using FFmpeg.AutoGen;
using NLog;

public class VideoStreamServer
{
    private const int Port = 5000;
    private TcpListener server;
    private FFmpegVideoEncoder encoder;
    private static readonly Logger logger = LogManager.GetCurrentClassLogger();

    public VideoStreamServer()
    {
        // Initialize FFmpeg network components
        Console.WriteLine("Initializing FFmpeg network components...");
        int result = ffmpeg.avformat_network_init();
        if (result != 0)
        {
            throw new ApplicationException($"Failed to initialize FFmpeg network components: {result}");
        }

        // Initialize encoder
        encoder = new FFmpegVideoEncoder(1920, 1080, AVCodecID.AV_CODEC_ID_H264); // Screen size & codec
    }

    public static void Main()
    {
        // Initialize NLog
        var logger = LogManager.GetCurrentClassLogger();
        logger.Info("Application started");

        var server = new VideoStreamServer();
        server.Start().Wait();
    }

    public async Task Start()
    {
        server = new TcpListener(IPAddress.Any, Port);
        server.Start();
        logger.Info($"Server started on port {Port}...");

        try
        {
            while (true)
            {
                TcpClient client = await server.AcceptTcpClientAsync();
                logger.Info("Client connected...");
                _ = HandleClientAsync(client);
            }
        }
        catch (Exception ex)
        {
            logger.Error(ex, "An error occurred");
        }
    }

    private async Task HandleClientAsync(TcpClient client)
    {
        using (client)
        using (NetworkStream netStream = client.GetStream())
        {
            try
            {
                await encoder.StreamEncodedVideoAsync(netStream);
            }
            catch (IOException ex)
            {
                logger.Error(ex, $"Network error: {ex.Message}");
                // Additional logging and recovery actions
            }
            catch (Exception ex)
            {
                logger.Error(ex, $"Unexpected error: {ex.Message}");
                // Log and handle other exceptions
            }
            finally
            {
                // Ensure all resources are cleaned up properly
                client.Close();
                logger.Info("Client connection closed properly.");
            }
        }
    }
}

public class FFmpegVideoEncoder
{
    private readonly int width;
    private readonly int height;
    private readonly AVCodecID codecId;
    private static readonly Logger logger = LogManager.GetCurrentClassLogger();

    public FFmpegVideoEncoder(int width, int height, AVCodecID codecId)
    {
        this.width = width;
        this.height = height;
        this.codecId = codecId;
        InitializeEncoder();
    }

    private void InitializeEncoder()
    {
        // Initialize FFmpeg encoder here
        logger.Debug("FFmpeg encoder initialized");
    }

    public async Task StreamEncodedVideoAsync(NetworkStream netStream)
    {
        // Initialize reusable buffers for efficiency
        byte[] buffer = new byte[4096];

        // Capture and encode video frames
        while (true)
        {
            try
            {
                // Simulate capture and encoding
                byte[] videoData = new byte[1024]; // This would come from the encoder

                // Simulate streaming
                for (int i = 0; i < videoData.Length; i += buffer.Length)
                {
                    int chunkSize = Math.Min(buffer.Length, videoData.Length - i);
                    Buffer.BlockCopy(videoData, i, buffer, 0, chunkSize);
                    await netStream.WriteAsync(buffer, 0, chunkSize);
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Error streaming video data");
                throw; // Rethrow to handle in the calling function
            }

            await Task.Delay(1000 / 30); // For 30 FPS
        }
    }
}


    


    When I build no issues but when i run it in debug mode I get this error

    


    System.DllNotFoundException
  HResult=0x80131524
  Message=Unable to load DLL 'avformat.59 under C:\Users\phlfo\Downloads\cfolder\server\ConsoleApp\bin\Debug\': The specified module could not be found.
  Source=FFmpeg.AutoGen
  StackTrace:
   at FFmpeg.AutoGen.ffmpeg.LoadLibrary(String libraryName, Boolean throwException)
   at FFmpeg.AutoGen.ffmpeg.<>c.<.cctor>b__7_0(String libraryName)
   at FFmpeg.AutoGen.ffmpeg.<>c.<.cctor>b__7_242()
   at FFmpeg.AutoGen.ffmpeg.avformat_network_init()
   at VideoStreamServer..ctor() in C:\Users\phlfo\Downloads\cfolder\server\ConsoleApp\Program.cs:line 20
   at VideoStreamServer.Main() in C:\Users\phlfo\Downloads\cfolder\server\ConsoleApp\Program.cs:line 36


    


    I have FFmpeg.AutoGen package installed through VS i originally started with 7.0 but then switched to 5.0 to see if an older version might work (it did not). I also have the files in the same directory as the .exe for testing purposes as seen in the screenshot. Can someone please help me figure out this error.
enter image description here

    


  • How to duplicate an audio file or trim it to a specific length in ffmpeg ?

    21 octobre 2023, par Руслан Лысенко

    I want to combine a video file (with audio) and an audio file together to get one output file.

    


    Most importantly, I need to do the following.

    


    If the length of the video file is longer, then you need to increase the length of the audio file to this length.

    


    If the audio file is longer than the video file, then make the audio file shorter to match the length of the video.

    


    Example :

    


    Video 2 minutes 5 seconds

    


    Audio 1 minute -> duplicated to 2 minutes 5 seconds.

    


    If

    


    Video 1 minute

    


    Audio 2 minutes 5 seconds -> trimmed to 1 minute.

    


    But, I can't even increase the length of the audio file.

    


    export async function overlayAudio(id: number, music: Music) {
  console.log('start')
  const videoPath = path.join(__dirname, `../../../uploads/movie/${id}/result/movie/predfinal.mp4`);
  
  if (music === null) {
    return videoPath.match(/\\uploads(.*)/)[0];
  } else {
    const audioPath = path.join(__dirname, `../../../${music.audio}`);
    const outputVideoPath = path.join(__dirname, `../../../uploads/movie/${id}/result/movie/output.mp4`);
    const matchPath = outputVideoPath.match(/\\uploads(.*)/);
    const cmd = `ffmpeg -i ${videoPath} -i ${audioPath} -filter_complex "[0:a]volume=1[a];[1:a]volume=0.2[b];[b]apad[looped_audio];[a][looped_audio]amix=inputs=2:duration=longest" -c:v copy -c:a aac -strict experimental -shortest ${outputVideoPath}`;

    try {
      await execPromise(cmd);
      console.log('end!')
      return matchPath[0];
    } catch (error) {
      console.error('Error:', error);
      throw error;
    }
  }
}



    


  • Using FFMpeg with Runtime.exec() to do a simple transcoding

    1er novembre 2011, par Adam Ingmansson

    I know there are many questions touching this subject, but none have helped me solve my issue.

    Purpose :

    Transcoding a video taken,from a queue, from .mov to h.264 (for now only that)

    Solution :

    Building a java application that gets the next in the queue, transcodes it then repeat

    Problem :

    Running ffmpeg using Runtime.exec() is not working.
    Im using the StreamGobbler from this tutorial to capturing the output from the process.

    This code shows how i start my process :

    String[] command = new String[]{"./ffmpeg/ffmpeg","-i",videoFile.getPath(),"-vcodec","libx264","-fpre",preset,folder + recID + ".flv"};
    System.out.println("Running command..");
    Process p = r.exec(command);

    // any error message?
    StreamGobbler errorGobbler = new
    StreamGobbler(p.getErrorStream(), "ERROR");            

    // any output?
    StreamGobbler outputGobbler = new
    StreamGobbler(p.getInputStream(), "OUT");

    // kick them off
    errorGobbler.start();
    outputGobbler.start();

    //logProcessOutputAndErrors(p);

    int res = p.waitFor();
    if (res != 0) {
       throw new Exception("Encoding error: "+String.valueOf(res));
    }

    and this is the current modified version of StreamGobbler (the important part)

    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);
    String line=null;
    int c = 0;
    StringBuilder str = new StringBuilder();

    while (true) {
       c = br.read();
    }

    Sometimes ffmpeg just stalls, maybe waiting for my input (although there is no indication on screen).

    Sometimes it just ends.

    Sometimes (when I added the line "System.out.print((char) c) ;" in the while-loop above) i got loads of "¿¿ï" repeated over and over again, wich might be the actual encoding of the video wich I managed to capture instead of to a file.

    For those who wonders why i dont just go with a commandline or maybe even php :

    The purpose is an application that will run 24/7 transcoding anything and everything from a queue. The files are pretty large to begin with and takes about 15 min to transcode.