Recherche avancée

Médias (1)

Mot : - Tags -/3GS

Autres articles (66)

  • Les autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

  • De l’upload à la vidéo finale [version standalone]

    31 janvier 2010, par

    Le chemin d’un document audio ou vidéo dans SPIPMotion est divisé en trois étapes distinctes.
    Upload et récupération d’informations de la vidéo source
    Dans un premier temps, il est nécessaire de créer un article SPIP et de lui joindre le document vidéo "source".
    Au moment où ce document est joint à l’article, deux actions supplémentaires au comportement normal sont exécutées : La récupération des informations techniques des flux audio et video du fichier ; La génération d’une vignette : extraction d’une (...)

  • Librairies et binaires spécifiques au traitement vidéo et sonore

    31 janvier 2010, par

    Les logiciels et librairies suivantes sont utilisées par SPIPmotion d’une manière ou d’une autre.
    Binaires obligatoires FFMpeg : encodeur principal, permet de transcoder presque tous les types de fichiers vidéo et sonores dans les formats lisibles sur Internet. CF ce tutoriel pour son installation ; Oggz-tools : outils d’inspection de fichiers ogg ; Mediainfo : récupération d’informations depuis la plupart des formats vidéos et sonores ;
    Binaires complémentaires et facultatifs flvtool2 : (...)

Sur d’autres sites (9861)

  • How to convert a Stream on the fly with FFMpegCore ?

    18 octobre 2023, par Adrian

    For a school project, I need to stream videos that I get from torrents while they are downloading on the server.
When the video is a .mp4 file, there's no problem, but I must also be able to stream .mkv files, and for that I need to convert them into .mp4 before sending them to the client, and I can't find a way to convert my Stream that I get from MonoTorrents with FFMpegCore into a Stream that I can send to my client.

    


    Here is the code I wrote to simply download and stream my torrent :

    


    var cEngine = new ClientEngine();

var manager = await cEngine.AddStreamingAsync(GenerateMagnet(torrent), ) ?? throw new Exception("An error occurred while creating the torrent manager");

await manager.StartAsync();
await manager.WaitForMetadataAsync();

var videoFile = manager.Files.OrderByDescending(f => f.Length).FirstOrDefault();
if (videoFile == null)
    return Results.NotFound();

