Recherche avancée

Médias (2)

Mot : - Tags -/map

Autres articles (68)

  • HTML5 audio and video support

    13 avril 2011, par

    MediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
    The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
    For older browsers the Flowplayer flash fallback is used.
    MediaSPIP allows for media playback on major mobile platforms with the above (...)

  • Support audio et vidéo HTML5

    10 avril 2011

    MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
    Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
    Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
    Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)

  • 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 (...)

Sur d’autres sites (8307)

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

    


  • FFMPEG to fluent ffmpeg [on hold]

    16 janvier 2018, par Minh

    I use ffmpeg command on VPS but I want cover to github . Help me
    This is code

    ffmpeg - re - i http: //storage.livefb.com.vn/assets/video/video_307_1516075122469280.mp4 -i assets/bg/13.png -i assets/logo.png -filter_complex "[0:v][1:v] overlay=x=4:y=H-h:enable='between(t,0,t)' [tmp]; [tmp][2:v] overlay=x=14:y=H-h-10:enable='between(t,0,t)',drawtext=fontfile=assets/thanh.ttf:y=h-60:x=158:text='TDL AUTOFB INBOXFB LIVEFB
     0965367062 MINH THU ':fontcolor=white:fontsize=36,drawbox=enable='
    between(t, 2, 10)
    ':y=ih-ih/2:color=black@0.8:width=iw:height=50:t=max,drawtext=enable='
    between(t, 2, 10)
    ':fontfile=assets/thanh.ttf:y=h-h/2+10:x=(w-text_w)/2:text='
    được phát bởi livefb liên hệ minh thư để được hỗ trợ ':fontcolor=white:fontsize=30" -vcodec libx264 -pix_fmt yuv420p -r 30 -g 60 -b:v 1400k -profile:v main -level 3.1 -acodec libmp3lame -b:a 128k -ar 44100 -metadata title="" -metadata artist="" -metadata album_artist="" -metadata album="" -metadata date="" -metadata track="" -metadata genre="" -metadata publisher="" -metadata encoded_by="" -metadata copyright="" -metadata composer="" -metadata performer="" -metadata TIT1="" -metadata TIT3="" -metadata disc="" -metadata TKEY="" -metadata TBPM="" -metadata language="eng" -metadata encoder="" -threads 0 -preset superfast -f flv "rtmp://live-api.facebook.com:80/rtmp/187884241800146?ds=1&a=ATgAYCPa1TJeWa2t"