Recherche avancée

Médias (1)

Mot : - Tags -/MediaSPIP 0.2

Autres articles (76)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • Creating farms of unique websites

    13 avril 2011, par

    MediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
    This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...)

  • Le profil des utilisateurs

    12 avril 2011, par

    Chaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
    L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)

Sur d’autres sites (4806)

  • ffmpeg - Making a Clean WAV file

    24 septembre 2016, par Edward

    I’m looking to batch convert a number of files to audio files using ffmpeg for a game called Star Wars: Jedi Knight: Dark Forces II. The problem I’m having is that ffmpeg seems to be doing something that does so that Jedi Knight can’t play the sound file.

    Jedi Knight accepts plain old PCM WAV files of various ranges, from 5khz to 96khz, 8 and 16 bit, mono and stereo. This sounds plain and simple. Except for that if one were to create a WAV file using MS Sound Recorder, Jedi Knight could not play it. Speculation was that it added something extra to header or something. But it can play a WAV file created by Audacity, GoldWave or ModPlug Tracker to name a few.

    So why not ffmpeg ? Am I using the wrong codec or params ? I took an original sound file from the game and performed the following :

    ffmpeg -i "orig_thrmlpu2.wav" -f wav -acodec pcm_s16le -ar 22050 -ac 1 "ffmpeg_thrmlpu2.wav"

    The ffmpeg version does not play in the game. ffprobe shows that the ffmpeg version has some Metadata which the original doesn’t have. What params should I use to try and get the same WAV format as the original ? Mind you, -ar, -ac and bits aren’t the important parts.

    Here are the files for you to examine : http://www.edwardleuf.org/Games/JK/thrmlpu2.zip

  • C++ h264 ffmpeg/libav encode/decode(lossless) issues

    1er février 2017, par MrSmith

    Insights to encode/decode video with ffmpeg h264 (lossless)

    So I got something working on the encoding part, encode an avi in 264 however VLC wont play it, however Totem will.
    Decoding the same file proves troublesome. (I want the exact same data/frame going in as going out), I get these ;

    saving frame   5
    Video decoding
    [h264 @ 0x1d19880] decode_slice_header error
    frame :6
    saving frame   6
    Video decoding
    [h264 @ 0x1d19880] error while decoding MB 15 7, bytestream -27
    [h264 @ 0x1d19880] concealing 194 DC, 194 AC, 194 MV errors in I frame
    frame :7
    saving frame   7
    Video decoding
    [h264 @ 0x1d19880] decode_slice_header error

    and ultimatly this

    [H264 Decoder @ 0x7f1320766040] frame :11
    Broken frame packetizing
    [h264 @ 0x1d19880] SPS changed in the middle of the frame
    [h264 @ 0x1d19880] decode_slice_header error
    [h264 @ 0x1d19880] no frame!
    Error while decoding frame 11

    GAME OVER.

    Now I suspect that I have to go back to 1. the encoding part, there is problary a good reason VLC wont play it !

    I encode like this.

    void encode(char *Y,char *U,char *V){
    av_init_packet(&pkt);
    pkt.data = NULL;    // packet data will be allocated by the encoder
    pkt.size = 0;
    fflush(stdout);

    frame->data[0] = (uint8_t*)Y;
    frame->data[1] = (uint8_t*)U;
    frame->data[2] = (uint8_t*)V;
    frame->pts = ++i;

    ret = avcodec_encode_video2(c, &pkt, frame, &got_output);
    if (ret < 0) {
       fprintf(stderr, "Error encoding frame\n");
       exit (EXIT_FAILURE);
    }
    if (got_output) {
       printf("Write frame %3d (size=%5d)\n", i, pkt.size);
       fwrite(pkt.data, 1, pkt.size, f);
       av_free_packet(&pkt);
    }
    }

    And the codec is setup like this :

    AVCodecID dasd = AV_CODEC_ID_H264;
    codec = avcodec_find_encoder(dasd);
    c = avcodec_alloc_context3(codec);
    c->bit_rate = 400000;
    c->width = 320;
    c->height = 240;
    c->time_base= (AVRational){1,25};
    c->gop_size = 10;
    c->max_b_frames=1;
    c->pix_fmt = AV_PIX_FMT_YUV420P;
    av_opt_set(c->priv_data, "preset", "slow", 0);
    avcodec_open2(c, codec, NULL);

    Since I am going for lossless i am not dealing with delayed frames(is this a correct assumption ?)
    I may not actually be encoding lossless, it seems like I may have to go with something like

    AVDictionary *param;
    av_dict_set(&param, "qp", "0", 0);

    And then open...

    So I guess me questions is these :

    • What are the correct codec params for lossless encoding (and advice if h264 is a terrible idea in this regard).
    • Do I need to handle delayed frames when going for lossless ?
    • Why is VLC mad at me ?

    Thanks.

  • How can i save the preview video in pictureBox1 to a avi/mp4 video file on hard disk using directshow ?

    10 avril 2016, par benny dayag

    The first problem maybe it’s not a problem but for some reason the video preview in the pictureBox1 is working but the frame rate seems not right. I can’t figure how to set/change it. The preview video seems a bit dart to the eyes not flickering but not moving smooth.

    The main problem is how to save the preview in the pictureBox1 or directly the streaming to a video file ? The MediaSubtype i’m getting is h.264

    The video is from the device legato game capture.

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using DirectShowLib;
    using DirectShowLib.BDA;
    using DirectShowLib.DES;
    using DirectShowLib.DMO;
    using DirectShowLib.Dvd;
    using DirectShowLib.MultimediaStreaming;
    using DirectShowLib.SBE;
    using System.Runtime.InteropServices;
    using System.Management;
    using System.IO;
    using System.Drawing.Imaging;


    namespace Youtube_Manager
    {

       public partial class Elgato_Video_Capture : Form
       {


           IFileSinkFilter sink;

           IFilterGraph2 graph;
           ICaptureGraphBuilder2 captureGraph;
           System.Drawing.Size videoSize;

           string error = "";
           List devices = new List();
           IMediaControl mediaControl;

           public Elgato_Video_Capture()
           {
               InitializeComponent();



               if (comboBox1.Items.Count == 0)
               {
                   for (int xx = 1; xx <= 8; xx++)
                   {
                       comboBox1.Items.Add(xx);
                   }
               }

               InitDevice();
               timer1.Start();
           }

           IBaseFilter smartTeeFilter;
           IPin outPin;
           IPin inPin;
           private void InitDevice()
           {
               try
               {
                   //Set the video size to use for capture and recording
                   videoSize = new Size(827, 505);//1280, 720);

                   //Initialize filter graph and capture graph
                   graph = (IFilterGraph2)new FilterGraph();
                   captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2();
                   captureGraph.SetFiltergraph(graph);
                   //Create filter for Elgato
                   Guid elgatoGuid = new Guid("39F50F4C-99E1-464A-B6F9-D605B4FB5918");
                   Type comType = Type.GetTypeFromCLSID(elgatoGuid);
                   IBaseFilter  elgatoFilter = (IBaseFilter)Activator.CreateInstance(comType);
                   graph.AddFilter(elgatoFilter, "Elgato Video Capture Filter");

                   //Create smart tee filter, add to graph, connect Elgato's video out to smart tee in
                   smartTeeFilter = (IBaseFilter)new SmartTee();

                   graph.AddFilter(smartTeeFilter, "Smart Tee");
                   outPin = GetPin(elgatoFilter, "Video");
                   inPin = GetPin(smartTeeFilter, "Input");
                   SetAndGetAllAvailableResolution(outPin);
                   graph.Connect(outPin, inPin);


                   //Create video renderer filter, add it to graph, connect smartTee Preview pin to video renderer's input pin
                   IBaseFilter videoRendererFilter = (IBaseFilter)new VideoRenderer();

                   graph.AddFilter(videoRendererFilter, "Video Renderer");
                   outPin = GetPin(smartTeeFilter, "Preview");

                   inPin = GetPin(videoRendererFilter, "Input");
                   graph.Connect(outPin, inPin);

                  // int hr = graph.Connect(outPin, inPin); ;
                  // DsError.ThrowExceptionForHR(hr);

                   captureGraph.SetOutputFileName(MediaSubType.Avi, @"e:\screenshots\test1.mp4", out smartTeeFilter, out sink);

                   //Render stream from video renderer
                   captureGraph.RenderStream(PinCategory.VideoPort, MediaType.Video, videoRendererFilter, null, null);
                   //Set the video preview to be the videoFeed panel
                   IVideoWindow vw = (IVideoWindow)graph;
                   vw.put_Owner(pictureBox1.Handle);
                   vw.put_MessageDrain(this.Handle);
                   vw.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings | WindowStyle.ClipChildren);
                   vw.SetWindowPosition(0, 0, 827, 505);

                   //Start the preview
                   mediaControl = graph as IMediaControl;
                   mediaControl.Run();
               }
               catch (Exception err)
               {
                   error = err.ToString();
               }
           }

            IPin GetPin(IBaseFilter filter, string pinname)
           {
               IEnumPins epins;
               int hr = filter.EnumPins(out epins);
               checkHR(hr, "Can't enumerate pins");
               IntPtr fetched = Marshal.AllocCoTaskMem(4);
               IPin[] pins = new IPin[1];
               while (epins.Next(1, pins, fetched) == 0)
               {
                   PinInfo pinfo;
                   pins[0].QueryPinInfo(out pinfo);
                   bool found = (pinfo.name == pinname);
                   DsUtils.FreePinInfo(pinfo);
                   if (found)
                       return pins[0];
               }
               checkHR(-1, "Pin not found");
               return null;
           }

           public  void checkHR(int hr, string msg)
           {
               if (hr < 0)
               {
                   MessageBox.Show(msg);
                   DsError.ThrowExceptionForHR(hr);
               }



           }

           public void SetAndGetAllAvailableResolution(IPin VideoOutPin)
           {
               int hr = 0;
               IAMStreamConfig streamConfig = (IAMStreamConfig)VideoOutPin;
               AMMediaType searchmedia;
               AMMediaType CorectvidFormat = new AMMediaType();
               IntPtr ptr;
               int piCount, piSize;
               hr = streamConfig.GetNumberOfCapabilities(out piCount, out piSize);
               ptr = Marshal.AllocCoTaskMem(piSize);
               for (int i = 0; i < piCount; i++)
               {
                   hr = streamConfig.GetStreamCaps(i, out searchmedia, ptr);
                   VideoInfoHeader v = new VideoInfoHeader();

                   Marshal.PtrToStructure(searchmedia.formatPtr, v);
                   if (i == 2)// 4
                   {
                       CorectvidFormat = searchmedia;
                   }
               }
               hr = streamConfig.SetFormat(CorectvidFormat);

               IntPtr pmt = IntPtr.Zero;
               AMMediaType mediaType = new AMMediaType();
               IAMStreamConfig streamConfig1 = (IAMStreamConfig)VideoOutPin;
               hr = streamConfig1.GetFormat(out mediaType);
               BitmapInfoHeader bmpih = new BitmapInfoHeader();
               Marshal.PtrToStructure(mediaType.formatPtr, bmpih);
           }
     }
    }

    I tried to use this line to save the video to a video file but the video file on hard disk is 0 KB so I guess it’s a wrong way to do it.
    I also thought somehow to save each frame(bitmap image) from the pictureBox1 to the hard disk or maybe the memory and use ffmpeg to create/build a video file in real time from each saved frame but I can’t get/save the images(frames) from the pictureBox1 for some reason.

    I tried using DrawToBitmap but all the frames(bitmaps on hard disk saved) are empty size 2.24 KB

    captureGraph.SetOutputFileName(MediaSubType.Avi, @"e:\screenshots\test1.mp4", out smartTeeFilter, out sink);

    This is how I tried to get the frames from the pictureBox1

    public static int counter = 0;
           private void timer1_Tick(object sender, EventArgs e)
           {
               counter++;
               Bitmap bmp = new Bitmap(pictureBox1.ClientSize.Width, pictureBox1.ClientSize.Height);
               pictureBox1.DrawToBitmap(bmp, pictureBox1.ClientRectangle);
               bmp.Save(@"e:\screenshots\" + "screenshot" + counter.ToString("D6") + ".bmp");
               bmp.Dispose();
           }