
Recherche avancée
Médias (1)
-
Richard Stallman et le logiciel libre
19 octobre 2011, par
Mis à jour : Mai 2013
Langue : français
Type : Texte
Autres articles (111)
-
MediaSPIP 0.1 Beta version
25 avril 2011, parMediaSPIP 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 (...) -
Script d’installation automatique de MediaSPIP
25 avril 2011, parAfin de palier aux difficultés d’installation dues principalement aux dépendances logicielles coté serveur, un script d’installation "tout en un" en bash a été créé afin de faciliter cette étape sur un serveur doté d’une distribution Linux compatible.
Vous devez bénéficier d’un accès SSH à votre serveur et d’un compte "root" afin de l’utiliser, ce qui permettra d’installer les dépendances. Contactez votre hébergeur si vous ne disposez pas de cela.
La documentation de l’utilisation du script d’installation (...) -
XMP PHP
13 mai 2011, parDixit Wikipedia, XMP signifie :
Extensible Metadata Platform ou XMP est un format de métadonnées basé sur XML utilisé dans les applications PDF, de photographie et de graphisme. Il a été lancé par Adobe Systems en avril 2001 en étant intégré à la version 5.0 d’Adobe Acrobat.
Étant basé sur XML, il gère un ensemble de tags dynamiques pour l’utilisation dans le cadre du Web sémantique.
XMP permet d’enregistrer sous forme d’un document XML des informations relatives à un fichier : titre, auteur, historique (...)
Sur d’autres sites (6693)
-
Padding thumbnail with color
I know, it’s been a while since I last blogged. This is because a lot of things are happening in my personal life. I recently relocated to London from Finland and started a new job. Things are quite busy but I will try to post an example now and then. In the meanwhile I would like to hear about sites using Imagick, so if your project is not super secret please post an url and maybe a small explanation what you’re doing with Imagick on the site. This is purely for my personal interest.
Anyway, to the point. Today’s example originates from a question asked by a user. How do I thumbnail the image inside given dimensions proportionally and fill the “blank” areas with a color ? Well, the answer is here
The code is for Imagick 2.1.0 but adapting to older versions should not be hard.
-
< ?php
-
/* Define width and height of the thumbnail */
-
$width = 100 ;
-
$height = 100 ;
-
-
/* Instanciate and read the image in */
-
$im = new Imagick( "test.png" ) ;
-
-
/* Fit the image into $width x $height box
-
The third parameter fits the image into a "bounding box" */
-
$im->thumbnailImage( $width, $height, true ) ;
-
-
/* Create a canvas with the desired color */
-
$canvas = new Imagick() ;
-
$canvas->newImage( $width, $height, ’pink’, ’png’ ) ;
-
-
/* Get the image geometry */
-
$geometry = $im->getImageGeometry() ;
-
-
/* The overlay x and y coordinates */
-
$x = ( $width - $geometry[’width’] ) / 2 ;
-
$y = ( $height - $geometry[’height’] ) / 2 ;
-
-
/* Composite on the canvas */
-
$canvas->compositeImage( $im, imagick: :COMPOSITE_OVER, $x, $y ) ;
-
-
/* Output the image*/
-
header( "Content-Type : image/png" ) ;
-
echo $canvas ;
-
-
?>
-
-
Typesetting
Ever had the situation where you have a piece of string which you need to overlay on an image ? Maybe a situation where the area reserved for the string is known in pixels but you need to know the font size to fill most of the area ? Think no more !
Here is a small example of how to fit a certain piece of a string on to an area of which you know the width and the height or only the width. The magic happens through the ImageMagick CAPTION : format. You can see from the example images how the parameters actually affect the image.
-
< ?php
-
-
/* How wide is our image */
-
$image_width = 200 ;
-
-
/* Give zero for autocalculating the height */
-
$image_height = 200 ;
-
-
/* Specify the text */
-
$text = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
-
Mauris lectus mi, mattis non, euismod vel, sagittis nec, ipsum." ;
-
-
/* Instanciate imagick */
-
$im = new Imagick() ;
-
-
/* Create new image using caption : pseudo format */
-
$im->newPseudoImage( $image_width, $image_height, "caption :" . $text ) ;
-
-
/* Put 1px border around the image */
-
$im->borderImage( ’black’, 1, 1 ) ;
-
-
/* PNG format */
-
$im->setImageFormat( "png") ;
-
-
/* Output */
-
header( "Content-Type : image/png" ) ;
-
echo $im ;
-
-
?>
Here is image with width 100 and height 0 :
Width 100 Height 50 :
Width 200 Height 200 (as you can see the font size is now larger) :
-
-
Problem opening xvid264 with avcodec_alloc_context(NULL)
12 juillet 2024, par user3763774I want to multiplex audio and video together using the ffmpeg encoding library with xvid264rgb codec. I can open the codec when I create the context specifying that codec, but not if I use NULL for the argument with allocate context. My understanding is I need to use NULL so I can open the audio codec as well.


