Recherche avancée

Médias (91)

Autres articles (102)

  • Contribute to a better visual interface

    13 avril 2011

    MediaSPIP is based on a system of themes and templates. Templates define the placement of information on the page, and can be adapted to a wide range of uses. Themes define the overall graphic appearance of the site.
    Anyone can submit a new graphic theme or template and make it available to the MediaSPIP community.

  • Configuration spécifique pour PHP5

    4 février 2011, par

    PHP5 est obligatoire, vous pouvez l’installer en suivant ce tutoriel spécifique.
    Il est recommandé dans un premier temps de désactiver le safe_mode, cependant, s’il est correctement configuré et que les binaires nécessaires sont accessibles, MediaSPIP devrait fonctionner correctement avec le safe_mode activé.
    Modules spécifiques
    Il est nécessaire d’installer certains modules PHP spécifiques, via le gestionnaire de paquet de votre distribution ou manuellement : php5-mysql pour la connectivité avec la (...)

  • Multilang : améliorer l’interface pour les blocs multilingues

    18 février 2011, par

    Multilang est un plugin supplémentaire qui n’est pas activé par défaut lors de l’initialisation de MediaSPIP.
    Après son activation, une préconfiguration est mise en place automatiquement par MediaSPIP init permettant à la nouvelle fonctionnalité d’être automatiquement opérationnelle. Il n’est donc pas obligatoire de passer par une étape de configuration pour cela.

Sur d’autres sites (8613)

  • Streamimg video files using EmbedIO for the server and with live transcoding C#

    24 mai 2020, par Efrain Bastidas Berrios

    I'm using EmbedIO to create a simple web server to stream some local video files over the network
by simply typing an url like this one : http://192.168.1.101:9696/videos?seconds=0&file=F:\Videos\MyVideo.mp4

    



    The code for the server is the following :

    



    static void StartServer(params string[] args)
{
    var url = GetIpAddress();
    if (args.Length > 0)
        url = args[0];
    var server = new WebServer(o => o
            .WithUrlPrefix(url)
            .WithMode(HttpListenerMode.EmbedIO))
            .WithLocalSessionManager()
            .WithModule(new VideoModule("/videos"))
            .WithModule(new ActionModule("/", HttpVerbs.Any, ctx =>
            {
                return ctx.SendDataAsync(new { Message = "Server initialized" });
            }));
    server.RunAsync();

    var browser = new Process()
    {
        StartInfo = new ProcessStartInfo(url) { UseShellExecute = true }
    };
    browser.Start();
    Console.ReadKey(true);
} 


    



    And the code for the VideoModule is the following :

    



        public class VideoModule : WebModuleBase
    {
        private readonly Process _transcodeProcess;

        public VideoModule(string baseRoute)
            : base(baseRoute)
        {
            _transcodeProcess = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName = @"C:\ffmpeg\ffmpeg.exe",
                    UseShellExecute = false,
                    LoadUserProfile = false,
                    RedirectStandardInput = true,
                    RedirectStandardOutput = true,
                    CreateNoWindow = false
                }
            };
        }

        public override bool IsFinalHandler => false;

        protected override Task OnRequestAsync(IHttpContext context)
        {
            var path = context.RequestedPath;
            var verb = context.Request.HttpVerb;
            var query = context.GetRequestQueryData();
            var allowedQueryParametes = new[]
            {
                "file",
                "seconds"
            };
            if (query.Count == 0 || !query.AllKeys.All(q => allowedQueryParametes.Contains(q)))
            {
                context.SetHandled();
                return Task.CompletedTask;
            }
            try
            {
                string filepath = query["file"];
                if (!File.Exists(filepath))
                {
                    context.Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest;
                    return Task.CompletedTask;
                }

                double duration = GetFileDuration(filepath);

                var file = new FileInfo(filepath);
                context.Response.Headers.Add("Content-Duration", $"{Math.Round(duration, 2)}");
                context.Response.ContentType = context.GetMimeType(file.Extension);                     
                _transcodeProcess.StartInfo.Arguments = @$"-v quiet -y -i ""{filepath}"" -crf 28 -preset ultrafast -vcodec h264 -acodec aac -b:a 128k -movflags frag_keyframe+faststart -f mp4 -";
                _transcodeProcess.Start();

                var stream = _transcodeProcess.StandardOutput.BaseStream as FileStream;
                return stream.CopyToAsync(context.Response.OutputStream);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            finally
            {
                context.SetHandled();
            }
            return Task.CompletedTask;
        }

        private static double GetFileDuration(string filepath)
        {
            var p = new Process
            {
                EnableRaisingEvents = true,
                StartInfo = new ProcessStartInfo
                {
                    FileName = @"C:\ffmpeg\ffprobe.exe",
                    UseShellExecute = false,
                    LoadUserProfile = false,
                    RedirectStandardInput = true,
                    RedirectStandardOutput = true,
                    RedirectStandardError = true,
                    CreateNoWindow = false
                }
            };
            p.StartInfo.Arguments = @$"-v quiet -i ""{filepath}"" -show_entries format=duration -of csv=p=0";
            p.Start();
            p.WaitForExit();
            string stringDuration = p.StandardOutput.ReadToEnd();
            return double.Parse(stringDuration.Replace(Environment.NewLine, string.Empty));
        }
}


    



    As you can see, I'm using ffmpeg because i need to transcode my video files.
