Recherche avancée

Médias (91)

Autres articles (82)

  • Amélioration de la version de base

    13 septembre 2013

    Jolie sélection multiple
    Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
    Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...)

  • Menus personnalisés

    14 novembre 2010, par

    MediaSPIP utilise le plugin Menus pour gérer plusieurs menus configurables pour la navigation.
    Cela permet de laisser aux administrateurs de canaux la possibilité de configurer finement ces menus.
    Menus créés à l’initialisation du site
    Par défaut trois menus sont créés automatiquement à l’initialisation du site : Le menu principal ; Identifiant : barrenav ; Ce menu s’insère en général en haut de la page après le bloc d’entête, son identifiant le rend compatible avec les squelettes basés sur Zpip ; (...)

  • Déploiements possibles

    31 janvier 2010, par

    Deux types de déploiements sont envisageable dépendant de deux aspects : La méthode d’installation envisagée (en standalone ou en ferme) ; Le nombre d’encodages journaliers et la fréquentation envisagés ;
    L’encodage de vidéos est un processus lourd consommant énormément de ressources système (CPU et RAM), il est nécessaire de prendre tout cela en considération. Ce système n’est donc possible que sur un ou plusieurs serveurs dédiés.
    Version mono serveur
    La version mono serveur consiste à n’utiliser qu’une (...)