In the example, the first open works with codec indicated in the allocate context. The second doesn't.


#include 
#include 
#include 
#include <libavcodec></libavcodec>avcodec.h>
#include <libavutil></libavutil>opt.h>
#define WIDTH 400
#define HEIGHT 300

const AVCodec *videocodec;

bool init_video_encoder(AVCodecContext *c, int width, int height) {
 int ret;
 
 const AVRational tb_rat = {1, 30};
 const AVRational fr_rat = {30, 1};

 fprintf(stderr, "init video encoder\n");
 // video
 //fprintf(stderr, "speed= %d \n", videocodec->speed);
 c->bit_rate = 400000;
 c->width = width;
 c->height = height;
 c->time_base = tb_rat;
 c->framerate = fr_rat;
 c->gop_size = 10;
 c->max_b_frames = 1;
 c->pix_fmt = AV_PIX_FMT_RGB24;
 if( videocodec->id == AV_CODEC_ID_H264 ) 
 av_opt_set(c->priv_data, "preset", "slow", 0);
 
 ret = avcodec_open2(c, videocodec, NULL);
 if( ret < 0 ) {
 fprintf(stderr, "failure to open codec: %s\n", av_err2str(ret));
 return false;
 }
 //avcodec_free_context(&c);
 return true;
}

int main(int argc, char **argv) {

 AVCodecContext *context = NULL;

 videocodec = avcodec_find_encoder_by_name("libx264rgb");
 if( videocodec == NULL ) {
 fprintf(stderr, "video encoder 'libx264rgb' not found");
 exit;
 }

 context = avcodec_alloc_context3(videocodec);
 if( context == NULL ) {
 fprintf(stderr, "could not allocate context with codec");
 return false;
 }
 if( init_video_encoder( context, WIDTH, HEIGHT ) ) 
 fprintf(stderr, " success initializing video encoder case one\n");
 else
 fprintf(stderr, " failure to initialize video encoder case one\n");
 avcodec_close( context );

 context = avcodec_alloc_context3(NULL);
 if( context == NULL ) {
 fprintf(stderr, "could not allocate context without codec");
 return false;
 }
 if( init_video_encoder( context, WIDTH, HEIGHT ) ) 
 fprintf(stderr, " success initializing video encoder case two\n");
 else
 fprintf(stderr, " failure to initialize video encoder case two\n");
 avcodec_close( context );
}



Here is the error message :


broken ffmpeg default settings detected
use an encoding preset (e.g. -vpre medium)
preset usage: -vpre <speed> -vpre <profile>
speed presets are listed in x264 --help
profile is optional; x264 defaults to high
failure to open codec: Generic error in an external library
failure to initialize video encoder case two
</profile></speed>


Is this the right approach to use ? How do I set the encoding preset ? The code appears already to do that.