Currently this works (At least in Chrome) the problem is that i can't seek the video, and
I assume that's because I'm returning a 200 status code (its the default) instead of a 206 Partial Content code.

    



    So, i thought, that if i want to return chunks of the video, i needed to pass some extra arguments to ffmpeg in order to transcode only a portion of the file, so i created a variable _seconds which will hold the current position and also added a -t 60 to only process 60 seconds

    



    So, with those changes, the OnRequestAsync now looks like this :

    



        protected override Task OnRequestAsync(IHttpContext context)
    {
        var path = context.RequestedPath;
        var verb = context.Request.HttpVerb;
        var query = context.GetRequestQueryData();
        var allowedQueryParametes = new[]
        {
            "file",
            "seconds"
        };
        if (query.Count == 0 || !query.AllKeys.All(q => allowedQueryParametes.Contains(q)))
        {
            context.SetHandled();
            return Task.CompletedTask;
        }

        try
        {
            string filepath = query["file"];
            if (!File.Exists(filepath))
            {
                context.Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest;
                return Task.CompletedTask;
            }

            double duration = GetFileDuration(filepath);

            var file = new FileInfo(filepath);
            context.Response.Headers.Add("Accept-Ranges", "bytes");
            context.Response.Headers.Add("Content-Duration", $"{Math.Round(duration, 2)}");
            context.Response.ContentType = context.GetMimeType(file.Extension);
            context.Response.DisableCaching();
            if (context.Request.Headers.ContainsKey("Range"))
            {
                string[] range = context.Request.Headers["Range"].Split(new char[] { '=', '-' });
                long start  = long.Parse(range[1]);
                if (start != 0)
                {
                    _seconds += 60;
                }

                _transcodeProcess.StartInfo.Arguments = @$"-v quiet -ss {_seconds} -y -i ""{filepath}"" -t 60 -crf 28 -preset ultrafast -vcodec h264 -acodec aac -b:a 128k -movflags frag_keyframe+faststart -f mp4 -";
                _transcodeProcess.Start();

                var stream = _transcodeProcess.StandardOutput.BaseStream as FileStream;
                var memStream = new MemoryStream();
                stream.CopyTo(memStream);
                _transcodeProcess.WaitForExit();
                context.Response.StatusCode = 206;
                context.Response.ContentLength64 = memStream.Length;
                var responseRange = string.Format("bytes {0}-{1}/*", start, memStream.Length - 1);

                context.Response.Headers.Add("Content-Range", responseRange);
                memStream.Position = 0;
                return memStream.CopyToAsync(context.Response.OutputStream);
            }
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
        }
        finally
        {
            context.SetHandled();
        }
        return Task.CompletedTask;
    }


    



    The problem is that it works for the first 60 seconds of the video, but then the Chrome video player stops. For some reason it's not asking for the next chunk and I don't know why (I thought that this will be automatically handled since I'm returning back a 206 code)

    



    Any help would be appreciated, thanks !

    


  • Automating youtube-dl to download videos from a Vlive Channel [on hold]

    17 août 2019, par yrcje

    I would like to automate youtube-dl to download any new live streams from a Vlive page, as youtube-dl supports vlive downloading, I would like to ask if it’s possible for me to use a bat to automate it ? As sometimes the replay just gets cut and I’d like to avoid that if possible. I tried looking into phyton as well but I can’t find any phyton related things that is related to vlive as most of them are just youtube.

    Would appreciate any help if possible.

  • streaming on youtube with ffmpeg [on hold]

    20 septembre 2017, par Bojan Dedić

    I found this code on internet and it works great for streaming live videos on youtube. Only problem is that I need to stream every video which is inside folder "videos", not only just one.

    VBR="2500k"                          
    sortie
    FPS="30"              
    QUAL="medium"                                  
    YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2"  

    SOURCE="video.mp4"    
    KEY="..."

    ffmpeg \
      -i "$SOURCE" -deinterlace \
      -vcodec libx264 -pix_fmt yuv420p -preset $QUAL -r $FPS -g $(($FPS * 2)) -b:v $VBR \
      -acodec libmp3lame -ar 44100 -threads 6 -qscale 3 -b:a 712000 -bufsize 512k \
      -f flv "$YOUTUBE_URL/$KEY"

    This is what i came up with :

    for f in *.mp4; do
       ffmpeg \
           -i "$f" -deinterlace \
           -vcodec libx264 -pix_fmt yuv420p -preset $QUAL -r $FPS -g $(($FPS * 2)) -b:v $VBR \
           -acodec libmp3lame -ar 44100 -threads 6 -qscale 3 -b:a 712000 -bufsize 512k \
           -f flv "$YOUTUBE_URL/$KEY"
    done