
Recherche avancée
Autres articles (102)
-
MediaSPIP v0.2
21 juin 2013, parMediaSPIP 0.2 est la première version de MediaSPIP stable.
Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
Comme pour la version précédente, 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 (...) -
Gestion des droits de création et d’édition des objets
8 février 2011, parPar défaut, beaucoup de fonctionnalités sont limitées aux administrateurs mais restent configurables indépendamment pour modifier leur statut minimal d’utilisation notamment : la rédaction de contenus sur le site modifiables dans la gestion des templates de formulaires ; l’ajout de notes aux articles ; l’ajout de légendes et d’annotations sur les images ;
-
Mise à disposition des fichiers
14 avril 2011, parPar défaut, lors de son initialisation, MediaSPIP ne permet pas aux visiteurs de télécharger les fichiers qu’ils soient originaux ou le résultat de leur transformation ou encodage. Il permet uniquement de les visualiser.
Cependant, il est possible et facile d’autoriser les visiteurs à avoir accès à ces documents et ce sous différentes formes.
Tout cela se passe dans la page de configuration du squelette. Il vous faut aller dans l’espace d’administration du canal, et choisir dans la navigation (...)
Sur d’autres sites (14428)
-
Encoding with ffmpeg : video quality drops
21 mai 2014, par Adi UliciI’m trying to encode a set of pictures into a video with ffmpeg. I’m new to this stuff, but I managed to get it work. I have only one problem : the first second or two of video look good but as the time goes the video quality keeps dropping and dropping. At the end (it’s a video of about 16 seconds) the quality is really bad and I can’t understand why.
I’m using AV_CODEC_ID_MPEG1VIDEO as video codec (frankly, it’s the only one I could make work) and here is a sample of my code :
c = avcodec_alloc_context3(codec);
if (!c) {
fprintf(stderr, "Could not allocate video codec context\n");
exit(1);
}
c->bit_rate = 400000;
c->width = width;
c->height = height;
struct AVRational time_base = {1, 25};
c->time_base = time_base;
c->gop_size = 10;
c->max_b_frames = 1;
c->pix_fmt = AV_PIX_FMT_YUV420P;
if (codec_id == AV_CODEC_ID_H264)
av_opt_set(c->priv_data, "preset", "slow", 0);
// Open the codec
if (avcodec_open2(c, codec, NULL) < 0) {
fprintf(stderr, "Could not open codec\n");
exit(1);
}
fopen_s(&f, filename, "wb");
if (!f) {
fprintf(stderr, "Could not open %s\n", filename);
exit(1);
}
frame = av_frame_alloc();
if (!frame) {
fprintf(stderr, "Could not allocate video frame\n");
exit(1);
}
frame->format = c->pix_fmt;
frame->width = c->width;
frame->height = c->height;
ret = av_image_alloc(frame->data, frame->linesize, c->width, c->height,
c->pix_fmt, 32);
if (ret < 0) {
fprintf(stderr, "Could not allocate raw picture buffer\n");
exit(1);
}
struct SwsContext *frameConvertContext = sws_getContext(width, height,
PIX_FMT_RGB24,
c->width, c->height,
c->pix_fmt,
SWS_LANCZOS | SWS_ACCURATE_RND, NULL, NULL, NULL);
for (i = 0; i < framesNr; i++) {
// Read an image
std::stringstream filename;
filename << "input/image-" << (i+1) << ".jpg";
Image* img;
img = Image::fromJpeg((char*) filename.str().c_str());
int srcSliceY[1] = { img->getWidth() * 3 };
const uint8_t* imgbuf[1] = { (uint8_t*) img->getData(sizeof(uint8_t)) };
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
fflush(stdout);
frameConvertContext = sws_getCachedContext(frameConvertContext, width, height,
PIX_FMT_RGB24,
c->width, c->height,
c->pix_fmt,
SWS_LANCZOS | SWS_ACCURATE_RND, NULL, NULL, NULL);
sws_scale(frameConvertContext, imgbuf, srcSliceY, 0, img->getHeight(), frame->data, frame->linesize);
frame->pts = i;
/* encode the image */
ret = avcodec_encode_video2(c, &pkt, frame, &got_output);
if (ret < 0) {
fprintf(stderr, "Error encoding frame\n");
exit(1);
}
if (got_output) {
printf(".");
fwrite(pkt.data, 1, pkt.size, f);
av_free_packet(&pkt);
}
// Free the memory
delete img;
}Any tips ? Thanks a lot !
-
Encoding video using FFmpeg and FreeImage
14 mai 2014, par mikeI have to make a video encoder to encode video using mjpeg codec from many jpgs saved on the disk. I use FreeImage to load images and ffmpeg to encode. Unfortunately, the output video isn’t that what I expect. I can’t play it in MPC. VLC can play it but there is only a single quick flash of the last picture I loaded. I want to have 1 fps video and for example I loaded 4 frames so my video should last 4 seconds.
Input pictures are in BGR24 pixel format.
What is more, when I run my code I got swscaler warning that picture format YUVJ420P is deprecated but I cant find another pixel format which is suitable for MJPEG codec.
Here is my source code :
AVPixelFormat in_pix_fmt = AV_PIX_FMT_BGR24;
AVPixelFormat out_pix_fmt = AV_PIX_FMT_YUVJ420P;
AVCodec *pCodec;
AVCodecContext *pCodecCtx = NULL;
int out_size = 0;
int size, outbuf_size, i, outpic_size, w, h;
FILE *file;
const char *videofile_name = "test_video_cpp.avi";
AVFrame *picture, *outpic;
uint8_t *outbuf, *picture_buf, *outpic_buf;
av_register_all();
pCodec = avcodec_find_encoder(CODEC_ID_MJPEG);
if (!pCodec)
{
cout << "Codec not found\n\n";
return 1;
}
pCodecCtx = avcodec_alloc_context3(pCodec);
picture = avcodec_alloc_frame();
outpic = avcodec_alloc_frame();
pCodecCtx->codec_id = CODEC_ID_MJPEG;
pCodecCtx->codec_type = AVMEDIA_TYPE_VIDEO;
pCodecCtx->pix_fmt = out_pix_fmt;
pCodecCtx->bit_rate = 400000;
pCodecCtx->width = 1688;
pCodecCtx->height = 728;
pCodecCtx->time_base.num = 1;
pCodecCtx->time_base.den = 1; //fps
pCodecCtx->max_b_frames = 0;
outbuf_size = 500000;
outbuf = new uint8_t[outbuf_size];
if (avcodec_open2(pCodecCtx, pCodec, NULL) < 0) //open codec
{
cout << "Could not open codec\n";
exit(1);
}
file = fopen(videofile_name, "wb"); //open file
if (!file)
{
cout << "Could not open " << videofile_name << endl;
exit(1);
}
outpic_size = avpicture_get_size(out_pix_fmt, pCodecCtx->width, pCodecCtx->height);
outpic_buf = new uint8_t[outpic_size];
cout << "Outpic size was setted to: " << outpic_size << endl;
size = pCodecCtx->width * pCodecCtx->height;
picture_buf = new uint8_t[size * 3];
for (i = 1; i < 5; i++)
{
fflush(stdout);
stringstream ss;
ss << i;
filename = name + ss.str() + ext;
path = dir + filename;
dib = FreeImage_Load(FIF_JPEG, path.c_str(), 0);
picture_buf = FreeImage_GetBits(dib);
h = FreeImage_GetHeight(dib);
w = FreeImage_GetWidth(dib);
avpicture_fill((AVPicture*)picture, picture_buf, in_pix_fmt, w, h);
avpicture_fill((AVPicture*)outpic, outpic_buf, out_pix_fmt, pCodecCtx->width, pCodecCtx->height);
struct SwsContext* fooContext = sws_getContext(w, h, in_pix_fmt, pCodecCtx->width, pCodecCtx->height, out_pix_fmt, SWS_BICUBIC, NULL, NULL, NULL);
sws_scale(fooContext, picture->data, picture->linesize, 0, pCodecCtx->height, outpic->data, outpic->linesize);
//encode single frame
out_size = avcodec_encode_video(pCodecCtx, outpic_buf, outpic_size, outpic);
cout << "encoding frame " << i << "(size=" << out_size << ")\n";
fwrite(outbuf, 1, out_size, file);
}
//encode delayed frames
for ( ; out_size; i++)
{
fflush(stdout);
out_size = avcodec_encode_video(pCodecCtx, outbuf, outbuf_size, NULL);
cout << "write frame " << i << "(size=" << out_size << ")\n";
fwrite(outbuf, 1, out_size, file);
}
outbuf[0] = 0x00;
outbuf[1] = 0x00;
outbuf[2] = 0x01;
outbuf[3] = 0xb7;
fwrite(outbuf, 1, 4, file);
fclose(file);
delete outbuf;
avcodec_close(pCodecCtx);
av_free(pCodecCtx);
avpicture_free((AVPicture*)picture);
avpicture_free((AVPicture*)outpic);
delete picture_buf;
delete outpic_buf; -
FFMPEG subtitle : mov_text removal
27 mars 2014, par user3461178I have problems with subtitles. My video playout can not play them. So I have been trying to remove it.
C:\Users\Jakub\Desktop\eclipse\workspace\tvpohoda_archiv>"c:\\lib/ffmpeg/bin/ffm
peg.exe" -i "videa/1050028-CITRON_-_Uz_zavrate_ridnou_c.m4v" -sn -c:a copy -c:v
copy "videa/1050028-CITRON_-_Uz_zavrate_ridnou_c2.mov"
ffmpeg version N-57650-gcb52d6d Copyright (c) 2000-2013 the FFmpeg developers
built on Oct 30 2013 20:35:46 with gcc 4.8.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aa
cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavp
ack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 48.100 / 52. 48.100
libavcodec 55. 39.100 / 55. 39.100
libavformat 55. 19.104 / 55. 19.104
libavdevice 55. 5.100 / 55. 5.100
libavfilter 3. 90.100 / 3. 90.100
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'videa/1050028-CITRON_-_Uz_zavrate_ridno
u_c.m4v':
Metadata:
major_brand : M4V
minor_version : 512
compatible_brands: isomiso2avc1
encoder : Lavf55.19.104
Duration: 00:04:56.49, start: 0.021333, bitrate: 7239 kb/s
Chapter #0.0: start 0.000000, end 296.400000
Metadata:
title : Chapter 1
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 720x576 [
SAR 212:225 DAR 53:45], 6997 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 24
0 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream #0:2(eng): Subtitle: mov_text (text / 0x74786574)
Metadata:
handler_name : SubtitleHandler
File 'videa/1050028-CITRON_-_Uz_zavrate_ridnou_c2.mov' already exists. Overwrite
? [y/N] y
Output #0, mov, to 'videa/1050028-CITRON_-_Uz_zavrate_ridnou_c2.mov':
Metadata:
major_brand : M4V
minor_version : 512
compatible_brands: isomiso2avc1
encoder : Lavf55.19.104
Chapter #0.0: start 0.021000, end 296.421000
Metadata:
title : Chapter 1
Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p, 720x576 [SAR 212
:225 DAR 53:45], q=2-31, 6997 kb/s, 25 fps, 12800 tbn, 12800 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, 240 kb/s
(default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 7408 fps=0.0 q=-1.0 Lsize= 262031kB time=00:04:56.49 bitrate=7239.9kbits
/s
video:253116kB audio:8700kB subtitle:0 global headers:0kB muxing overhead 0.0820
40%Or :
C:\Users\Jakub\Desktop\eclipse\workspace\tvpohoda_archiv>"c:\\lib/ffmpeg/bin/ffm
peg.exe" -i "videa/1050028-CITRON_-_Uz_zavrate_ridnou_c.m4v" -map 0:0 -map 0:1
-c:a copy -c:v copy "videa/1050028-CITRON_-_Uz_zavrate_ridnou_c2.mov"
ffmpeg version N-57650-gcb52d6d Copyright (c) 2000-2013 the FFmpeg developers
built on Oct 30 2013 20:35:46 with gcc 4.8.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aa
cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavp
ack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 48.100 / 52. 48.100
libavcodec 55. 39.100 / 55. 39.100
libavformat 55. 19.104 / 55. 19.104
libavdevice 55. 5.100 / 55. 5.100
libavfilter 3. 90.100 / 3. 90.100
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'videa/1050028-CITRON_-_Uz_zavrate_ridno
u_c.m4v':
Metadata:
major_brand : M4V
minor_version : 512
compatible_brands: isomiso2avc1
encoder : Lavf55.19.104
Duration: 00:04:56.49, start: 0.021333, bitrate: 7239 kb/s
Chapter #0.0: start 0.000000, end 296.400000
Metadata:
title : Chapter 1
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 720x576 [
SAR 212:225 DAR 53:45], 6997 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 24
0 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream #0:2(eng): Subtitle: mov_text (text / 0x74786574)
Metadata:
handler_name : SubtitleHandler
Output #0, mov, to 'videa/1050028-CITRON_-_Uz_zavrate_ridnou_c2.mov':
Metadata:
major_brand : M4V
minor_version : 512
compatible_brands: isomiso2avc1
encoder : Lavf55.19.104
Chapter #0.0: start 0.021000, end 296.421000
Metadata:
title : Chapter 1
Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p, 720x576 [SAR 212
:225 DAR 53:45], q=2-31, 6997 kb/s, 25 fps, 12800 tbn, 12800 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, 240 kb/s
(default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 2702 fps=0.0 q=-1.0 size= 95498kB time=00:01:48.03 bitrate=7241.6kbits/
frame= 4436 fps=4435 q=-1.0 size= 157319kB time=00:02:57.38 bitrate=7265.2kbits
frame= 6296 fps=4196 q=-1.0 size= 223194kB time=00:04:11.77 bitrate=7262.0kbits
frame= 7408 fps=4121 q=-1.0 Lsize= 262031kB time=00:04:56.49 bitrate=7239.9kbit
s/s
video:253116kB audio:8700kB subtitle:0 global headers:0kB muxing overhead 0.0820
40%But it did not worked, subtitles have stayed there.
i am normally starting this ffmpeg from java but this files are from command line
Please can you help me ?