Recherche avancée

Médias (2)

Mot : - Tags -/media

Autres articles (53)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

  • Ecrire une actualité

    21 juin 2013, par

    Présentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
    Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
    Vous pouvez personnaliser le formulaire de création d’une actualité.
    Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)

  • 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

Sur d’autres sites (9533)

  • 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;

  • Remove characters from string using cmd.exe batch file and ffmpeg

    26 décembre 2023, par user2498772

    Here is the code...

    &#xA;

    @echo off&#xA;:: set paths (no quotes)&#xA;set ffmpeg=F:\Video\Ffmpeg\ffmpeg.exe&#xA;set infolder=F:\Downloads&#xA;set outfolder=F:\Video\Finished&#xA;&#xA;&#xA;&#xA;@echo.&#xA;@echo on&#xA;for %%f in (%infolder%\*.mp4) do "%ffmpeg%" -i "%%~dpnf.mp4" -c copy "%outfolder%\%%~nf.mp4"&#xA;@echo off&#xA;if errorlevel 1 pause&#xA;@echo.&#xA;

    &#xA;

    This code converts an mpeg-dash file to mp4.&#xA;An mpeg-dash is a streaming file format.

    &#xA;

    The input and output file looks like this : "filename - DASH_V.mp4". (no quotes)

    &#xA;

    I would like the output file to have the " - DASH_V" removed, so it looks like "filename.mp4". (no quotes)

    &#xA;

    Any help would be appreciated. Could be a quick fix like changing "%% dpnf -13.0.mp4" to last command, but I am clueless on syntax as you can see.

    &#xA;

    Tried a million things and got nowhere. Clueless on syntax.

    &#xA;

  • FFMPEG fails with seeking params before input on AWS Lambda

    18 janvier 2023, par Rashid Goshtasbi

    I am trying to run the following command on AWS Lambda that has FFMPEG layer but it fails with a SIGSEGV. The FFMPEG process starts working fine until it reaches the segment's it wants to get.

    &#xA;

    /opt/ffmpeglib/ffmpeg -ss 00:02:00 -t 30 -i https://cdn.bitmovin.com/content/assets/art-of-motion-dash-hls-progressive/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa-audio-only.m3u8 /tmp/out.aac -y&#xA;

    &#xA;

    Note : The url is a sample url for this sharing

    &#xA;

    What this is doing : It will seek 2 minutes into the stream url, then capture the next 30 seconds into an out.aac file. When I run this locally, it works fine. When I run this on Lambda, it ends abruptly when reading the segments that are in the time frame I want (from 2:00min to 2:30 min).

    &#xA;

    FFMPEG will skip the frames if I put the -ss 00:02:00 -t 30 before the -i which they state is faster. If i put it after the -i, it works, but of course, it's a bit slower.

    &#xA;

    Example working command :

    &#xA;

    /opt/ffmpeglib/ffmpeg -i https://cdn.bitmovin.com/content/assets/art-of-motion-dash-hls-progressive/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa-audio-only.m3u8 -ss 00:02:00 -t 30 /tmp/out.aac -y&#xA;

    &#xA;

    Wondering if anyone knows a way to run this on Lambda. Thank you.

    &#xA;

    Note : I have tried this on Python and Javascript. Tried also making child processes with Javascript and no luck. I also added -nostdin and piped stdin/out to dev null but nothing.

    &#xA;

    Thanks.

    &#xA;

    Example of me running locally :

    &#xA;

    ~/D/build [1]$ ffmpeg -ss 00:02:00 -t 30 -i https://cdn.bitmovin.com/content/assets/art-of-motion-dash-hls-progressive/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa-audio-only.m3u8 /tmp/out.aac -y                                                                      14:56:13&#xA;ffmpeg version 5.1.2 Copyright (c) 2000-2022 the FFmpeg developers&#xA;  built with Apple clang version 14.0.0 (clang-1400.0.29.102)&#xA;  configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/5.1.2 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-neon&#xA;  libavutil      57. 28.100 / 57. 28.100&#xA;  libavcodec     59. 37.100 / 59. 37.100&#xA;  libavformat    59. 27.100 / 59. 27.100&#xA;  libavdevice    59.  7.100 / 59.  7.100&#xA;  libavfilter     8. 44.100 /  8. 44.100&#xA;  libswscale      6.  7.100 /  6.  7.100&#xA;  libswresample   4.  7.100 /  4.  7.100&#xA;  libpostproc    56.  6.100 / 56.  6.100&#xA;[hls @ 0x122f05250] Opening &#x27;https://cdn.bitmovin.com/content/assets/art-of-motion-dash-hls-progressive/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa_audio_1_stereo_128000.m3u8&#x27; for reading&#xA;[hls @ 0x122f05250] Skip (&#x27;#EXT-X-VERSION:3&#x27;)&#xA;[hls @ 0x122f05250] Opening &#x27;https://cdn.bitmovin.com/content/assets/art-of-motion-dash-hls-progressive/audio/1_stereo_128000/hls/segment_0.ts&#x27; for reading&#xA;[hls @ 0x122f05250] Opening &#x27;https://cdn.bitmovin.com/content/assets/art-of-motion-dash-hls-progressive/audio/1_stereo_128000/hls/segment_1.ts&#x27; for reading&#xA;Input #0, hls, from &#x27;https://cdn.bitmovin.com/content/assets/art-of-motion-dash-hls-progressive/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa-audio-only.m3u8&#x27;:&#xA;  Duration: 00:03:31.43, start: 0.000000, bitrate: 0 kb/s&#xA;  Program 0 &#xA;    Metadata:&#xA;      variant_bitrate : 128000&#xA;  Stream #0:0: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp&#xA;    Metadata:&#xA;      variant_bitrate : 128000&#xA;Stream mapping:&#xA;  Stream #0:0 -> #0:0 (aac (native) -> aac (native))&#xA;Press [q] to stop, [?] for help&#xA;[hls @ 0x122f05250] Opening &#x27;https://cdn.bitmovin.com/content/assets/art-of-motion-dash-hls-progressive/audio/1_stereo_128000/hls/segment_30.ts&#x27; for reading&#xA;[hls @ 0x122f05250] Opening &#x27;https://cdn.bitmovin.com/content/assets/art-of-motion-dash-hls-progressive/audio/1_stereo_128000/hls/segment_31.ts&#x27; for reading&#xA;Output #0, adts, to &#x27;/tmp/out.aac&#x27;:&#xA;  Metadata:&#xA;    encoder         : Lavf59.27.100&#xA;  Stream #0:0: Audio: aac (LC), 48000 Hz, stereo, fltp, 128 kb/s&#xA;    Metadata:&#xA;      variant_bitrate : 128000&#xA;      encoder         : Lavc59.37.100 aac&#xA;[https @ 0x12001c600] Opening &#x27;https://cdn.bitmovin.com/content/assets/art-of-motion-dash-hls-progressive/audio/1_stereo_128000/hls/segment_32.ts&#x27; for reading&#xA;[https @ 0x124038800] Opening &#x27;https://cdn.bitmovin.com/content/assets/art-of-motion-dash-hls-progressive/audio/1_stereo_128000/hls/segment_33.ts&#x27; for reading&#xA;[https @ 0x12001c600] Opening &#x27;https://cdn.bitmovin.com/content/assets/art-of-motion-dash-hls-progressive/audio/1_stereo_128000/hls/segment_34.ts&#x27; for reading&#xA;[https @ 0x124038800] Opening &#x27;https://cdn.bitmovin.com/content/assets/art-of-motion-dash-hls-progressive/audio/1_stereo_128000/hls/segment_35.ts&#x27; for reading&#xA;[https @ 0x12001c600] Opening &#x27;https://cdn.bitmovin.com/content/assets/art-of-motion-dash-hls-progressive/audio/1_stereo_128000/hls/segment_36.ts&#x27; for reading&#xA;[https @ 0x124038800] Opening &#x27;https://cdn.bitmovin.com/content/assets/art-of-motion-dash-hls-progressive/audio/1_stereo_128000/hls/segment_37.ts&#x27; for reading&#xA;[https @ 0x12001c600] Opening &#x27;https://cdn.bitmovin.com/content/assets/art-of-motion-dash-hls-progressive/audio/1_stereo_128000/hls/segment_38.ts&#x27; for reading&#xA;size=     486kB time=00:00:30.01 bitrate= 132.8kbits/s speed=10.7x    &#xA;video:0kB audio:477kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.018663%&#xA;

    &#xA;

    It doesn't do anything after this line via the lambda console logs :

    &#xA;

    [hls @ 0x72faa80] Opening &#x27;https://cdn.bitmovin.com/content/assets/art-of-motion-dash-hls-progressive/audio/1_stereo_128000/hls/segment_0.ts&#x27; for reading&#xA;

    &#xA;