Sur d’autres sites (5970)

  • PHP FFmpeg video aspect ratio problem [SOLVED]

    29 août 2011, par Herr Kaleun

    i compiled the new version of FFMPEG and the padding commands have been deprecated.
    As i try to get familiar with the new -vf pad= commands, i want to ask, how can i
    convert a video without changing it's aspect ratio.

    I've checked numerous solutions from stackoverflow, nothing seemed to work.
    Can someone, please post a working PHP example or cmd line. I would be VERY happy.

    Please note that the videos in question, could be 4:3 and also be 16:9

    Let's say, i convert a 16:9 video to 640x480 format. It will need some bars at
    the top and at the bottom. That is what i want to do.

    Thanks

    EDIT :
    I solved the problem on my own. The FFmpeg documentation is a little bit weird so
    you have to experiment yourself a little bit.
    The padding formula is like :

       $pad_horizontal = $target_width     + $pad_left + $pad_right;
       $pad_vertical   = $target_height;
       // blah
       $command .= " -vf pad=$pad_horizontal:$pad_vertical:". $pad_left .":". $pad_top  .":black";

    Pay special attention at the $pad_vertical part since the paddings there are better
    not added so that the padding calculation of ffmpeg is not broken.

    Here is the full source code to the demo

    <?

       /***********************************************************************************
       get_dimensions()

       Takes in a set of video dimensions - original and target - and returns the optimal conversion
       dimensions.  It will always return the smaller of the original or target dimensions.
       For example: original dimensions of 320x240 and target dimensions of 640x480.
       The result will be 320x240 because converting to 640x480 would be a waste of disk
       space, processing, and bandwidth (assuming these videos are to be downloaded).

       @param $original_width:     The actual width of the original video file which is to be converted.
       @param $original_height:    The actual height of the original video file which is to be converted.
       @param $target_width:       The width of the video file which we will be converting to.
       @param $target_height:      The height of the video file which we will be converting to.
       @param $force_aspect:       Boolean value of whether or not to force conversion to the target's
                             aspect ratio using padding (so the video isn't stretched).  If false, the
                             conversion dimensions will retain the aspect ratio of the original.
                             Optional parameter.  Defaults to true.
       @return: An array containing the size and padding information to be used for conversion.
                   Format:
                   Array
                   (
                       [width] => int
                       [height] => int
                       [padtop] => int // top padding (if applicable)
                       [padbottom] => int // bottom padding (if applicable)
                       [padleft] => int // left padding (if applicable)
                       [padright] => int // right padding (if applicable)
                   )
       ***********************************************************************************/
       function get_dimensions($original_width,$original_height,$target_width,$target_height,$force_aspect)
       {
           if(!isset($force_aspect))
           {
               $force_aspect = true;
           }
           // Array to be returned by this function
           $target = array();
           $target['padleft'] = 0;
           $target['padright'] = 0;
           $target['padbottom'] = 0;
           $target['padtop'] = 0;



           // Target aspect ratio (width / height)
           $aspect = $target_width / $target_height;
           // Target reciprocal aspect ratio (height / width)
           $raspect = $target_height / $target_width;

           if($original_width/$original_height !== $aspect)
           {
               // Aspect ratio is different
               if($original_width/$original_height > $aspect)
               {
                   // Width is the greater of the two dimensions relative to the target dimensions
                   if($original_width < $target_width)
                   {
                       // Original video is smaller.  Scale down dimensions for conversion
                       $target_width = $original_width;
                       $target_height = round($raspect * $target_width);
                   }
                   // Calculate height from width
                   $original_height = round($original_height / $original_width * $target_width);
                   $original_width = $target_width;
                   if($force_aspect)
                   {
                       // Pad top and bottom
                       $dif = round(($target_height - $original_height) / 2);
                       $target['padtop'] = $dif;
                       $target['padbottom'] = $dif;
                   }
               }
               else
               {
                   // Height is the greater of the two dimensions relative to the target dimensions
                   if($original_height < $target_height)
                   {
                       // Original video is smaller.  Scale down dimensions for conversion
                       $target_height = $original_height;
                       $target_width = round($aspect * $target_height);
                   }
                   //Calculate width from height
                   $original_width = round($original_width / $original_height * $target_height);
                   $original_height = $target_height;
                   if($force_aspect)
                   {
                       // Pad left and right
                       $dif = round(($target_width - $original_width) / 2);
                       $target['padleft'] = $dif;
                       $target['padright'] = $dif;
                   }
               }
           }
           else
           {
               // The aspect ratio is the same
               if($original_width !== $target_width)
               {
                   if($original_width < $target_width)
                   {
                       // The original video is smaller.  Use its resolution for conversion
                       $target_width = $original_width;
                       $target_height = $original_height;
                   }
                   else
                   {
                       // The original video is larger,  Use the target dimensions for conversion
                       $original_width = $target_width;
                       $original_height = $target_height;
                   }
               }
           }
           if($force_aspect)
           {
               // Use the target_ vars because they contain dimensions relative to the target aspect ratio
               $target['width'] = $target_width;
               $target['height'] = $target_height;
           }
           else
           {
               // Use the original_ vars because they contain dimensions relative to the original's aspect ratio
               $target['width'] = $original_width;
               $target['height'] = $original_height;
           }
           return $target;
       }

       function get_vid_dim($file)
       {
           $command = '/usr/bin/ffmpeg -i ' . escapeshellarg($file) . ' 2>&1';
           $dimensions = array();
           exec($command,$output,$status);
           if (!preg_match(&#39;/Stream #(?:[0-9\.]+)(?:.*)\: Video: (?P<videocodec>.*) (?P<width>[0-9]*)x(?P<height>[0-9]*)/&#39;,implode("\n",$output),$matches))
           {
               preg_match(&#39;/Could not find codec parameters \(Video: (?P<videocodec>.*) (?P<width>[0-9]*)x(?P<height>[0-9]*)\)/&#39;,implode("\n",$output),$matches);
           }
           if(!empty($matches[&#39;width&#39;]) &amp;&amp; !empty($matches[&#39;height&#39;]))
           {
               $dimensions[&#39;width&#39;] = $matches[&#39;width&#39;];
               $dimensions[&#39;height&#39;] = $matches[&#39;height&#39;];
           }
           return $dimensions;
       }


       $command    = &#39;/usr/bin/ffmpeg -i &#39; . $src . &#39; -ab 96k -b 700k -ar 44100 -f flv -s &#39; . &#39;640x480 -acodec mp3 &#39;. $video_output_dir . $video_filename . &#39; 2>&amp;1&#39;;


       define( &#39;VIDEO_WIDTH&#39;,      &#39;640&#39; );
       define( &#39;VIDEO_HEIGHT&#39;,     &#39;480&#39; );

       $src_1              = getcwd() .&#39;/&#39;. &#39;test_video1.mpeg&#39;;
       $video_filename1    = &#39;video1.flv&#39;;

       $src_2              = getcwd() .&#39;/&#39;. &#39;test_video2.mp4&#39;;
       $video_filename2    = &#39;video2.flv&#39;;

       $src_3              = getcwd() .&#39;/&#39;. &#39;test_video3.mp4&#39;;
       $video_filename3    = &#39;video3.flv&#39;;

       convert_video( $src_1, $video_filename1 );
       convert_video( $src_2, $video_filename2 );
       convert_video( $src_3, $video_filename3 );

       function convert_video( $src = &#39;&#39;, $video_filename = &#39;&#39; )
       {

           $video_output_dir   = getcwd() .&#39;/&#39;;

           @unlink ( $video_output_dir . $video_filename );

           $original   = get_vid_dim($src);
           $target     = get_dimensions( $original[&#39;width&#39;], $original[&#39;height&#39;], VIDEO_WIDTH, VIDEO_HEIGHT, TRUE );

           echo &#39;<pre>&#39;;
           print_r( $original );
           echo &#39;</pre>&#39;;
           echo &#39;<pre>&#39;;
           print_r( $target );
           echo &#39;</pre>&#39;;



           $target_width   = $target[&#39;width&#39;];
           $target_height  = $target[&#39;height&#39;];

           $pad_left       = $target[&#39;padleft&#39;];
           $pad_right      = $target[&#39;padright&#39;];
           $pad_bottom     = $target[&#39;padbottom&#39;];
           $pad_top        = $target[&#39;padtop&#39;];

           $pad_horizontal = $target_width     + $pad_left + $pad_right;
           $pad_vertical   = $target_height; //    + $pad_top + $pad_bottom;


           $command = &#39;/usr/bin/ffmpeg -i &#39; . $src;

           // $command .= " -s {$target_width}x{$target_height} ";

           $command .= " -vf pad=$pad_horizontal:$pad_vertical:". $pad_left .":". $pad_top  .":black";

           $command .= &#39; -ab 96k -b 700k -ar 44100&#39;;
           $command .= &#39; -f flv &#39;;
           $command .= &#39; -qscale 4&#39;;

           $command .= &#39; -ss 30&#39;;
           $command .= &#39; -t 5&#39;;

           $command .= &#39; -ac 2 -ab 128k -qscale 5 &#39;;
           $command .= &#39; &#39; . $video_output_dir . $video_filename;


           exec( $command, $output, $status );

           echo &#39;<pre>&#39;;
           print_r( $command );
           echo &#39;</pre>&#39;;

           if ( $status == 0 )
           {
               echo &#39;<br />Convert OK. <br />&#39;;
           }
           else
           {
               echo &#39;<pre>&#39;;
               print_r( $output );
               echo &#39;</pre>&#39;;
           }

           echo &#39;<br />&#39;;
           echo &#39;<br />&#39;;

       }





    ?>
    </height></width></videocodec></height></width></videocodec>

    Thank you and have fun :)

  • Simply beyond ridiculous

    7 mai 2010, par Dark Shikari — H.265, speed

    For the past few years, various improvements on H.264 have been periodically proposed, ranging from larger transforms to better intra prediction. These finally came together in the JCT-VC meeting this past April, where over two dozen proposals were made for a next-generation video coding standard. Of course, all of these were in very rough-draft form ; it will likely take years to filter it down into a usable standard. In the process, they’ll pick the most useful features (hopefully) from each proposal and combine them into something a bit more sane. But, of course, it all has to start somewhere.

    A number of features were common : larger block sizes, larger transform sizes, fancier interpolation filters, improved intra prediction schemes, improved motion vector prediction, increased internal bit depth, new entropy coding schemes, and so forth. A lot of these are potentially quite promising and resolve a lot of complaints I’ve had about H.264, so I decided to try out the proposal that appeared the most interesting : the Samsung+BBC proposal (A124), which claims compression improvements of around 40%.

    The proposal combines a bouillabaisse of new features, ranging from a 12-tap interpolation filter to 12thpel motion compensation and transforms as large as 64×64. Overall, I would say it’s a good proposal and I don’t doubt their results given the sheer volume of useful features they’ve dumped into it. I was a bit worried about complexity, however, as 12-tap interpolation filters don’t exactly scream “fast”.

    I prepared myself for the slowness of an unoptimized encoder implementation, compiled their tool, and started a test encode with their recommended settings.

    I waited. The first frame, an I-frame, completed.

    I took a nap.

    I waited. The second frame, a P-frame, was done.

    I played a game of Settlers.

    I waited. The third frame, a B-frame, was done.

    I worked on a term paper.

    I waited. The fourth frame, a B-frame, was done.

    After a full 6 hours, 8 frames had encoded. Yes, at this rate, it would take a full two weeks to encode 10 seconds of HD video. On a Core i7. This is not merely slow ; this is over 1000 times slower than x264 on “placebo” mode. This is so slow that it is not merely impractical ; it is impossible to even test. This encoder is apparently designed for some sort of hypothetical future computer from space. And word from other developers is that the Intel proposal is even slower.

    This has led me to suspect that there is a great deal of cheating going on in the H.265 proposals. The goal of the proposals, of course, is to pick the best feature set for the next generation video compression standard. But there is an extra motivation : organizations whose features get accepted get patents on the resulting standard, and thus income. With such large sums of money in the picture, dishonesty becomes all the more profitable.

    There is a set of rules, of course, to limit how the proposals can optimize their encoders. If different encoders use different optimization techniques, the results will no longer be comparable — remember, they are trying to compare compression features, not methods of optimizing encoder-side decisions. Thus all encoders are required to use a constant quantizer, specified frame types, and so forth. But there are no limits on how slow an encoder can be or what algorithms it can use.

    It would be one thing if the proposed encoder was a mere 10 times slower than the current reference ; that would be reasonable, given the low level of optimization and higher complexity of the new standard. But this is beyond ridiculous. With the prize given to whoever can eke out the most PSNR at a given quantizer at the lowest bitrate (with no limits on speed), we’re just going to get an arms race of slow encoders, with every company trying to use the most ridiculous optimizations possible, even if they involve encoding the frame 100,000 times over to choose the optimal parameters. And the end result will be as I encountered here : encoders so slow that they are simply impossible to even test.

    Such an arms race certainly does little good in optimizing for reality where we don’t have 30 years to encode an HD movie : a feature that gives great compression improvements is useless if it’s impossible to optimize for in a reasonable amount of time. Certainly once the standard is finalized practical encoders will be written — but it makes no sense to optimize the standard for a use-case that doesn’t exist. And even attempting to “optimize” anything is difficult when encoding a few seconds of video takes weeks.

    Update : The people involved have contacted me and insist that there was in fact no cheating going on. This is probably correct ; the problem appears to be that the rules that were set out were simply not strict enough, making many changes that I would intuitively consider “cheating” to be perfectly allowed, and thus everyone can do it.

    I would like to apologize if I implied that the results weren’t valid ; they are — the Samsung-BBC proposal is definitely one of the best, which is why I picked it to test with. It’s just that I think any situation in which it’s impossible to test your own software is unreasonable, and thus the entire situation is an inherently broken one, given the lax rules, slow baseline encoder, and no restrictions on compute time.

  • compile FFmpeg error on windows when run ./configure

    5 novembre 2013, par user1325717

    I want to use FFmpeg to decode mp3 and acc on android, I use android-ndk-r7 and the newest cygwin.

    I wrote a shell config.sh, which content is :


    TMPDIR=/cygdrive/c/temp

    PREBUILT=/cygdrive/c/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows
    PLATFORM=/cygdrive/c/android-ndk-r7/platforms/android-8/arch-arm

    ./configure --target-os=linux --arch=arm --enable-version3 --enable-gpl --enable-nonfree --disable-stripping --disable-ffmpeg --disable-ffplay --disable-ffserver --disable-ffprobe --disable-encoders --disable-muxers --disable-devices --disable-protocols --enable-protocol=file --enable-avfilter --disable-network --disable-mpegaudio-hp --disable-avdevice --enable-cross-compile --cc=$PREBUILT/bin/arm-linux-androideabi-gcc --cross-prefix=$PREBUILT/bin/arm-linux-androideabi- --nm=$PREBUILT/bin/arm-linux-androideabi-nm --extra-cflags="-fPIC -DANDROID" --disable-asm --enable-neon --enable-armv5te --extra-ldflags="-Wl,-T,$PREBUILT/arm-eabi/lib/ldscripts/armelf_linux_eabi.x -Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/crtbegin.o $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/crtend.o -lc -lm -ldl"

    I open cmd and do bash to open cygwin shell, then do ./config, the problem is appeared :
    "/cygdrive/c/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-gcc is unable to create an executable file..."

    the config.log is :

    check_ld
    check_cc
    BEGIN /cygdrive/c/temp/ffconf.SFJc3t92.c
       1   int main(void){ return 0; }
    END /cygdrive/c/temp/ffconf.SFJc3t92.c
    gcc -fPIC -DANDROID -std=c99 -c -o /cygdrive/c/temp/ffconf.YKRv5TSp.o /cygdrive/c/temp/ffconf.SFJc3t92.c
    /cygdrive/c/temp/ffconf.SFJc3t92.c:1:0: warning: -fPIC ignored for target (all code is position independent)
    gcc -Wl,-rpath-link=/cygdrive/c/android-ndk-r7/platforms/android-4/arch-arm/usr/lib -L/cygdrive/c/android-ndk-r7/platforms/android-4/arch-arm/usr/lib -nostdlib /cygdrive/c/android-ndk-r7/platforms/android-4/arch-arm/usr/lib/crtbegin_static.o /cygdrive/c/android-ndk-r7/platforms/android-4/arch-arm/usr/lib/crtend_android.o -lc -lm -ldl -o /cygdrive/c/temp/ffconf.Yf1Ftjmo /cygdrive/c/temp/ffconf.YKRv5TSp.o
    /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld: /cygdrive/c/android-ndk-r7/platforms/android-4/arch-arm/usr/lib/crtbegin_static.o: Relocations in generic ELF (EM: 40)
    /cygdrive/c/android-ndk-r7/platforms/android-4/arch-arm/usr/lib/crtbegin_static.o: could not read symbols: File in wrong format
    collect2: ld returned 1 exit status
    C compiler test failed.

    I don't know what is happened, is there someone who know what is happened, thanks.