Recherche avancée

Médias (1)

Mot : - Tags -/ogv

Autres articles (15)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

  • Les formats acceptés

    28 janvier 2010, par

    Les commandes suivantes permettent d’avoir des informations sur les formats et codecs gérés par l’installation local de ffmpeg :
    ffmpeg -codecs ffmpeg -formats
    Les format videos acceptés en entrée
    Cette liste est non exhaustive, elle met en exergue les principaux formats utilisés : h264 : H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 m4v : raw MPEG-4 video format flv : Flash Video (FLV) / Sorenson Spark / Sorenson H.263 Theora wmv :
    Les formats vidéos de sortie possibles
    Dans un premier temps on (...)

  • Les vidéos

    21 avril 2011, par

    Comme les documents de type "audio", Mediaspip affiche dans la mesure du possible les vidéos grâce à la balise html5 .
    Un des inconvénients de cette balise est qu’elle n’est pas reconnue correctement par certains navigateurs (Internet Explorer pour ne pas le nommer) et que chaque navigateur ne gère en natif que certains formats de vidéos.
    Son avantage principal quant à lui est de bénéficier de la prise en charge native de vidéos dans les navigateur et donc de se passer de l’utilisation de Flash et (...)

Sur d’autres sites (4454)

  • Discord.Net sending audio with ffmpeg only works once (the first time)

    16 janvier 2023, par Esko

    Context :

    


    So I am writing a small bot that should play local audio files on command. I am using Discord.Net, ffmpeg, opus and libsodium.
