Recherche avancée

Médias (17)

Mot : - Tags -/wired

Autres articles (39)

  • Installation en mode ferme

    4 février 2011, par

    Le mode ferme permet d’héberger plusieurs sites de type MediaSPIP en n’installant qu’une seule fois son noyau fonctionnel.
    C’est la méthode que nous utilisons sur cette même plateforme.
    L’utilisation en mode ferme nécessite de connaïtre un peu le mécanisme de SPIP contrairement à la version standalone qui ne nécessite pas réellement de connaissances spécifique puisque l’espace privé habituel de SPIP n’est plus utilisé.
    Dans un premier temps, vous devez avoir installé les mêmes fichiers que l’installation (...)

  • 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

  • Personnaliser les catégories

    21 juin 2013, par

    Formulaire de création d’une catégorie
    Pour ceux qui connaissent bien SPIP, une catégorie peut être assimilée à une rubrique.
    Dans le cas d’un document de type catégorie, les champs proposés par défaut sont : Texte
    On peut modifier ce formulaire dans la partie :
    Administration > Configuration des masques de formulaire.
    Dans le cas d’un document de type média, les champs non affichés par défaut sont : Descriptif rapide
    Par ailleurs, c’est dans cette partie configuration qu’on peut indiquer le (...)

Sur d’autres sites (9647)

  • On-demand and seamless transcoding of individual HLS segments

    5 janvier 2024, par Omid Ariyan

    Background

    


    I've been meaning to implement on-demand transcoding of certain video formats such as ".mkv", ".wmv", ".mov", etc. in order to serve them on a media management server using ASP.NET Core 6.0, C# and ffmpeg.

    


    My Approach

    


    The approach I've decided to use is to serve a dynamically generated .m3u8 file which is simply generated using a segment duration of choice e.g. 10s and the known video duration. Here's how I've done it. Note that the resolution is currently not implemented and discarded :

    


    public string GenerateVideoOnDemandPlaylist(double duration, int segment)
{
   double interval = (double)segment;
   var content = new StringBuilder();

   content.AppendLine("#EXTM3U");
   content.AppendLine("#EXT-X-VERSION:6");
   content.AppendLine(String.Format("#EXT-X-TARGETDURATION:{0}", segment));
   content.AppendLine("#EXT-X-MEDIA-SEQUENCE:0");
   content.AppendLine("#EXT-X-PLAYLIST-TYPE:VOD");
   content.AppendLine("#EXT-X-INDEPENDENT-SEGMENTS");

   for (double index = 0; (index * interval) < duration; index++)
   {
      content.AppendLine(String.Format("#EXTINF:{0:#.000000},", ((duration - (index * interval)) > interval) ? interval : ((duration - (index * interval)))));
      content.AppendLine(String.Format("{0:00000}.ts", index));
   }

   content.AppendLine("#EXT-X-ENDLIST");

   return content.ToString();
}

[HttpGet]
[Route("stream/{id}/{resolution}.m3u8")]
public IActionResult Stream(string id, string resolution)
{
   double duration = RetrieveVideoLengthInSeconds();
   return Content(GenerateVideoOnDemandPlaylist(duration, 10), "application/x-mpegURL", Encoding.UTF8);
}


    


    Here's an example of how the .m3u8 file looks like :

    


    #EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-INDEPENDENT-SEGMENTS
