
Advanced search
Medias (1)
-
Bug de détection d’ogg
22 March 2013, by
Updated: April 2013
Language: français
Type: Video
Other articles (34)
-
Support audio et vidéo HTML5
10 April 2011MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...) -
Taille des images et des logos définissables
9 February 2011, byDans beaucoup d’endroits du site, logos et images sont redimensionnées pour correspondre aux emplacements définis par les thèmes. L’ensemble des ces tailles pouvant changer d’un thème à un autre peuvent être définies directement dans le thème et éviter ainsi à l’utilisateur de devoir les configurer manuellement après avoir changé l’apparence de son site.
Ces tailles d’images sont également disponibles dans la configuration spécifique de MediaSPIP Core. La taille maximale du logo du site en pixels, on permet (...) -
Gestion de la ferme
2 March 2010, byLa ferme est gérée dans son ensemble par des "super admins".
Certains réglages peuvent être fais afin de réguler les besoins des différents canaux.
Dans un premier temps il utilise le plugin "Gestion de mutualisation"
On other websites (5745)
-
Converting uint8_t data to AVFrame with FFmpeg
30 October 2017, by J.LefebvreI am currently working in C++ with the Autodesk 3DStudio Max 2014 SDK (toolset 100) and the Ffmpeg library in Visual Studio 2015 and trying to convert a DIB (Device Independent Bitmap) to uint8_t pointer array and then convert these data to an AVFrame.
I don’t have any errors, but my video is still black and without meta data.
(no time display, etc)I made approximatively the same with a Visual Studio Console application to convert jpeg image sequence from disk and this is working fine.
(The only difference is that instead of converting jpeg to AVFrame with the Ffmpeg library, I try to convert raw data to an AVFrame.)So I think the problem could be either on the DIB conversion to the uint8_t data or the uint8_t data to the AVFrame.
(The second is more plausible, because I used the SFML library to display a window with my rgb uint8_t* data for debuging and it is working fine.)I first initialize the ffmpeg library :
This function is called once at the beginning.
int Converter::Initialize(AVCodecID codec_id, int width, int height, int fps, const char *filename)
{
avcodec_register_all();
av_register_all();
AVCodec *codec;
inputFrame = NULL;
codecContext = NULL;
pkt = NULL;
file = NULL;
outputFilename = new char[strlen(filename)]();
*outputFilename = '\0';
strcpy(outputFilename, filename);
int ret;
//Initializing AVCodecContext and getting PixelFormat supported by encoder
codec = avcodec_find_encoder(codec_id);
if (!codec)
return 1;
AVPixelFormat pixFormat = codec->pix_fmts[0];
codecContext = avcodec_alloc_context3(codec);
if (!codecContext)
return 1;
codecContext->bit_rate = 400000;
codecContext->width = width;
codecContext->height = height;
codecContext->time_base.num = 1;
codecContext->time_base.den = fps;
codecContext->gop_size = 10;
codecContext->max_b_frames = 1;
codecContext->pix_fmt = pixFormat;
if (codec_id == AV_CODEC_ID_H264)
av_opt_set(codecContext->priv_data, "preset", "slow", 0);
//Actually opening the encoder
if (avcodec_open2(codecContext, codec, NULL) < 0)
return 1;
file = fopen(outputFilename, "wb");
if (!file)
return 1;
inputFrame = av_frame_alloc();
inputFrame->format = codecContext->pix_fmt;
inputFrame->width = codecContext->width;
inputFrame->height = codecContext->height;
ret = av_image_alloc(inputFrame->data, inputFrame->linesize, codecContext->width, codecContext->height, codecContext->pix_fmt, 32);
if (ret < 0)
return 1;
return 0;
}Then for each frame, I get the DIB and convert to a uint8_t* it with this function :
uint8_t* Util::ToUint8_t(RGBQUAD *data, int width, int height)
{
uint8_t* buf = (uint8_t*)data;
int imageSize = width * height;
size_t rgbquad_size = sizeof(RGBQUAD);
size_t total_bytes = imageSize * rgbquad_size;
uint8_t * pCopyBuffer = new uint8_t[total_bytes];
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
int index = (x + width * y) * rgbquad_size;
int invertIndex = (x + width* (height - y - 1)) * rgbquad_size;
//BGRA to RGBA
pCopyBuffer[index] = buf[invertIndex + 2];
pCopyBuffer[index + 1] = buf[invertIndex + 1];
pCopyBuffer[index + 2] = buf[invertIndex];
pCopyBuffer[index + 3] = 0xFF;
}
}
return pCopyBuffer;
}
void GetDIBBuffer(Interface* ip, BITMAPINFO *bmi, uint8_t** outBuffer)
{
int size;
ViewExp& view = ip->GetActiveViewExp();
view.getGW()->getDIB(NULL, &size);
bmi = (BITMAPINFO *)malloc(size);
BITMAPINFOHEADER *bmih = (BITMAPINFOHEADER *)bmi;
view.getGW()->getDIB(bmi, &size);
uint8_t * pCopyBuffer = Util::ToUint8_t(bmi->bmiColors, bmih->biWidth, bmih->biHeight);
*outBuffer = pCopyBuffer;
}This function is used to get the DIB :
void GetViewportDIB(Interface* ip, BITMAPINFO *bmi, BITMAPINFOHEADER *bmih, BitmapInfo biFile, Bitmap *map)
{
int size;
if (!biFile.Name()[0])
return;
ViewExp& view = ip->GetActiveViewExp();
view.getGW()->getDIB(NULL, &size);
bmi = (BITMAPINFO *)malloc(size);
bmih = (BITMAPINFOHEADER *)bmi;
view.getGW()->getDIB(bmi, &size);
biFile.SetWidth((WORD)bmih->biWidth);
biFile.SetHeight((WORD)bmih->biHeight);
biFile.SetType(BMM_TRUE_32);
map = TheManager->Create(&biFile);
map->OpenOutput(&biFile);
map->FromDib(bmi);
map->Write(&biFile);
map->Close(&biFile);
}And after the conversion to AVFrame and video encoding :
The EncodeFromMem function is call each frame.
int Converter::EncodeFromMem(const char *outputDir, int frameNumber, uint8_t* data)
{
int ret;
inputFrame->pts = frameNumber;
EncodeFrame(data, codecContext, inputFrame, &pkt, file);
return 0;
}
static void RgbToYuv(uint8_t *rgb, AVCodecContext *c, AVFrame *frame)
{
struct SwsContext *swsCtx = NULL;
const int in_linesize[1] = { 3 * c->width };// RGB stride
swsCtx = sws_getCachedContext(swsCtx, c->width, c->height, AV_PIX_FMT_RGB24, c->width, c->height, AV_PIX_FMT_YUV420P, 0, 0, 0, 0);
sws_scale(swsCtx, (const uint8_t * const *)&rgb, in_linesize, 0, c->height, frame->data, frame->linesize);
}
static void EncodeFrame(uint8_t *rgb, AVCodecContext *c, AVFrame *frame, AVPacket **pkt, FILE *file)
{
int ret, got_output;
RgbToYuv(rgb, c, frame);
*pkt = av_packet_alloc();
av_init_packet(*pkt);
(*pkt)->data = NULL;
(*pkt)->size = 0;
ret = avcodec_encode_video2(c, *pkt, frame, &got_output);
if (ret < 0)
{
fprintf(stderr, "Error encoding frame/n");
exit(1);
}
if (got_output)
{
fwrite((*pkt)->data, 1, (*pkt)->size, file);
av_packet_unref(*pkt);
}
}To finish I have a function that write the packets and free the memory :
This function is called once at the end of the time range.int Converter::Finalize()
{
int ret, got_output;
uint8_t endcode[] = { 0, 0, 1, 0xb7 };
/* get the delayed frames */
do
{
fflush(stdout);
ret = avcodec_encode_video2(codecContext, pkt, NULL, &got_output);
if (ret < 0)
{
fprintf(stderr, "Error encoding frame/n");
return 1;
}
if (got_output)
{
fwrite(pkt->data, 1, pkt->size, file);
av_packet_unref(pkt);
}
} while (got_output);
fwrite(endcode, 1, sizeof(endcode), file);
fclose(file);
avcodec_close(codecContext);
av_free(codecContext);
av_frame_unref(inputFrame);
av_frame_free(&inputFrame);
//av_freep(&inputFrame->data[0]); //Crash
delete outputFilename;
outputFilename = 0;
return 0;
}EDIT :
I modify my RgbToYuv function and create another one to convert back the yuv frame to an rgb one.
This not really solve the problem, but maybe focus the problem on the conversion from YuvToRgb.
This is the result of the conversion from YUV to RGB :
![YuvToRgb result]: https://img42.com/kHqpt+
static void YuvToRgb(AVCodecContext *c, AVFrame *frame)
{
struct SwsContext *img_convert_ctx = sws_getContext(c->width, c->height, AV_PIX_FMT_YUV420P, c->width, c->height, AV_PIX_FMT_RGB24, SWS_BICUBIC, NULL, NULL, NULL);
AVFrame * rgbPictInfo = av_frame_alloc();
avpicture_fill((AVPicture*)rgbPictInfo, *(frame)->data, AV_PIX_FMT_RGB24, c->width, c->height);
sws_scale(img_convert_ctx, frame->data, frame->linesize, 0, c->height, rgbPictInfo->data, rgbPictInfo->linesize);
Util::DebugWindow(c->width, c->height, rgbPictInfo->data[0]);
}
static void RgbToYuv(uint8_t *rgb, AVCodecContext *c, AVFrame *frame)
{
AVFrame * rgbPictInfo = av_frame_alloc();
avpicture_fill((AVPicture*)rgbPictInfo, rgb, AV_PIX_FMT_RGBA, c->width, c->height);
struct SwsContext *swsCtx = sws_getContext(c->width, c->height, AV_PIX_FMT_RGBA, c->width, c->height, AV_PIX_FMT_YUV420P, SWS_BICUBIC, NULL, NULL, NULL);
avpicture_fill((AVPicture*)frame, rgb, AV_PIX_FMT_YUV420P, c->width, c->height);
sws_scale(swsCtx, rgbPictInfo->data, rgbPictInfo->linesize, 0, c->height, frame->data, frame->linesize);
YuvToRgb(c, frame);
} -
Anomalie #3920 (Nouveau): sur Sauvegarde SQLite (SPIP 3.1.3 et 3.1.4 mini)
11 March 2017, by YannX DYXEn SPIP 3 la sauvegarde standard pose parfois des problèmes, que j’ai trop souvent vus...
Cette fois j’ai investigué sur un SPIP 3.1.4 OVH (avec prefix spécifique), toutes les tables ne sont pas sauvegardées, au contraire de la sauvegarde SQL : certes un message existe mais !
- d’une part des tables vides ou non déclarées dans un plugin activé sont omises : pourquoi ?
(encore une fois au contraire de la sauvegarde SQL encore disponible en plugin !)
=> est-il possible d’apporter un lien vers une aide plus détaillée, explicitant les causes possibles ?
(cf. http://forum.spip.net/fr_262960.html & http://forum.spip.net/fr_266342.html par exemple).
- le long libellé affiché<:dump:texte_sauvegarde:>
ne signale aucunement ces aspects et indications ; le lien vers http://www.spip.net/fr_article1489.html est-il encore pertinent (je n’ai jamais tenté une restauration d’une autre version SQLite : comment se passerait une table non déclarée ou non connue dans le SPIP cible ? ) ?
- d’autre part la lecture du message en fin des erreurs est peu explicite à la lecture (cf. ci-dessous),
il me semblerait plus significatif d’afficher :Nombre de tables non sauvegardées : 12/58
- d’ailleurs l’affichage est incorrect, car il n’indique pas le bon préfixe (en cas de préfixe non-standard !!)
(et de ce fait, je vais avouer avoir jusqu’à présent négligé ces erreurs incomprises, et... patatras !)
_ S’il est intéressant de faire une sauvegarde dé-préfixée (ce que j’ai parfois trouvé utile), peut-etre serait-il intéressant de faire apparaitre (dans un commentaire ou une meta) le préfixe d’origine, à titre de documentation !En recherchant de la documentation, je n’ai trouvé que http://www.spip.net/fr_article3418.html qui mériterait peut-etre d’etre complété avec les informations/explications ci-dessus (et leurs conséquences)...
En complément, le site exemple ayant été migré d’anciennes versions SPIP 2, montre encore les anciennes tables@ spip_mots_xx@
je ne me souviens pas d’un plugin qui éliminerait ces anciennes tables résiduelles (pour ceux qui ne savent utiliser phpMyAdmin ou Adminer)... ce qui supprimerait ensuite ces erreurs / voir par exemple sur les forums SPIP) -
FFmpeg auto rotate video when copying video stream without re-encoding
25 February 2019, by Mahfujur RahmanI have been trying to convert an mp4 (portrait) file to mkv. As the mkv container support any video and audio stream, I am copying the audio and video stream to the output container. The command I’m using
ffmpeg -y -i test.mp4 -vcodec copy -acodec copy test.mkv
File info for
test.mp4
is followingInput #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2019-02-23T11:18:50.000000Z
com.android.version: 8.0.0
Duration: 00:00:25.86, start: 0.000000, bitrate: 12270 kb/s
Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720, 12005 kb/s, SAR 1:1 DAR 16:9, 30 fps, 30 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 90
creation_time : 2019-02-23T11:18:50.000000Z
handler_name : VideoHandle
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default)
Metadata:
creation_time : 2019-02-23T11:18:50.000000Z
handler_name : SoundHandleNow, the problem is that the output video I get from ffmpeg is a 90 degree counter clockwise rotated video. The reason I believe is the following info being removed from output file,
Side data:
displaymatrix: rotation of -90.00 degreesFile info for rotated output file
test.mkv
Input #0, matroska,webm, from 'test.mkv':
Metadata:
MAJOR_BRAND : mp42
MINOR_VERSION : 0
COMPATIBLE_BRANDS: isommp42
COM.ANDROID.VERSION: 8.0.0
ENCODER : Lavf58.12.100
Duration: 00:00:25.87, start: 0.000000, bitrate: 12265 kb/s
Stream #0:0(eng): Video: h264, yuv420p(tv, bt709, progressive), 1280x720, SAR 1:1 DAR 16:9, 30 fps, 30 tbr, 1k tbn, 2k tbc (default)
Metadata:
ROTATE : 90
HANDLER_NAME : VideoHandle
DURATION : 00:00:25.866000000
Stream #0:1(eng): Audio: aac, 48000 Hz, stereo, fltp (default)
Metadata:
HANDLER_NAME : SoundHandle
DURATION : 00:00:25.813000000But when I convert this rotated output
test.mkv
to mp4 again, I get the portrait file. The displaymatrix side data appears again in the file info.Converting the same mp4 file to m4v by copying the steam works fine.
So, this whole thing is very much confusing to me.
Now my question is, how can I convert the mp4 file to mkv without re-encoding and avoid getting rotated output?
In this post they solved it for c++. I am working on android and using ffmpeg android wrapper to use the ffmpeg library. Is there any ffmpeg flag to handle this situation?