
Recherche avancée
Médias (91)
-
Géodiversité
9 septembre 2011, par ,
Mis à jour : Août 2018
Langue : français
Type : Texte
-
USGS Real-time Earthquakes
8 septembre 2011, par
Mis à jour : Septembre 2011
Langue : français
Type : Texte
-
SWFUpload Process
6 septembre 2011, par
Mis à jour : Septembre 2011
Langue : français
Type : Texte
-
La conservation du net art au musée. Les stratégies à l’œuvre
26 mai 2011
Mis à jour : Juillet 2013
Langue : français
Type : Texte
-
Podcasting Legal guide
16 mai 2011, par
Mis à jour : Mai 2011
Langue : English
Type : Texte
-
Creativecommons informational flyer
16 mai 2011, par
Mis à jour : Juillet 2013
Langue : English
Type : Texte
Autres articles (72)
-
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 (...) -
MediaSPIP version 0.1 Beta
16 avril 2011, parMediaSPIP 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 (...) -
Amélioration de la version de base
13 septembre 2013Jolie 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 (...)
Sur d’autres sites (13348)
-
avfilter/graphparser : allow specifying filter@id as filter instance
17 mai 2017, par Muhammad Faizavfilter/graphparser : allow specifying filter@id as filter instance
See http://lists.ffmpeg.org/pipermail/ffmpeg-user/2017-April/035975.html
Parsed_filter_X could remain and user can override it with custom one.Example :
ffplay -f lavfi "nullsrc=s=640x360,
sendcmd='1 drawtext@top reinit text=Hello ; 2 drawtext@bottom reinit text=World',
drawtext@top=x=16:y=16:fontsize=20:fontcolor=Red:text='',
drawtext@bottom=x=16:y=340:fontsize=16:fontcolor=Blue:text=''"Reviewed-by : Paul B Mahol <onemda@gmail.com>
Signed-off-by : Muhammad Faiz <mfcc64@gmail.com> -
Creating a usable H.264 video file
4 mai 2019, par Ethan McTagueI am trying to use
libavcodec
to generate an mp4 video file from individual frames. Each input frame is a qtQImage
, and the output file is written to using the QtQFile
class.I’ve done this through a
VideoTarget
class which opens the given ’target’ file when initialized, records frames whenaddFrame(image)
is called, and then saves/closes the file when its destructor is called.The class has the following fields :
AVCodec* m_codec = nullptr;
AVCodecContext *m_context = nullptr;
AVPacket* m_packet = nullptr;
AVFrame* m_frame = nullptr;
QFile m_target;And looks like this :
VideoTarget::VideoTarget(QString target, QObject *parent) : QObject(parent), m_target(target)
{
// Find video codec
m_codec = avcodec_find_encoder_by_name("libx264rgb");
if (!m_codec) throw std::runtime_error("Unable to find codec.");
// Make codec context
m_context = avcodec_alloc_context3(m_codec);
if (!m_context) throw std::runtime_error("Unable to allocate codec context.");
// Make codec packet
m_packet = av_packet_alloc();
if (!m_packet) throw std::runtime_error("Unable to allocate packet.");
// Configure context
m_context->bit_rate = 400000;
m_context->width = 1280;
m_context->height = 720;
m_context->time_base = (AVRational){1, 60};
m_context->framerate = (AVRational){60, 1};
m_context->gop_size = 10;
m_context->max_b_frames = 1;
m_context->pix_fmt = AV_PIX_FMT_RGB24;
if (m_codec->id == AV_CODEC_ID_H264)
av_opt_set(m_context->priv_data, "preset", "slow", 0);
// Open Codec
int ret = avcodec_open2(m_context, m_codec, nullptr);
if (ret < 0) {
throw std::runtime_error("Unable to open codec.");
}
// Open file
if (!m_target.open(QIODevice::WriteOnly))
throw std::runtime_error("Unable to open target file.");
// Allocate frame
m_frame = av_frame_alloc();
if (!m_frame) throw std::runtime_error("Unable to allocate frame.");
m_frame->format = m_context->pix_fmt;
m_frame->width = m_context->width;
m_frame->height = m_context->height;
m_frame->pts = 0;
ret = av_frame_get_buffer(m_frame, 24);
if (ret < 0) throw std::runtime_error("Unable to allocate frame buffer.");
}
void VideoTarget::addFrame(QImage &image)
{
// Ensure frame data is writable
int ret = av_frame_make_writable(m_frame);
if (ret < 0) throw std::runtime_error("Unable to make frame writable.");
// Prepare image
for (int y = 0; y < m_context->height; y++) {
for (int x = 0; x < m_context->width; x++) {
auto pixel = image.pixelColor(x, y);
int pos = (y * 1024 + x) * 3;
m_frame->data[0][pos] = pixel.red();
m_frame->data[0][pos + 1] = pixel.green();
m_frame->data[0][pos + 2] = pixel.blue();
}
}
m_frame->pts++;
// Send the frame
ret = avcodec_send_frame(m_context, m_frame);
if (ret < 0) throw std::runtime_error("Unable to send AV frame.");
while (ret >= 0) {
ret = avcodec_receive_packet(m_context, m_packet);
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
return;
else if (ret < 0) throw std::runtime_error("Error during encoding.");
m_target.write((const char*)m_packet->data, m_packet->size);
av_packet_unref(m_packet);
}
}
VideoTarget::~VideoTarget()
{
int ret = avcodec_send_frame(m_context, nullptr);
if (ret < 0) throw std::runtime_error("Unable to send AV null frame.");
while (ret >= 0) {
ret = avcodec_receive_packet(m_context, m_packet);
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
return;
else if (ret < 0) throw std::runtime_error("Error during encoding.");
m_target.write((const char*)m_packet->data, m_packet->size);
av_packet_unref(m_packet);
}
// Magic number at the end of the file
uint8_t endcode[] = { 0, 0, 1, 0xb7 };
m_target.write((const char*)endcode, sizeof(endcode));
m_target.close();
// Free codec stuff
avcodec_free_context(&m_context);
av_frame_free(&m_frame);
av_packet_free(&m_packet);
}When used, the class seems to work, and data is written to the file, except I am unable to play back the resulting file in any application.
My main suspect is these lines :
// Prepare image
for (int y = 0; y < m_context->height; y++) {
for (int x = 0; x < m_context->width; x++) {
auto pixel = image.pixelColor(x, y);
int pos = (y * 1024 + x) * 3;
m_frame->data[0][pos] = pixel.red();
m_frame->data[0][pos + 1] = pixel.green();
m_frame->data[0][pos + 2] = pixel.blue();
}
}The
libavcodec
documentation was extremely vague regarding the layout of image data, so I effectively had to guess and be happy with the first thing that didn’t crash, so chances are I’m writing this incorrectly. There’s also the issue of size mismatch between mypixel
color data calls (givingint
values) and the 24-bits-per-pixel RGB format I have selected.How do I tweak this code to output actual, functioning video files ?
-
avcodec/dds : fix paletted files
19 juillet 2015, par Michael Niedermayer