var stream = await manager.StreamProvider!.CreateStreamAsync(videoFile, true);
return Results.File(stream, contentType: "video/mp4", fileDownloadName: manager.Name, enableRangeProcessing: true);


    


    I saw that the most common way to convert videos is by using ffmpeg. .NET has a package called FFMpefCore that is a wrapper for ffmpeg.

    


    To my previous code, I would add right before the return :

    


    if (!videoFile.Path.EndsWith(".mp4"))
{
    var outputStream = new MemoryStream();
    FFMpegArguments
        .FromPipeInput(new StreamPipeSource(stream), options =>
        {
            options.ForceFormat("mp4");
        })
        .OutputToPipe(new StreamPipeSink(outputStream))
        .ProcessAsynchronously();
    return Results.File(outputStream, contentType: "video/mp4", fileDownloadName: manager.Name, enableRangeProcessing: true);
}


    


    I unfortunately can't get a "live" Stream to send to my client.

    


  • ffmpeg c# asp.net video conversion error

    3 mai 2012, par Arun Kumar

    The following code shows error as "StandardOut has not been redirected or the process hasn't started yet." What is the problem in this code ? It requires any changes ? It always clear the process by catch exception.

    static void ExecuteAsync()
               {
                   if (File.Exists("Videos/output.flv"))
                   try
                   {
                       File.Delete("Videos/output.flv");
                   }
                   catch
                   {
                       return;
                   }

               try
               {
                   process = new Process();
                   ProcessStartInfo info = new ProcessStartInfo(@"e:\ffmpeg\bin\ffmpeg.exe", "-i cars1.flv -same_quant intermediate1.mpg");
                   info.CreateNoWindow = false;
                   info.UseShellExecute = false;
                   info.RedirectStandardError = true;
                   info.RedirectStandardOutput = true;
                   process.StartInfo = info;
                   process.EnableRaisingEvents = true;
                   process.ErrorDataReceived += new DataReceivedEventHandler(process_ErrorDataReceived);
                   process.OutputDataReceived += new DataReceivedEventHandler(process_OutputDataReceived);
                   process.Exited += new EventHandler(process_Exited);
                   process.Start();
                   process.BeginOutputReadLine();
                   process.BeginErrorReadLine();
               }
               catch (Exception ex)
               {
                   if (process != null) process.Dispose();
               }
           }
           static int lineCount = 0;
           static void process_ErrorDataReceived(object sender, DataReceivedEventArgs e)
           {
               Console.WriteLine("Input line: {0} ({1:m:s:fff})", lineCount++, DateTime.Now);
               Console.WriteLine(e.Data);
               Console.WriteLine();
           }

           static void process_OutputDataReceived(object sender, DataReceivedEventArgs e)
           {
               Console.WriteLine("Output Data Received.");
           }

           static void process_Exited(object sender, EventArgs e)
           {
               process.Dispose();
               Console.WriteLine("Bye bye!");
           }
       }
  • How to interact with process output ?

    14 mai, par 1ben99

    Ok so at the moment I have a program which runs FFmpeg using a process in VB.net. I send the process arguments in the startinfo as well as other things like the file location. When I run the code it sends the console output to the debug console ; this is probably because I have the .UseShellExecute = False and processInfo.RedirectStandardOutput = True

    



    My question is : How do I make something which can interpret the output ? Also with FFmpeg, the process is continuous so the process is always running for the most part and constantly adding more output lines in the debug console.

    



    The code I am using :

    



    Dim process As New Process
        Dim processInfo As New ProcessStartInfo
        processInfo.FileName = tempPath
        processInfo.Arguments = ("-r 1/.1 -i " + link + " -c copy " + saveLocation + "\" + streamerName + ".ts")
        processInfo.UseShellExecute = False
        processInfo.WindowStyle = ProcessWindowStyle.Hidden
        processInfo.CreateNoWindow = True
        processInfo.RedirectStandardOutput = True
        process.StartInfo = processInfo
        process.Start()


    



    I tried this with no luck.

    



    Dim output As String
        Using StreamReader As System.IO.StreamReader = process.StandardOutput
            output = StreamReader.ReadToEnd().ToString
        End Using


    



    Edit : I now have this code :

    



    Dim process As New Process
        AddHandler process.OutputDataReceived, AddressOf CallbackProcesoAsync
        AddHandler process.ErrorDataReceived, AddressOf ErrorDataReceivedAsync
        Dim processInfo As New ProcessStartInfo
        processInfo.FileName = tempPath
        processInfo.Arguments = ("-r 1/.1 -i " + link + " -c copy " + saveLocation + "\" + streamerName + ".ts")
        processInfo.UseShellExecute = False
        processInfo.WindowStyle = ProcessWindowStyle.Hidden
        processInfo.CreateNoWindow = False
        processInfo.RedirectStandardOutput = True
        processInfo.RedirectStandardError = True
        process.StartInfo = processInfo
        process.Start()
        processes.Add(Tuple.Create(tempPath, streamerName))
        Debug.WriteLine("Attempting to record " + streamerName)
        Dim output As String
        Using StreamReader As System.IO.StreamReader = process.StandardOutput
            output = StreamReader.ReadToEnd().ToString
        End Using
    End If
End Sub

Private Sub CallbackProcesoAsync(sender As Object, args As System.Diagnostics.DataReceivedEventArgs)
    If Not args.Data Is Nothing AndAlso Not String.IsNullOrEmpty(args.Data) Then
        RichTextBox1.Text = args.Data
    End If
End Sub

Private Sub ErrorDataReceivedAsync(sender As Object, args As System.Diagnostics.DataReceivedEventArgs)
    If Not args.Data Is Nothing AndAlso Not String.IsNullOrEmpty(args.Data) Then
        RichTextBox2.Text = args.Data
    End If
End Sub


    



    But I have not recieved any outputs to the richtextboxes ?

    



    I feel like it has something to do with the streamReader so I removed it and it still didn't work ? I don't have any more ideas what it could be.