
Recherche avancée
Médias (1)
-
The pirate bay depuis la Belgique
1er avril 2013, par
Mis à jour : Avril 2013
Langue : français
Type : Image
Autres articles (59)
-
Configurer la prise en compte des langues
15 novembre 2010, parAccéder à la configuration et ajouter des langues prises en compte
Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...) -
Demande de création d’un canal
12 mars 2010, parEn fonction de la configuration de la plateforme, l’utilisateur peu avoir à sa disposition deux méthodes différentes de demande de création de canal. La première est au moment de son inscription, la seconde, après son inscription en remplissant un formulaire de demande.
Les deux manières demandent les mêmes choses fonctionnent à peu près de la même manière, le futur utilisateur doit remplir une série de champ de formulaire permettant tout d’abord aux administrateurs d’avoir des informations quant à (...) -
La file d’attente de SPIPmotion
28 novembre 2010, parUne file d’attente stockée dans la base de donnée
Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...)
Sur d’autres sites (6536)
-
How can I resize an image then centralize it with a white background ? Can it be done using php-Imagine library ?
6 février 2017, par BOBOThe effect I would like to generate is exactly like the example in
this StackOverflow thread : (Related Question)1.Resize image
2.Keep proportion
3.Add or Fill none-image areas with white backgroundHere are three examples of this process below :
1. If original is square no matter 640*640 or 1024*1024, just resize it to target dimension e.g. 480*480 will work.
-
If the original input is vertical rectangular,the output should not be cropped
and still be centerlized as below (the red dash edge marker is just make it easier to see the background is white and the proportion is kept after image resized to 480*480 px)
-
if the original input is horizontal rectangular, output like below, white background, keeps proportion and image uncroped , thus without losing anything after the image processing.
So after I’ve clarified such a question,
I would like to know :- Is there a general name of such Custom Image Resize mentioned above ?
- would like to know how to achieve it using php image library Imagine ?
is it doable using php-imagine, or have to switch to another library, e.g imagemagick ?
P.S. If you would like to achieve the effect either in image-resizing or video resizing, you can use below FFMPEG single-line command.
(thanks to @Mulvya, yes below code applies both to videos and image formats)[run below built-in code in ffmpeg console to achieve the mentioned resize effect]
[video resize]
ffmpeg -i "[raw video url or videofile location.mp4]" -vf "scale=iw*min(480/iw\,480/ih):ih*min(480/iw\,480/ih),pad=480:480:(480-iw)/2:(480-ih)/2:color=white" [save_path_and_filename].mp4
[image resize]
ffmpeg -i "[raw image url or imagefile location.jpg]" -vf "scale=iw*min(480/iw\,480/ih):ih*min(480/iw\,480/ih),pad=480:480:(480-iw)/2:(480-ih)/2:color=white" [save_path_and_filename].jpg
-
-
lavf/avio : Be more explicit in logging white/black list matches
11 mars 2017, par Alexander Strasserlavf/avio : Be more explicit in logging white/black list matches
The current form of the messages indicating matches in the white
or black lists seems to be a bit too much relying on context.Make the messages more explicit.
Signed-off-by : Alexander Strasser <eclipse7@gmx.net>
-
libavformat : calling avformat_open_input 2 times results in decoding white frames
25 avril 2017, par explodus- pre build ffmpeg libs format/util/scale
- version 57.56.101
- don’t use any deprecated function
- use the actual style
- av_read_frame -> avcodec_send_packet -> avcodec_receive_frame -> sws_scale
Everything is fine on the first run, but when i wanna load/open another file i only get white frames.
void video::app::flush_cached_frames() {
if (nullptr == avcontext)
return;
if (nullptr == avpicture)
return;
// send an empty packet which instructs the codec to start flushing
AVPacket pkt;
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
avcodec_send_packet(avcontext, &pkt);
// drain the codec
while (true) {
int r = avcodec_receive_frame(avcontext, avpicture);
if (r != 0)
break;
}
}
void video::app::close_avi() {
flush_cached_frames();
if (avformat && avstream)
seek_to_frame(0);
avstream = nullptr;
if (avfile)
fclose(avfile);
avfile = nullptr;
if (avcontext)
avcodec_close(avcontext);
avcontext = nullptr;
if (avformat)
avformat_free_context(avformat);
avformat = nullptr;
if (sws_ctx)
sws_freeContext(sws_ctx);
sws_ctx = nullptr;
if (avparser)
av_parser_close(avparser);
avparser = nullptr;
if (avinbuf)
av_free(avinbuf);
avinbuf = nullptr;
}I think i close anything perfectly. Has anyone an idea ?
edit1 : init/load
unsigned video::app::load(const std::string& name) {
_file = name_;
close_avi();
av_register_all();
avcodec_register_all();
av_init_packet(&avpkt);
AVCodecID codec_id = AV_CODEC_ID_H264;
int64_t duration = 0;
double fps = .0;
int ret = 0;
{
av_log_set_level(1);
avfile = fopen(name_.c_str(), "rb");
avformat = avformat_alloc_context();
ret = avformat_open_input(&avformat, name_.c_str(), nullptr, nullptr);
ret = avformat_find_stream_info(avformat, nullptr);
duration = avformat->duration;
avstream = nullptr;
if (avformat->nb_streams == 1) {
avstream = avformat->streams[0];
} else {
avstream = avformat->streams[av_find_default_stream_index(avformat)];
}
if (avstream) {
fps = (double(avstream->avg_frame_rate.num) / double(avstream->avg_frame_rate.den));
codec_id = avstream->codecpar->codec_id;
duration = avstream->duration;
_vid.v_width = avstream->codecpar->width;
_vid.v_height = avstream->codecpar->height;
_vid.lastframe = duration / fps;
_vid.lastframe = avstream->nb_frames;
}
avcodec = avcodec_find_decoder(avstream->codecpar->codec_id);
avparser = av_parser_init(avcodec->id);
avcontext = avcodec_alloc_context3(avcodec);
avcontext->flags |= AVFMT_FLAG_NONBLOCK;
avcontext->flags |= AVFMT_FLAG_FLUSH_PACKETS;
avcontext->flags |= AVFMT_FLAG_DISCARD_CORRUPT;
avcontext->flags |= AVFMT_FLAG_NOBUFFER;
ret = avcodec_parameters_to_context(avcontext, avstream->codecpar);
ret = avcodec_open2(avcontext, avcodec, nullptr);
// Determine required buffer size and allocate buffer
auto numBytes = av_image_get_buffer_size(
AV_PIX_FMT_BGRA
, avcontext->width
, avcontext->height
, 1);
if (avinbuf)
av_free(avinbuf);
avinbuf = nullptr;
avinbuf = (uint8_t *)av_malloc(numBytes * sizeof(uint8_t));
ret = av_image_fill_arrays(
avrgb->data
, avrgb->linesize
, avinbuf
, AV_PIX_FMT_BGRA
, avcontext->width
, avcontext->height
, 1);
sws_ctx = sws_getContext(
avcontext->width
, avcontext->height
, avcontext->pix_fmt
, avcontext->width
, avcontext->height
, AV_PIX_FMT_BGRA
, SWS_BILINEAR
, nullptr
, nullptr
, nullptr
);
}
int err = (sws_ctx && avcontext && avformat) ? 0 : 1;
// ...
}getting the frame :
uint8_t * video::app::get_frame(uint32_t frame) {
if (!avcontext)
return nullptr;
if (!avformat)
return nullptr;
if (!avpicture)
return nullptr;
if (!avfile)
return nullptr;
try {
int ret = 0;
if (avpicture->data)
av_frame_unref(avpicture);
while (true) {
if ((ret = av_read_frame(avformat, &avpkt)) < 0)
break;
if (avpkt.stream_index == avstream->index) {
ret = avcodec_send_packet(avcontext, &avpkt);
if (ret < 0)
break;
while (ret >= 0) {
ret = avcodec_receive_frame(avcontext, avpicture);
if (ret == AVERROR_EOF) {
return nullptr;
} else if (ret == -11) {
avpkt.data = nullptr;
avpkt.size = 0;
break;
} else if (ret < 0) {
return nullptr;
}
if (ret == AVERROR(EAGAIN)) {
avpkt.data = nullptr;
avpkt.size = 0;
break;
}
if (ret >= 0) {
int linesize[AV_NUM_DATA_POINTERS] = {
avpicture->linesize[0]
, avpicture->linesize[1]
, avpicture->linesize[2]
, avpicture->linesize[3]
, avpicture->linesize[4]
, avpicture->linesize[5]
, avpicture->linesize[6]
, avpicture->linesize[7]
};
uint8_t * data[AV_NUM_DATA_POINTERS] = {
avpicture->data[0]
, avpicture->data[1]
, avpicture->data[2]
, avpicture->data[3]
, avpicture->data[4]
, avpicture->data[5]
, avpicture->data[6]
, avpicture->data[7]
};
{
// flip the frame, never ever touch this thing again!
// If the planes in the image are unequal size(e.g.YUV420) you need to adapt the height.
auto h = avcontext->height;
for (int i = 0; i < 4; i++) {
if (i)
data[i] += linesize[i] * ((h >> 1) - 1);
else
data[i] += linesize[i] * (h - 1);
linesize[i] = -linesize[i];
}
}
ret = sws_scale(
sws_ctx
, (uint8_t const * const *)data
, linesize
, 0
, avcontext->height
, avrgb->data
, avrgb->linesize);
av_packet_unref(&avpkt);
currPts = avpkt.dts;
currPts *= av_q2d(avstream->time_base);
usleep(1000000 * (currPts - prevPts));
prevPts = currPts;
return avrgb->data[0];
}
}
}
av_packet_unref(&avpkt);
}
} catch (...) {
}
return nullptr;
}