Recherche avancée

Médias (1)

Mot : - Tags -/artwork

Autres articles (38)

  • MediaSPIP version 0.1 Beta

    16 avril 2011, par

    MediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Pour avoir une installation fonctionnelle, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

  • Mise à jour de la version 0.1 vers 0.2

    24 juin 2013, par

    Explications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
    Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...)

Sur d’autres sites (2697)

  • Developing A Shader-Based Video Codec

    22 juin 2013, par Multimedia Mike — Outlandish Brainstorms

    Early last month, this thing called ORBX.js was in the news. It ostensibly has something to do with streaming video and codec technology, which naturally catches my interest. The hype was kicked off by Mozilla honcho Brendan Eich when he posted an article asserting that HD video decoding could be entirely performed in JavaScript. We’ve seen this kind of thing before using Broadway– an H.264 decoder implemented entirely in JS. But that exposes some very obvious limitations (notably CPU usage).

    But this new video codec promises 1080p HD playback directly in JavaScript which is a lofty claim. How could it possibly do this ? I got the impression that performance was achieved using WebGL, an extension which allows JavaScript access to accelerated 3D graphics hardware. Browsing through the conversations surrounding the ORBX.js announcement, I found this confirmation from Eich himself :

    You’re right that WebGL does heavy lifting.

    As of this writing, ORBX.js remains some kind of private tech demo. If there were a public demo available, it would necessarily be easy to reverse engineer the downloadable JavaScript decoder.

    But the announcement was enough to make me wonder how it could be possible to create a video codec which effectively leverages 3D hardware.

    Prior Art
    In theorizing about this, it continually occurs to me that I can’t possibly be the first person to attempt to do this (or the ORBX.js people, for that matter). In googling on the matter, I found various forums and Q&A posts where people asked if it were possible to, e.g., accelerate JPEG decoding and presentation using 3D hardware, with no answers. I also found a blog post which describes a plan to use 3D hardware to accelerate VP8 video decoding. It was a project done under the banner of Google’s Summer of Code in 2011, though I’m not sure which open source group mentored the effort. The project did not end up producing the shader-based VP8 codec originally chartered but mentions that “The ‘client side’ of the VP8 VDPAU implementation is working and is currently being reviewed by the libvdpau maintainers.” I’m not sure what that means. Perhaps it includes modifications to the public API that supports VP8, but is waiting for the underlying hardware to actually implement VP8 decoding blocks in hardware.

    What’s So Hard About This ?
    Video decoding is a computationally intensive task. GPUs are known to be really awesome at chewing through computationally intensive tasks. So why aren’t GPUs a natural fit for decoding video codecs ?

    Generally, it boils down to parallelism, or lack of opportunities thereof. GPUs are really good at doing the exact same operations over lots of data at once. The problem is that decoding compressed video usually requires multiple phases that cannot be parallelized, and the individual phases often cannot be parallelized. In strictly mathematical terms, a compressed data stream will need to be decoded by applying a function f(x) over each data element, x0 .. xn. However, the function relies on having applied the function to the previous data element, i.e. :

    f(xn) = f(f(xn-1))
    

    What happens when you try to parallelize such an algorithm ? Temporal rifts in the space/time continuum, if you’re in a Star Trek episode. If you’re in the real world, you’ll get incorrect, unusuable data as the parallel computation is seeded with a bunch of invalid data at multiple points (which is illustrated in some of the pictures in the aforementioned blog post about accelerated VP8).

    Example : JPEG
    Let’s take a very general look at the various stages involved in decoding the ubiquitous JPEG format :


    High level JPEG decoding flow

    What are the opportunities to parallelize these various phases ?

    • Huffman decoding (run length decoding and zig-zag reordering is assumed to be rolled into this phase) : not many opportunities for parallelizing the various Huffman formats out there, including this one. Decoding most Huffman streams is necessarily a sequential operation. I once hypothesized that it would be possible to engineer a codec to achieve some parallelism during the entropy decoding phase, and later found that On2′s VP8 codec employs the scheme. However, such a scheme is unlikely to break down to such a fine level that WebGL would require.
    • Reverse DC prediction : JPEG — and many other codecs — doesn’t store full DC coefficients. It stores differences in successive DC coefficients. Reversing this process can’t be parallelized. See the discussion in the previous section.
    • Dequantize coefficients : This could be very parallelized. It should be noted that software decoders often don’t dequantize all coefficients. Many coefficients are 0 and it’s a waste of a multiplication operation to dequantize. Thus, this phase is sometimes rolled into the Huffman decoding phase.
    • Invert discrete cosine transform : This seems like it could be highly parallelizable. I will be exploring this further in this post.
    • Convert YUV -> RGB for final display : This is a well-established use case for 3D acceleration.

    Crash Course in 3D Shaders and Humility
    So I wanted to see if I could accelerate some parts of JPEG decoding using something called shaders. I made an effort to understand 3D programming and its associated math throughout the 1990s but 3D technology left me behind a very long time ago while I got mixed up in this multimedia stuff. So I plowed through a few books concerning WebGL (thanks to my new Safari Books Online subscription). After I learned enough about WebGL/JS to be dangerous and just enough about shader programming to be absolutely lethal, I set out to try my hand at optimizing IDCT using shaders.

    Here’s my extremely high level (and probably hopelessly naive) view of the modern GPU shader programming model :


    Basic WebGL rendering pipeline

    The WebGL program written in JavaScript drives the show. It sends a set of vertices into the WebGL system and each vertex is processed through a vertex shader. Then, each pixel that falls within a set of vertices is sent through a fragment shader to compute the final pixel attributes (R, G, B, and alpha value). Another consideration is textures : This is data that the program uploads to GPU memory which can be accessed programmatically by the shaders).

    These shaders (vertex and fragment) are key to the GPU’s programmability. How are they programmed ? Using a special C-like shading language. Thought I : “C-like language ? I know C ! I should be able to master this in short order !” So I charged forward with my assumptions and proceeded to get smacked down repeatedly by the overall programming paradigm. I came to recognize this as a variation of the scientific method : Develop a hypothesis– in my case, a mental model of how the system works ; develop an experiment (short program) to prove or disprove the model ; realize something fundamental that I was overlooking ; formulate new hypothesis and repeat.

    First Approach : Vertex Workhorse
    My first pitch goes like this :

    • Upload DCT coefficients to GPU memory in the form of textures
    • Program a vertex mesh that encapsulates 16×16 macroblocks
    • Distribute the IDCT effort among multiple vertex shaders
    • Pass transformed Y, U, and V blocks to fragment shader which will convert the samples to RGB

    So the idea is that decoding of 16×16 macroblocks is parallelized. A macroblock embodies 6 blocks :


    JPEG macroblocks

    It would be nice to process one of these 6 blocks in each vertex. But that means drawing a square with 6 vertices. How do you do that ? I eventually realized that drawing a square with 6 vertices is the recommended method for drawing a square on 3D hardware. Using 2 triangles, each with 3 vertices (0, 1, 2 ; 3, 4, 5) :


    2 triangles make a square

    A vertex shader knows which (x, y) coordinates it has been assigned, so it could figure out which sections of coefficients it needs to access within the textures. But how would a vertex shader know which of the 6 blocks it should process ? Solution : Misappropriate the vertex’s z coordinate. It’s not used for anything else in this case.

    So I set all of that up. Then I hit a new roadblock : How to get the reconstructed Y, U, and V samples transported to the fragment shader ? I have found that communicating between shaders is quite difficult. Texture memory ? WebGL doesn’t allow shaders to write back to texture memory ; shaders can only read it. The standard way to communicate data from a vertex shader to a fragment shader is to declare variables as “varying”. Up until this point, I knew about varying variables but there was something I didn’t quite understand about them and it nagged at me : If 3 different executions of a vertex shader set 3 different values to a varying variable, what value is passed to the fragment shader ?

    It turns out that the varying variable varies, which means that the GPU passes interpolated values to each fragment shader invocation. This completely destroys this idea.

    Second Idea : Vertex Workhorse, Take 2
    The revised pitch is to work around the interpolation issue by just having each vertex shader invocation performs all 6 block transforms. That seems like a lot of redundant. However, I figured out that I can draw a square with only 4 vertices by arranging them in an ‘N’ pattern and asking WebGL to draw a TRIANGLE_STRIP instead of TRIANGLES. Now it’s only doing the 4x the extra work, and not 6x. GPUs are supposed to be great at this type of work, so it shouldn’t matter, right ?

    I wired up an experiment and then ran into a new problem : While I was able to transform a block (or at least pretend to), and load up a varying array (that wouldn’t vary since all vertex shaders wrote the same values) to transmit to the fragment shader, the fragment shader can’t access specific values within the varying block. To clarify, a WebGL shader can use a constant value — or a value that can be evaluated as a constant at compile time — to index into arrays ; a WebGL shader can not compute an index into an array. Per my reading, this is a WebGL security consideration and the limitation may not be present in other OpenGL(-ES) implementations.

    Not Giving Up Yet : Choking The Fragment Shader
    You might want to be sitting down for this pitch :

    • Vertex shader only interpolates texture coordinates to transmit to fragment shader
    • Fragment shader performs IDCT for a single Y sample, U sample, and V sample
    • Fragment shader converts YUV -> RGB

    Seems straightforward enough. However, that step concerning IDCT for Y, U, and V entails a gargantuan number of operations. When computing the IDCT for an entire block of samples, it’s possible to leverage a lot of redundancy in the math which equates to far fewer overall operations. If you absolutely have to compute each sample individually, for an 8×8 block, that requires 64 multiplication/accumulation (MAC) operations per sample. For 3 color planes, and including a few extra multiplications involved in the RGB conversion, that tallies up to about 200 MACs per pixel. Then there’s the fact that this approach means a 4x redundant operations on the color planes.

    It’s crazy, but I just want to see if it can be done. My approach is to pre-compute a pile of IDCT constants in the JavaScript and transmit them to the fragment shader via uniform variables. For a first order optimization, the IDCT constants are formatted as 4-element vectors. This allows computing 16 dot products rather than 64 individual multiplication/addition operations. Ideally, GPU hardware executes the dot products faster (and there is also the possibility of lining these calculations up as matrices).

    I can report that I actually got a sample correctly transformed using this approach. Just one sample, through. Then I ran into some new problems :

    Problem #1 : Computing sample #1 vs. sample #0 requires a different table of 64 IDCT constants. Okay, so create a long table of 64 * 64 IDCT constants. However, this suffers from the same problem as seen in the previous approach : I can’t dynamically compute the index into this array. What’s the alternative ? Maintain 64 separate named arrays and implement 64 branches, when branching of any kind is ill-advised in shader programming to begin with ? I started to go down this path until I ran into…

    Problem #2 : Shaders can only be so large. 64 * 64 floats (4 bytes each) requires 16 kbytes of data and this well exceeds the amount of shader storage that I can assume is allowed. That brings this path of exploration to a screeching halt.

    Further Brainstorming
    I suppose I could forgo pre-computing the constants and directly compute the IDCT for each sample which would entail lots more multiplications as well as 128 cosine calculations per sample (384 considering all 3 color planes). I’m a little stuck with the transform idea right now. Maybe there are some other transforms I could try.

    Another idea would be vector quantization. What little ORBX.js literature is available indicates that there is a method to allow real-time streaming but that it requires GPU assistance to yield enough horsepower to make it feasible. When I think of such severe asymmetry between compression and decompression, my mind drifts towards VQ algorithms. As I come to understand the benefits and limitations of GPU acceleration, I think I can envision a way that something similar to SVQ1, with its copious, hierarchical vector tables stored as textures, could be implemented using shaders.

    So far, this all pertains to intra-coded video frames. What about opportunities for inter-coded frames ? The only approach that I can envision here is to use WebGL’s readPixels() function to fetch the rasterized frame out of the GPU, and then upload it again as a new texture which a new frame processing pipeline could reference. Whether this idea is plausible would require some profiling.

    Using interframes in such a manner seems to imply that the entire codec would need to operate in RGB space and not YUV.

    Conclusions
    The people behind ORBX.js have apparently figured out a way to create a shader-based video codec. I have yet to even begin to reason out a plausible approach. However, I’m glad I did this exercise since I have finally broken through my ignorance regarding modern GPU shader programming. It’s nice to have a topic like multimedia that allows me a jumping-off point to explore other areas.

  • opening jpg image after saving from ffmpeg not working

    30 mai 2013, par user2042152

    In my project I am saving videos, converting formats to .swf using ffmpeg. Converting and saving the videos is working fine, but I have a problem with creating the thumbnails. It saves a "picture.jpg" but there is no image. looking at the thumbnail its only got the normal photoviewer sign which is fine, but when I try to open the image it gives a message of
    Windows photo viewer : Windows photo viewer cant open this picture because the file appears to be damaged, corrupted, or is too large. (this image is 2.7MB) - Photos taken from my camera is about 5MB and that opens.

    PictureViewer : couldn't display "image.jpg" because a suitable graphics importer could not be found.

    Paint : Paint cannot read this file. This is not a valid bitmap file or its format is currently not supported.
    The images won't open in any I done to save the image :

       protected void btnUploadVideo_Click(object sender, EventArgs e)
       {
           string dtMonth = DateTime.Now.ToString("MMM");
           string dtYear = DateTime.Now.ToString("yyyy");
           lblMsg.Visible = false;

           lblMsg.Visible = true;

           // Before attempting to save the file, verify
           // that the FileUpload control contains a file.
           if (fuPath.HasFile)
           {
               // Get the size in bytes of the file to upload.
               int fileSize = fuPath.PostedFile.ContentLength;

               // Allow only files less than 2,100,000 bytes (approximately 2 MB) to be uploaded.
               if (fileSize < 10497717)
               {
                   // Call a helper method routine to save the file.
                   SaveFile2();
               }
           }
           else
               // Notify the user that a file was not uploaded.
               lblMsg.Text = "You did not specify a file to upload.";
       }

       private void SaveFile2()
       {
           string dtMonth = DateTime.Now.ToString("MMM");
           string dtYear = DateTime.Now.ToString("yyyy");

           if (fuPath != null || fuPath.PostedFile != null)
           {
               postedfilename = fuPath.PostedFile.FileName;
               SavePath = Server.MapPath("~\\Video\\");
               string NewFName = postedfilename;
               NewFName = NewFName.Substring(NewFName.LastIndexOf("\\") + 1, NewFName.Length - NewFName.LastIndexOf(".")) + "." + NewFName.Substring(NewFName.LastIndexOf(".") + 1);
               Filenamewithpath = SavePath + NewFName;
               string outputPath = Server.MapPath("~\\uploads\\" + dtYear + "\\" + dtMonth + "\\SWF\\");
               CreateDirectoryIfNotExists(SavePath);
               CreateDirectoryIfNotExists(outputPath);

               //Save The file
               fuPath.PostedFile.SaveAs(Filenamewithpath);

               //Start Converting
               string inputfile, outputfile, filargs;
               string withoutext;

               //Get the file name without Extension
               withoutext = Path.GetFileNameWithoutExtension(Filenamewithpath);

               //Input file path of uploaded image
               inputfile = SavePath + NewFName;

               //output file format in swf

               outputfile = outputPath + withoutext + ".swf";
               Session["outputfile"] = withoutext + ".swf";
               //file orguments for FFMEPG

               // Create the path and file name to check for duplicates.
               string pathToCheck = outputfile;

               // Create a temporary file name to use for checking duplicates.
               string tempfileName = "";

               // Check to see if a file already exists with the
               // same name as the file to upload.        
               if (System.IO.File.Exists(pathToCheck))
               {
                   int counter = 2;
                   while (System.IO.File.Exists(pathToCheck))
                   {
                       // if a file with this name already exists,
                       // prefix the filename with a number.
                       tempfileName = outputPath + counter.ToString() + withoutext + ".swf";
                       pathToCheck = tempfileName;
                       counter++;
                   }

                   outputfile = tempfileName;
                   // Notify the user that the file name was changed.
                   lblMsg.Text = "A file with the same name already exists." +
                       "<br />Your file was saved as " + counter.ToString() + withoutext + ".swf";
               }

               filargs = "-i " + inputfile + " -ar 22050 " + outputfile;

               string spath;
               spath = Server.MapPath(".");
               Process proc;
               proc = new Process();
               proc.StartInfo.FileName = spath + "\\ffmpeg\\ffmpeg.exe";
               proc.StartInfo.Arguments = filargs;
               proc.StartInfo.UseShellExecute = false;
               proc.StartInfo.CreateNoWindow = false;
               proc.StartInfo.RedirectStandardOutput = false;
               try
               {

                   proc.Start();
                   fuPath.PostedFile.SaveAs(outputfile);
               }
               catch (Exception ex)
               {
                   Response.Write(ex.Message);
               }
               proc.WaitForExit();
               proc.Close();

               //Create Thumbs

               string thumbPath, thumbName;
               string thumbargs;

               thumbPath = Server.MapPath("~\\uploads\\" + dtYear + "\\" + dtMonth + "\\Thumb\\");
               CreateDirectoryIfNotExists(thumbPath);

               thumbName = thumbPath + withoutext + ".jpg";

               // Create the path and file name to check for duplicates.
               string thumbPathToCheck = thumbName;

               // Create a temporary file name to use for checking duplicates.
               string thumbTempfileName = "";

               // Check to see if a file already exists with the
               // same name as the file to upload.        
               if (System.IO.File.Exists(thumbPathToCheck))
               {
                   int counter = 2;
                   while (System.IO.File.Exists(thumbPathToCheck))
                   {
                       // if a file with this name already exists,
                       // prefix the filename with a number.
                       thumbTempfileName = thumbPath + counter.ToString() + withoutext + ".jpg";
                       thumbPathToCheck = thumbTempfileName;
                       counter++;
                   }

                   thumbName = thumbTempfileName;
                   // Notify the user that the file name was changed.
                   lblMsg.Text = "A file with the same name already exists." +
                       "<br />Your file was saved as " + counter.ToString() + withoutext + ".jpg";
               }

               //thumbargs = "-i " + inputfile + " -an -ss 00:00:03 -s 120×90 -vframes 1 -f mjpeg " + thumbName;
              // thumbargs = "-i " + inputfile + "-f image2 -ss 1.000 -vframes 1 " + thumbName;
               thumbargs = "-i " + inputfile + " -vframes 1 -ss 00:00:10 -s 150x150 " + thumbName;

               //  thumbargs = "ffmpeg -i" + inputfile + " -ss 0:00:01.000 -sameq -vframes 1 " + withoutext + ".jpg";
               //  thumbargs = "-i " + inputfile + " -vframes 1 -ss 00:00:07 -s 150x150 " + thumbName;
               Process thumbproc = new Process();
               thumbproc.StartInfo.FileName = spath + "\\ffmpeg\\ffmpeg.exe";
               thumbproc.StartInfo.Arguments = thumbargs;
               thumbproc.StartInfo.UseShellExecute = false;
               thumbproc.StartInfo.CreateNoWindow = true;
               thumbproc.StartInfo.RedirectStandardOutput = false;

               string data = "";                

               try
               {
                   fuPath.PostedFile.SaveAs(thumbName);
                   thumbproc.Start();
               }
               catch (Exception ex)
               {
                   Response.Write(ex.Message);
               }

               thumbproc.WaitForExit();
               thumbproc.Close();
               File.Delete(inputfile);
               lblMsg.Text = "Video Uploaded Successfully";
               hyp.Visible = true;
               hyp.NavigateUrl = "WatchVideo.aspx";

               SaveToDB(outputfile, thumbName);
           }
       }

    EDIT :
    If it is the thumbargs, I have tried a few ways, but with no success :

        //thumbargs = "-i " + inputfile + " -an -ss 00:00:03 -s 120×90 -vframes 1 -f mjpeg " + thumbName;
        // thumbargs = "-i " + inputfile + "-f image2 -ss 1.000 -vframes 1 " + thumbName;
         thumbargs = "-i " + inputfile + " -vframes 1 -ss 00:00:10 -s 150x150 " + thumbName;
        //  thumbargs = "ffmpeg -i" + inputfile + " -ss 0:00:01.000 -sameq -vframes 1 " + withoutext + ".jpg";

    This is how it looks when saved, but can't open....
    enter image description here

    EDIT :

    I tried adding the argument to the command prompt to see if it works there but it gave me a message of : [NULL @ 000000000025f7a0] Unable to find a suitable output format for 'vframes'
    vframes : invalid argument
    The line I used :

       ffmpeg -i VID2012.3GP vframes 1 VID2012.jpg

    If it is that it is not set correctly in IIS how do I set it ?

    EDIT :
    I changed a bit of my code. Debugging through my code there is no exception that is thrown, but if I point the mouse over the process (after it started) it "shows an exception of type System.InvalidOperationException"

       thumbargs = "-i " + postedfilename + " vframes 1" + thumbName;
               ProcessStartInfo thumbProcstartIfo = new ProcessStartInfo();
               thumbProcstartIfo.FileName = @"\ffmpeg\ffmpeg.exe";
               thumbProcstartIfo.Arguments = thumbargs;
               thumbProcstartIfo.UseShellExecute = false;
               thumbProcstartIfo.CreateNoWindow = true;
               thumbProcstartIfo.RedirectStandardOutput = false;

               try
               {
                   using (var process = new Process())
                   {
                       process.StartInfo = thumbProcstartIfo;
                       process.Start();
                       process.WaitForExit();
                   }
               }
               catch (InvalidOperationException ex)
               {
                   lblMsg.Text = ex.ToString();
               }
  • Jerky Video from Jpgs encoded with ffmpeg [closed]

    16 février 2012, par Glstunna

    I have a bunch of jpg snapshots taken from a 3d program at perfect time frames.
    But when I have the videos compiled/encoded into a video by ffmpeg, I notice an annoying jerkiness. The jerkiness is not that pronounced, but enough to be annoying, especially during slow camera pans.

    This is what I use :

    "ffmpeg-lgpl.exe" -y  -r 29.97 -i "C:\vidsnaps\vid_%d.jpg" -b 8000k "C:\Users\peki.ICE\Documents\macbattle.mpg"

    I chose mpg (mpeg1video) because that is the format readily available in all end-user systems like XP without downloading extra codecs. The video images are guaranteed to match that framerate 29.97 as the camera in the 3d program pretty much waits for each frame to be dumped to file before moving to the next one.

    What other fancy ffmpeg flags do I have to set for this thing to stop being jerky.

    EDIT : see video example here and notice the light jerk/stuttering.
    http://www.youtube.com/watch?v=g-slsJBZA2w&feature=youtu.be