#EXTINF:10.000000,
00000.ts
#EXTINF:3.386667,
00001.ts
#EXT-X-ENDLIST


    


    So the player would ask for 00000.ts, 00001.ts, etc. and the next step is to have them generated on demand :

    


    public byte[] GenerateVideoOnDemandSegment(int index, int duration, string path)&#xA;{&#xA;   int timeout = 30000;&#xA;   int totalWaitTime = 0;&#xA;   int waitInterval = 100;&#xA;   byte[] output = Array.Empty<byte>();&#xA;   string executable = "/opt/homebrew/bin/ffmpeg";&#xA;   DirectoryInfo temp = Directory.CreateDirectory(System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetRandomFileName()));&#xA;   string format = System.IO.Path.Combine(temp.FullName, "output-%05d.ts");&#xA;&#xA;   using (Process ffmpeg = new())&#xA;   {&#xA;      ffmpeg.StartInfo.FileName = executable;&#xA;&#xA;      ffmpeg.StartInfo.Arguments = String.Format("-ss {0} ", index * duration);&#xA;      ffmpeg.StartInfo.Arguments &#x2B;= String.Format("-y -t {0} ", duration);&#xA;      ffmpeg.StartInfo.Arguments &#x2B;= String.Format("-i \"{0}\" ", path);&#xA;      ffmpeg.StartInfo.Arguments &#x2B;= String.Format("-c:v libx264 -c:a aac ");&#xA;      ffmpeg.StartInfo.Arguments &#x2B;= String.Format("-segment_time {0} -reset_timestamps 1 -break_non_keyframes 1 -map 0 ", duration);&#xA;      ffmpeg.StartInfo.Arguments &#x2B;= String.Format("-initial_offset {0} ", index * duration);&#xA;      ffmpeg.StartInfo.Arguments &#x2B;= String.Format("-f segment -segment_format mpegts {0}", format);&#xA;&#xA;      ffmpeg.StartInfo.CreateNoWindow = true;&#xA;      ffmpeg.StartInfo.UseShellExecute = false;&#xA;      ffmpeg.StartInfo.RedirectStandardError = false;&#xA;      ffmpeg.StartInfo.RedirectStandardOutput = false;&#xA;&#xA;      ffmpeg.Start();&#xA;&#xA;      do&#xA;      {&#xA;         Thread.Sleep(waitInterval);&#xA;         totalWaitTime &#x2B;= waitInterval;&#xA;      }&#xA;      while ((!ffmpeg.HasExited) &amp;&amp; (totalWaitTime &lt; timeout));&#xA;&#xA;      if (ffmpeg.HasExited)&#xA;      {&#xA;         string filename = System.IO.Path.Combine(temp.FullName, "output-00000.ts");&#xA;&#xA;         if (!File.Exists(filename))&#xA;         {&#xA;            throw new FileNotFoundException("Unable to find the generated segment: " &#x2B; filename);&#xA;         }&#xA;&#xA;         output = File.ReadAllBytes(filename);&#xA;      }&#xA;      else&#xA;      {&#xA;         // It&#x27;s been too long. Kill it!&#xA;         ffmpeg.Kill();&#xA;      }&#xA;   }&#xA;&#xA;   // Remove the temporary directory and all its contents.&#xA;   temp.Delete(true);&#xA;&#xA;   return output;&#xA;}&#xA;&#xA;[HttpGet]&#xA;[Route("stream/{id}/{index}.ts")]&#xA;public IActionResult Segment(string id, int index)&#xA;{&#xA;   string path = RetrieveVideoPath(id);&#xA;   return File(GenerateVideoOnDemandSegment(index, 10, path), "application/x-mpegURL", true);&#xA;}&#xA;</byte>

    &#xA;

    So as you can see, here's the command I use to generate each segment incrementing -ss and -initial_offset by 10 for each segment :

    &#xA;

    ffmpeg -ss 0 -y -t 10 -i "video.mov" -c:v libx264 -c:a aac -segment_time 10 -reset_timestamps 1 -break_non_keyframes 1 -map 0 -initial_offset 0 -f segment -segment_format mpegts /var/folders/8h/3xdhhky96b5bk2w2br6bt8n00000gn/T/4ynrwu0q.z24/output-%05d.ts&#xA;

    &#xA;

    The Problem

    &#xA;

    Things work on a functional level, however the transition between segments is slightly glitchy and especially the audio has very short interruptions at each 10 second mark. How can I ensure the segments are seamless ? What can I improve in this process ?

    &#xA;

  • Saving individual frames of multiple m3u8 streams

    10 décembre 2023, par Toprak

    I have a list of multiple m3u8 stream URLs. I want to grab individual live frames of these streams and save them locally. I managed to do this with openCv however, the number of streams is around 20, even though I wrote the code using parallel processing and multithreading, some streams wait too long to download the new frames.

    &#xA;

    Is there a better way or faster module that I can use ? Theoretically it shouldn't be this hard because I can open each stream in browser and the client side player can stream it. I feel like maybe ffmpeg is a solution, but I couldn't find a way to download and save each frame from a stream link by ffmpeg, with a unique name so. it doesn't update all the time.

    &#xA;

    Edit :&#xA;I attempted to this issue with ffmpeg as well, using multithreading , but probably because each time they want to grab a frame, they need to connect, this is slower.

    &#xA;

    ffmpeg -i url.m3u8 -vframes 1 -q:v 2 output.jpg

    &#xA;

  • The RTSP stream provided by my camera is parsed properly by ffmpeg on windows but on Linux it shows:Invalid data found when processing input ? [closed]

    9 novembre 2023, par LvWei

    The RTSP stream provided by my camera is parsed properly by ffmpeg on windows but on Linux it shows:Invalid data found when processing input ?

    &#xA;

    The execution logs for ffmpeg for both operating systems are as follows:

    &#xA;

    Linux :

    &#xA;

    Opening an input file: rtsp://admin:12345678wjc@10.11.12.143:8960/h264/ch1/sub/av_stream.&#xA;Probing rtsp score:100 size:0&#xA;[tcp @ 0x64c8480] No default whitelist set&#xA;[tcp @ 0x64c8480] Original list of addresses:&#xA;[tcp @ 0x64c8480] Address 10.11.12.143 port 8960&#xA;[tcp @ 0x64c8480] Interleaved list of addresses:&#xA;[tcp @ 0x64c8480] Address 10.11.12.143 port 8960&#xA;[tcp @ 0x64c8480] Starting connection attempt to 10.11.12.143 port 8960&#xA;[tcp @ 0x64c8480] Successfully connected to 10.11.12.143 port 8960&#xA;[rtsp @ 0x64c5840] Sending:&#xA;OPTIONS rtsp://10.11.12.143:8960/h264/ch1/sub/av_stream RTSP/1.0&#xA;CSeq: 1&#xA;User-Agent: Lavf60.3.100&#xA;&#xA;--&#xA;[rtsp @ 0x64c5840] ret=-104 c=00 [rtsp://admin:password@10.11.12.143:8960/h264/ch1/sub/av_stream: Invalid data found when processing input&#xA;

    &#xA;

    Windows :

    &#xA;

    [tcp @ 000001c07a8ddd00] No default whitelist set&#xA;[tcp @ 000001c07a8ddd00] Original list of addresses:&#xA;[tcp @ 000001c07a8ddd00] Address 10.11.12.143 port 8960&#xA;[tcp @ 000001c07a8ddd00] Interleaved list of addresses:&#xA;[tcp @ 000001c07a8ddd00] Address 10.11.12.143 port 8960&#xA;[tcp @ 000001c07a8ddd00] Starting connection attempt to 10.11.12.143 port 8960&#xA;[tcp @ 000001c07a8ddd00] Successfully connected to 10.11.12.143 port 8960&#xA;[rtsp @ 000001c07a8da480] Sending:&#xA;OPTIONS rtsp://10.11.12.143:8960/h264/ch1/sub/av_stream RTSP/1.0&#xA;CSeq: 1&#xA;User-Agent: Lavf60.15.100&#xA;&#xA;--&#xA;[rtsp @ 000001c07a8da480] ret=1 c=52 [R]&#xA;[rtsp @ 000001c07a8da480] ret=1 c=54 [T]&#xA;[rtsp @ 000001c07a8da480] ret=1 c=53 [S]&#xA;[rtsp @ 000001c07a8da480] ret=1 c=50 [P]&#xA;[rtsp @ 000001c07a8da480] ret=1 c=2f [/]&#xA;[rtsp @ 000001c07a8da480] ret=1 c=31 [1]&#xA;[rtsp @ 000001c07a8da480] ret=1 c=2e [.]&#xA;[rtsp @ 000001c07a8da480] ret=1 c=30 [0]&#xA;[rtsp @ 000001c07a8da480] ret=1 c=20 [ ]&#xA;[rtsp @ 000001c07a8da480] ret=1 c=32 [2]&#xA;[rtsp @ 000001c07a8da480] ret=1 c=30 [0]&#xA;    Last message repeated 1 times&#xA;[rtsp @ 000001c07a8da480] ret=1 c=20 [ ]&#xA;[rtsp @ 000001c07a8da480] ret=1 c=4f [O]&#xA;[rtsp @ 000001c07a8da480] ret=1 c=4b [K]&#xA;[rtsp @ 000001c07a8da480] ret=1 c=0d [&#xA;]&#xA;[rtsp @ 000001c07a8da480] ret=1 c=0a [&#xA;]&#xA;[rtsp @ 000001c07a8da480] line=&#x27;RTSP/1.0 200 OK&#x27;&#xA;

    &#xA;

    windows下完整执行日志链接:&#xA;https://cowtransfer.com/s/b69b55e743c244 点击链接查看 [ windows_log.txt ] ,或访问奶牛快传 cowtransfer.com 输入传输口令 bsp0fk 查看;

    &#xA;

    Why is this happening ? What causes parsing failures on linux systems ?感谢各位大佬!!!

    &#xA;