I have a Speak() function that should, in Theory,

    


    Open ffmpeg -> encode .mp3 -> create PCM stream -> pump the encoded .mp3 to the output(PCM Stream).

    


    That looks like this :

    


    public async Task Speak(IGuild guild, Sound.SoundName soundName)
{
  IAudioClient client;
  if (ConnectedChannels.TryGetValue(guild.Id, out client))
  {
    using (var ffmpeg = CreateStream(sound.Filename))
    using (var stream = client.CreatePCMStream(AudioApplication.Voice, 98304))
    using (var output = ffmpeg.StandardOutput.BaseStream)
    {
     try
     {
       await output.CopyToAsync(stream);                            
     }
     catch (Exception ex) { Console.WriteLine("Error " + ex.Message); Console.WriteLine($"- {ex.StackTrace}"); }
     finally { await stream.FlushAsync(); }
     Console.WriteLine("Spoken!");
   }
}

private Process CreateStream(string _path) 
{
  var process = Process.Start(new ProcessStartInfo
                 {
                   FileName = "ffmpeg",
                   Arguments = $"-hide_banner -loglevel panic -i \"{_path}\" -ac 2 -f s16le -ar 48000 pipe:1",
                   UseShellExecute = false,
                   RedirectStandardOutput = true,
                 });
  return process;
}


    


    And it does this, but only one time. A bit more specific, When my bot joins a Voice Channel, it saves the VoiceChannel ID and the IAudioClient in a private static readonly ConcurrentDictionary ConnectedChannels = new ConcurrentDictionary();. After that it automatically calls the Speak() function to play a hello.mp3 audio. This Process is done like this :

    


    [Command("join", RunMode = RunMode.Async)]
[RequireUserPermission(GuildPermission.MentionEveryone)]
public async Task JoinChannel(IVoiceChannel channel = null) 
{
 // Get the Voice channel
 channel = channel ?? (Context.User as IGuildUser)?.VoiceChannel;
 if (channel == null) { await Context.Channel.SendMessageAsync("You are not in a VoiceChannel"); return; }

 // Saving the AudioClient
 var audioClient = await channel.ConnectAsync();
 Console.WriteLine($"Connected to channel {channel.Name}");

 ConnectedChannels.TryAdd(channel.Guild.Id, audioClient);

 await Task.Delay(1000);
 await Speak(Context.Guild, Sound.SoundName.hello);
}


    


    This works pefectly fine, The audio plays.

    


    Now that the bot is connected to a VoiceChannel and the IAudioClient is saved to the Dictionary. I should be able to call the Speak() function whenever i want and from Whereever i want, as long as the bot is in the VoiceChannel, right ?

    


    No it doesnt.

    


    and that takes me to my

    


    Problem :

    


    After the bot is now sitting silently in the voice channel i call a "speak" command that looks in code like this :

    


    [Command("speak")]
public async Task speakSingle() 
{
  await Speak(Context.Guild, Sound.SoundName.Random);
}


    


    But the bot remains silent, even though the speak indicator in Discord lights up ! What am I missing ? I dont get it. Is it sending an empty stream ?
    Even when I disconnect the bot from the VoiceChannel an reconnect it It wont send audio. The only thing that helps is Reconectiong the Bot From the Server.
    I am pretty new to C# and Streams and async programing. So could somebody help me out finding the problem and fix it ?

    


    Errors (CommandPromt Ouput) :

    


    1#
    This occures when i run the "speak" command, im getting a NullReferenceException for "Discord.WebSocket.pdb not loaded" in VisualStudio. Allthough I couldn't find anything thats null...

    


    17:34:17 Audio #1    System.Exception: WebSocket connection was closed&#xA; ---> Discord.Net.WebSocketClosedException: The server sent close 4008: "Rate limited."&#xA;   at Discord.Net.WebSockets.DefaultWebSocketClient.RunAsync(CancellationToken cancelToken)&#xA;   --- End of inner exception stack trace ---&#xA;   at Discord.ConnectionManager.&lt;>c__DisplayClass29_0.&lt;<startasync>b__0>d.MoveNext()&#xA;</startasync>

    &#xA;

    2#
    This occures when the bot rejoined the Voice Channel and automatically executes the Speak() function.

    &#xA;

    Error A task was canceled.&#xA;-    at Discord.Audio.Streams.BufferedWriteStream.WriteAsync(Byte[] data, Int32 offset, Int32 count, CancellationToken cancelToken)&#xA;   at Discord.Audio.Streams.OpusEncodeStream.WriteAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancelToken)&#xA;   at System.IO.Stream.CopyToAsyncInternal(Stream destination, Int32 bufferSize, CancellationToken cancellationToken)&#xA;   at Bot.Modules.VoiceChannel.Speak(IGuild guild, SoundName soundName) in Y:\Dokumente\Coding\C#\Vs_Studio\Bot\Bot\Modules\VoiceChannel.cs:line 90&#xA;

    &#xA;

    This is my first Question on StackOverflow and i hope i provieded enough context, if not tell me please.

    &#xA;

  • How to quote a file name with a single quote in ffmpeg movie= filter notation ? [closed]

    21 avril, par PieterV

    I am trying to run ffmpeg using a file that contains a single quote &#x27; in the filename.

    &#xA;

    I tried to follow the docs that say I should replace a &#x27; with &#x27;\&#x27;&#x27;.
    &#xA;And a ticket that says I should replace a &#x27; with \\\\\&#x27;.

    &#xA;

    I've tried both, and can't get get it working.

    &#xA;

    E.g. docs format :

    &#xA;

    ./ffprobe -loglevel error -read_intervals %00:30 -select_streams s:0 -f lavfi -i "movie=&#x27;D\:\\Test\\Interlaced - Dragons&#x27;\&#x27;&#x27; Den - S14E02 - Episode 2.mkv&#x27;[out0&#x2B;subcc]" -show_packets -print_format json&#xA;&#xA;{&#xA;[Parsed_movie_0 @ 00000222a2f82200] Failed to avformat_open_input &#x27;D:\Test\Interlaced - Dragons Den - S14E02 - Episode 2.mkv&#x27;&#xA;[AVFilterGraph @ 00000222a2f76ec0] Error processing filtergraph: No such file or directory&#xA;movie=&#x27;D\:\\Test\\Interlaced - Dragons&#x27;\&#x27;&#x27; Den - S14E02 - Episode 2.mkv&#x27;[out0&#x2B;subcc]: No such file or directory&#xA;

    &#xA;

    E.g. ticket format :

    &#xA;

    ./ffprobe -loglevel error -read_intervals %00:30 -select_streams s:0 -f lavfi -i "movie=&#x27;D\:\\Test\\Interlaced - Dragons\\\\\&#x27; Den - S14E02 - Episode 2.mkv&#x27;[out0&#x2B;subcc]" -show_packets -print_format json&#xA;&#xA;{&#xA;[Parsed_movie_0 @ 00000158613d2080] Failed to avformat_open_input &#x27;D:\Test\Interlaced - Dragons\\ Den - S14E02 - Episode 2.mkv[out0&#x2B;subcc]&#x27;&#xA;[AVFilterGraph @ 00000158613c6ec0] Error processing filtergraph: No such file or directory&#xA;movie=&#x27;D\:\\Test\\Interlaced - Dragons\\\\\&#x27; Den - S14E02 - Episode 2.mkv&#x27;[out0&#x2B;subcc]: No such file or directory&#xA;

    &#xA;

    > dir "D:\Test\Interlaced - Dragons&#x27; Den - S14E02 - Episode 2.mkv"&#xA;&#xA;    Directory: D:\Test&#xA;&#xA;Mode                 LastWriteTime         Length Name&#xA;----                 -------------         ------ ----&#xA;-a---           4/20/2025 11:38 AM       18059051 Interlaced - Dragons&#x27; Den - S14E02 - Episode 2.mkv&#xA;

    &#xA;

    This is on Win11 using FFmpeg7.
    &#xA;Any ideas ?

    &#xA;

    [Update]
    &#xA;I found a doc on escape filtergraph strings, did not help, I tried 0 to 7 \.

    &#xA;

    I also found and tried the ffescape utility, the output it produces just uses a single \&#x27; and does not work.

    &#xA;

    > echo "D:\Test\Interlaced - Dragons&#x27; Den - S14E02 - Episode 2.mkv" | ./ffescape.exe&#xA;=> D:\\Test\\Interlaced - Dragons\&#x27; Den - S14E02 - Episode 2.mkv\&#xA;&#xA;> ./ffprobe -loglevel error -read_intervals %00:30 -select_streams s:0 -f lavfi -i "movie=&#x27;D:\\Test\\Interlaced - Dragons\&#x27; Den - S14E02 - Episode 2.mkv\&#x27;[out0&#x2B;subcc]" -show_packets -print_format json&#xA;{&#xA;[Parsed_movie_0 @ 0000021348f12200] Failed to avformat_open_input &#x27;D&#x27;&#xA;[AVFilterGraph @ 0000021348f06ec0] Error processing filtergraph: No such file or directory&#xA;movie=&#x27;D:\\Test\\Interlaced - Dragons\&#x27; Den - S14E02 - Episode 2.mkv\&#x27;[out0&#x2B;subcc]: No such file or directory&#xA;

    &#xA;

    [Update]
    &#xA;I found docs for ffmpeg filter script where I can place commands in a file.

    &#xA;

    I tried ./ffprobe -loglevel error -read_intervals %00:01 -select_streams s:0 -f lavfi -/i "d:\filtergraph.txt" -show_packets -print_format json, and it load the script.

    &#xA;

    Works : movie=test.mkv[out0&#x2B;subcc]\ if test.mkv is in ffprobe dir.&#xA;Works : movie=test\&#x27;.mkv[out0&#x2B;subcc]\ if test&#x27;.mkv is in ffprobe dir.
    &#xA;Not : movie=D:\test.mkv[out0&#x2B;subcc]
    &#xA;Not : movie=D\:\\test.mkv[out0&#x2B;subcc]
    &#xA;Not : movie=test space.mkv[out0&#x2B;subcc]
    &#xA;Not : movie=&#x27;test space.mkv[out0&#x2B;subcc]&#x27;
    &#xA;Not : movie="test space.mkv[out0&#x2B;subcc]"
    &#xA;Not : &#x27;movie=test space.mkv[out0&#x2B;subcc]&#x27;
    &#xA;Not : "movie=test space.mkv[out0&#x2B;subcc]"

    &#xA;

     :(

    &#xA;

  • How to dump ALL metadata from a media file, including cover image title ? [closed]

    9 avril, par Unideal

    I have an MP3 song :

    &#xA;

    # ffprobe -hide_banner -i filename.mp3&#xA;Input #0, mp3, from &#x27;filename.mp3&#x27;:&#xA;  Metadata:&#xA;    composer        : Music Author&#xA;    title           : Song Name&#xA;    artist          : Singer&#xA;    encoder         : Lavf61.7.100&#xA;    genre           : Rock&#xA;    date            : 2025&#xA;  Duration: 00:03:14.04, start: 0.023021, bitrate: 208 kb/s&#xA;  Stream #0:0: Audio: mp3 (mp3float), 48000 Hz, stereo, fltp, 192 kb/s&#xA;      Metadata:&#xA;        encoder         : Lavc61.19&#xA;  Stream #0:1: Video: png, rgb24(pc, gbr/unknown/unknown), 600x600 [SAR 1:1 DAR 1:1], 90k tbr, 90k tbn (attached pic)&#xA;      Metadata:&#xA;        title           : Cover&#xA;        comment         : Cover (front)&#xA;

    &#xA;

    The task is to save its metadata to a text file and restore from that file later. Both goals should be accomplished with ffmpeg.

    &#xA;

    The simpliest method is to run :

    &#xA;

    # ffmpeg -i filename.mp3 -f ffmetadata metadata.txt&#xA;

    &#xA;

    After that, metadata.txt contains :

    &#xA;

    ;FFMETADATA1&#xA;composer=Music Author&#xA;title=Song Name&#xA;artist=Singer&#xA;date=2025&#xA;genre=Rock&#xA;encoder=Lavf61.7.100&#xA;

    &#xA;

    I got global metadata only, but stream-specific info (cover image title and comment in my case) are missing.

    &#xA;

    Google suggested a more complex form of the command above to extract all metadata fields without any exclusions :

    &#xA;

    # ffmpeg -y -i filename.mp3 -c copy -map_metadata 0 -map_metadata:s:v 0:s:v -map_metadata:s:a 0:s:a -f ffmetadata metadata.txt&#xA;

    &#xA;

    But the output is exactly the same :

    &#xA;

    ;FFMETADATA1&#xA;composer=Music Author&#xA;title=Song Name&#xA;artist=Singer&#xA;date=2025&#xA;genre=Rock&#xA;encoder=Lavf61.7.100&#xA;

    &#xA;

    Again, no info about the attached image.

    &#xA;

    Please explain what am I doing wrong.

    &#xA;