
Recherche avancée
Autres articles (74)
-
Creating farms of unique websites
13 avril 2011, parMediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...) -
MediaSPIP : Modification des droits de création d’objets et de publication définitive
11 novembre 2010, parPar défaut, MediaSPIP permet de créer 5 types d’objets.
Toujours par défaut les droits de création et de publication définitive de ces objets sont réservés aux administrateurs, mais ils sont bien entendu configurables par les webmestres.
Ces droits sont ainsi bloqués pour plusieurs raisons : parce que le fait d’autoriser à publier doit être la volonté du webmestre pas de l’ensemble de la plateforme et donc ne pas être un choix par défaut ; parce qu’avoir un compte peut servir à autre choses également, (...) -
Les autorisations surchargées par les plugins
27 avril 2010, parMediaspip core
autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs
Sur d’autres sites (7271)
-
Creating a video from images using ffmpeg libav and libx264 ?
11 janvier 2014, par marikanerI am trying to create a video from images using the ffmpeg library. The images have a size of 1920x1080 and are supposed to be encoded with H.264 using a .mkv container.
I have come across various problems, thinking I am getting closer to a solution, but this one I am really stuck on. With the settings I use, the first X frames (around 40, depending on what and how many images I use for the video) of my video are not encoded. avcodec_encode_video2 does not return any error (return value is 0) with got_picture_ptr = 0.
The result is a video that actually looks as expected, but the first seconds are weirdly jumpy.So this is how I create the video file :
// m_codecContext is an instance variable of type AVCodecContext *
// m_formatCtx is an instance variable of type AVFormatContext *
// outputFileName is a valid filename ending with .mkv
AVOutputFormat *oformat = av_guess_format(NULL, outputFileName, NULL);
if (oformat == NULL)
{
oformat = av_guess_format("mpeg", NULL, NULL);
}
// oformat->video_codec is AV_CODEC_ID_H264
AVCodec *codec = avcodec_find_encoder(oformat->video_codec);
m_codecContext = avcodec_alloc_context3(codec);
m_codecContext->codec_id = oformat->video_codec;
m_codecContext->codec_type = AVMEDIA_TYPE_VIDEO;
m_codecContext->gop_size = 30;
m_codecContext->bit_rate = width * height * 4
m_codecContext->width = width;
m_codecContext->height = height;
m_codecContext->time_base = (AVRational){1,frameRate};
m_codecContext->max_b_frames = 1;
m_codecContext->pix_fmt = AV_PIX_FMT_YUV420P;
m_formatCtx = avformat_alloc_context();
m_formatCtx->oformat = oformat;
m_formatCtx->video_codec_id = oformat->video_codec;
snprintf(m_formatCtx->filename, sizeof(m_formatCtx->filename), "%s", outputFileName);
AVStream *videoStream = avformat_new_stream(m_formatCtx, codec);
if(!videoStream)
{
printf("Could not allocate stream\n");
}
videoStream->codec = m_codecContext;
if(m_formatCtx->oformat->flags & AVFMT_GLOBALHEADER)
{
m_codecContext->flags |= CODEC_FLAG_GLOBAL_HEADER;
}
avcodec_open2(m_codecContext, codec, NULL) < 0);
avio_open(&m_formatCtx->pb, outputFileName.toStdString().c_str(), AVIO_FLAG_WRITE);
avformat_write_header(m_formatCtx, NULL);this is how the frames are added :
void VideoCreator::writeImageToVideo(const QSharedPointer<qimage> &img, int frameIndex)
{
AVFrame *frame = avcodec_alloc_frame();
/* alloc image and output buffer */
int size = m_codecContext->width * m_codecContext->height;
int numBytes = avpicture_get_size(m_codecContext->pix_fmt, m_codecContext->width, m_codecContext->height);
uint8_t *outbuf = (uint8_t *)malloc(numBytes);
uint8_t *picture_buf = (uint8_t *)av_malloc(numBytes);
int ret = av_image_fill_arrays(frame->data, frame->linesize, picture_buf, m_codecContext->pix_fmt, m_codecContext->width, m_codecContext->height, 1);
frame->data[0] = picture_buf;
frame->data[1] = frame->data[0] + size;
frame->data[2] = frame->data[1] + size/4;
frame->linesize[0] = m_codecContext->width;
frame->linesize[1] = m_codecContext->width/2;
frame->linesize[2] = m_codecContext->width/2;
fflush(stdout);
for (int y = 0; y < m_codecContext->height; y++)
{
for (int x = 0; x < m_codecContext->width; x++)
{
unsigned char b = img->bits()[(y * m_codecContext->width + x) * 4 + 0];
unsigned char g = img->bits()[(y * m_codecContext->width + x) * 4 + 1];
unsigned char r = img->bits()[(y * m_codecContext->width + x) * 4 + 2];
unsigned char Y = (0.257 * r) + (0.504 * g) + (0.098 * b) + 16;
frame->data[0][y * frame->linesize[0] + x] = Y;
if (y % 2 == 0 && x % 2 == 0)
{
unsigned char V = (0.439 * r) - (0.368 * g) - (0.071 * b) + 128;
unsigned char U = -(0.148 * r) - (0.291 * g) + (0.439 * b) + 128;
frame->data[1][y/2 * frame->linesize[1] + x/2] = U;
frame->data[2][y/2 * frame->linesize[2] + x/2] = V;
}
}
}
int pts = frameIndex;//(1.0 / 30.0) * 90.0 * frameIndex;
frame->pts = pts;//av_rescale_q(m_codecContext->coded_frame->pts, m_codecContext->time_base, formatCtx->streams[0]->time_base); //(1.0 / 30.0) * 90.0 * frameIndex;
int got_packet_ptr;
AVPacket packet;
av_init_packet(&packet);
packet.data = outbuf;
packet.size = numBytes;
packet.stream_index = formatCtx->streams[0]->index;
packet.flags |= AV_PKT_FLAG_KEY;
packet.pts = packet.dts = pts;
m_codecContext->coded_frame->pts = pts;
ret = avcodec_encode_video2(m_codecContext, &packet, frame, &got_packet_ptr);
if (got_packet_ptr != 0)
{
m_codecContext->coded_frame->pts = pts; // Set the time stamp
if (m_codecContext->coded_frame->pts != (0x8000000000000000LL))
{
pts = av_rescale_q(m_codecContext->coded_frame->pts, m_codecContext->time_base, formatCtx->streams[0]->time_base);
}
packet.pts = pts;
if(m_codecContext->coded_frame->key_frame)
{
packet.flags |= AV_PKT_FLAG_KEY;
}
std::cout << "pts: " << packet.pts << ", dts: " << packet.dts << std::endl;
av_interleaved_write_frame(formatCtx, &packet);
av_free_packet(&packet);
}
free(picture_buf);
free(outbuf);
av_free(frame);
printf("\n");
}
</qimage>and this is the cleanup :
int numBytes = avpicture_get_size(m_codecContext->pix_fmt, m_codecContext->width, m_codecContext->height);
int got_packet_ptr = 1;
int ret;
// for(; got_packet_ptr != 0; i++)
while (got_packet_ptr)
{
uint8_t *outbuf = (uint8_t *)malloc(numBytes);
AVPacket packet;
av_init_packet(&packet);
packet.data = outbuf;
packet.size = numBytes;
ret = avcodec_encode_video2(m_codecContext, &packet, NULL, &got_packet_ptr);
if (got_packet_ptr)
{
av_interleaved_write_frame(m_formatCtx, &packet);
}
av_free_packet(&packet);
free(outbuf);
}
av_write_trailer(formatCtx);
avcodec_close(m_codecContext);
av_free(m_codecContext);
printf("\n");I assume it might be tied to the PTS and DTS values, but I have tried EVERYTHING. The frame index seems to make the most sense. The images are correct, I can save them to files without any problems. I am running out of ideas.
I would be incredibly thankful if there was someone out there who knew better than me...Cheers,
marikanerUPDATE :
If this is of any help this is the output at the end of the video encoding :
[libx264 @ 0x7fffc00028a0] frame I:19 Avg QP:14.24 size:312420
[libx264 @ 0x7fffc00028a0] frame P:280 Avg QP:19.16 size:148867
[libx264 @ 0x7fffc00028a0] frame B:181 Avg QP:21.31 size: 40540
[libx264 @ 0x7fffc00028a0] consecutive B-frames: 24.6% 75.4%
[libx264 @ 0x7fffc00028a0] mb I I16..4: 30.9% 45.5% 23.7%
[libx264 @ 0x7fffc00028a0] mb P I16..4: 4.7% 9.1% 4.5% P16..4: 23.5% 16.6% 12.6% 0.0% 0.0% skip:28.9%
[libx264 @ 0x7fffc00028a0] mb B I16..4: 0.6% 0.5% 0.3% B16..8: 26.7% 11.0% 5.5% direct: 3.9% skip:51.5% L0:39.4% L1:45.0% BI:15.6%
[libx264 @ 0x7fffc00028a0] final ratefactor: 19.21
[libx264 @ 0x7fffc00028a0] 8x8 transform intra:48.2% inter:47.3%
[libx264 @ 0x7fffc00028a0] coded y,uvDC,uvAC intra: 54.9% 53.1% 30.4% inter: 25.4% 13.5% 4.2%
[libx264 @ 0x7fffc00028a0] i16 v,h,dc,p: 41% 29% 11% 19%
[libx264 @ 0x7fffc00028a0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 26% 31% 3% 4% 3% 7% 3% 6%
[libx264 @ 0x7fffc00028a0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 26% 14% 4% 5% 4% 7% 4% 7%
[libx264 @ 0x7fffc00028a0] i8c dc,h,v,p: 58% 26% 13% 3%
[libx264 @ 0x7fffc00028a0] Weighted P-Frames: Y:17.1% UV:3.6%
[libx264 @ 0x7fffc00028a0] ref P L0: 63.1% 21.4% 11.4% 4.1% 0.1%
[libx264 @ 0x7fffc00028a0] ref B L0: 85.7% 14.3%
[libx264 @ 0x7fffc00028a0] kb/s:27478.30 -
Android ffmpeg - 3gp to mp4 videos not playing
17 juillet 2013, par santhoshI am doing an android application which is used to merge two videos and after merge completed play the result video. For this I am using ffmpeg.
When I record two mpeg or mp4 videos, the result merged video playing fine. Now I record the videos as 3gp and convert it into mp4 and merged it. Then the result video is not playing.
Can anybody help me What may be the problem ?
-
Why ffmpeg command results in blank video ?
17 juillet 2013, par kheyaI am trying to conver mov file to H264 encoded mp4
Same command converts another mov file just fine.But fails for a particular mov file. Original video is 29.6MB after conversion I get 966KB
I get the sound and duration right. But all the frames are black even though original video is fine.
Here is the command :
ffmpeg -i file3.mov -movflags +faststart -vcodec libx264 -preset slow -crf 20 -vf -threads 0 -acodec libvo_aacenc -b:a 128k "file3.mp4"
Here is the result of ffmpeg -i : >ffmpeg.exe -i file3.mov
ffmpeg version N-54691-g7f4a1fd Copyright (c) 2000-2013 the FFmpeg developers
built on Jul 12 2013 16:31:48 with gcc 4.7.3 (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-libvo-aacenc --enable-libvo-
amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --
enable-libxvid --enable-zlib
libavutil 52. 39.100 / 52. 39.100
libavcodec 55. 18.102 / 55. 18.102
libavformat 55. 12.102 / 55. 12.102
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 80.101 / 3. 80.101
libswscale 2. 3.100 / 2. 3.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 3.100 / 52. 3.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000000003077e0] sample aspect ratio already set to
118:81, ignoring 'pasp' atom (10000:7031)
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'file3.mov':
Metadata:
creation_time : 2009-02-12 01:19:22
Duration: 00:00:08.00, start: 0.000000, bitrate: 30338 kb/s
Stream #0:0(eng): Video: dvvideo (dvpp / 0x70707664), yuv411p, 720x576 [SAR
64:45 DAR 16:9], 28800 kb/s, SAR 118:81 DAR 295:162, 25 fps, 25 tbr, 600 tbn, 25
tbc
Metadata:
creation_time : 2009-02-12 01:19:22
handler_name : Apple Alias Data Handler
Stream #0:1(eng): Audio: pcm_s16be (twos / 0x736F7774), 48000 Hz, stereo, s1
6, 1536 kb/s
Metadata:
creation_time : 2009-02-12 01:19:22
handler_name : Apple Alias Data HandlerDuring conversion here is what I see (nothing unusual or no errors) :
ffmpeg version N-54691-g7f4a1fd Copyright (c) 2000-2013 the FFmpeg developers
built on Jul 12 2013 16:31:48 with gcc 4.7.3 (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-libvo-aacenc --enable-libvo-
amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --
enable-libxvid --enable-zlib
libavutil 52. 39.100 / 52. 39.100
libavcodec 55. 18.102 / 55. 18.102
libavformat 55. 12.102 / 55. 12.102
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 80.101 / 3. 80.101
libswscale 2. 3.100 / 2. 3.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 3.100 / 52. 3.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000000024aafe0] sample aspect ratio already set to
118:81, ignoring 'pasp' atom (10000:7031)
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'file3.mov':
Metadata:
creation_time : 2009-02-12 01:19:22
Duration: 00:00:08.00, start: 0.000000, bitrate: 30338 kb/s
Stream #0:0(eng): Video: dvvideo (dvpp / 0x70707664), yuv411p, 720x576 [SAR
64:45 DAR 16:9], 28800 kb/s, SAR 118:81 DAR 295:162, 25 fps, 25 tbr, 600 tbn, 25
tbc
Metadata:
creation_time : 2009-02-12 01:19:22
handler_name : Apple Alias Data Handler
Stream #0:1(eng): Audio: pcm_s16be (twos / 0x736F7774), 48000 Hz, stereo, s1
6, 1536 kb/s
Metadata:
creation_time : 2009-02-12 01:19:22
handler_name : Apple Alias Data Handler
No pixel format specified, yuv422p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 0000000000347340] using SAR=118/81
[libx264 @ 0000000000347340] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
AVX
[libx264 @ 0000000000347340] profile High 4:2:2, level 2.1, 4:2:2 8-bit
[libx264 @ 0000000000347340] 264 - core 133 r2334 a3ac64b - H.264/MPEG-4 AVC cod
ec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=1 r
ef=5 deblock=1:0:0 analyse=0x3:0x113 me=umh subme=8 psy=1 psy_rd=1.00:0.00 mixed
_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pski
p=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 deci
mate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_
adapt=2 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=2
5 scenecut=40 intra_refresh=0 rc_lookahead=50 rc=crf mbtree=1 crf=20.0 qcomp=0.6
0 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'file4a.mp4':
Metadata:
encoder : Lavf55.12.102
Stream #0:0(eng): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv422p, 4
80x320 [SAR 118:81 DAR 59:27], q=-1--1, 12800 tbn, 25 tbc
Metadata:
creation_time : 2009-02-12 01:19:22
handler_name : Apple Alias Data Handler
Stream #0:1(eng): Audio: aac (libvo_aacenc) ([64][0][0][0] / 0x0040), 48000
Hz, stereo, s16, 128 kb/s
Metadata:
creation_time : 2009-02-12 01:19:22
handler_name : Apple Alias Data Handler
Stream mapping:
Stream #0:0 -> #0:0 (dvvideo -> libx264)
Stream #0:1 -> #0:1 (pcm_s16be -> libvo_aacenc)
Press [q] to stop, [?] for help
[swscaler @ 00000000024b0740] Warning: data is not aligned! This can lead to a s
peedloss
frame= 78 fps=0.0 q=25.0 size= 128kB time=00:00:02.14 bitrate= 487.8kbits/
frame= 113 fps=109 q=25.0 size= 272kB time=00:00:04.27 bitrate= 520.9kbits/
frame= 145 fps= 94 q=25.0 size= 399kB time=00:00:05.36 bitrate= 609.2kbits/
frame= 182 fps= 89 q=25.0 size= 571kB time=00:00:06.45 bitrate= 725.0kbits/
Starting second pass: moving header on top of the file
frame= 200 fps= 70 q=-1.0 Lsize= 965kB time=00:00:08.00 bitrate= 987.2kbits
/s
video:832kB audio:126kB subtitle:0 global headers:0kB muxing overhead 0.755121%
[libx264 @ 0000000000347340] frame I:1 Avg QP:21.14 size: 39885
[libx264 @ 0000000000347340] frame P:50 Avg QP:21.80 size: 7412
[libx264 @ 0000000000347340] frame B:149 Avg QP:26.25 size: 2960
[libx264 @ 0000000000347340] consecutive B-frames: 0.5% 0.0% 1.5% 98.0%
[libx264 @ 0000000000347340] mb I I16..4: 13.7% 46.7% 39.7%
[libx264 @ 0000000000347340] mb P I16..4: 0.5% 19.7% 3.8% P16..4: 32.8% 11.9
% 14.1% 0.0% 0.0% skip:17.1%
[libx264 @ 0000000000347340] mb B I16..4: 0.0% 5.1% 1.3% B16..8: 14.4% 9.2
% 2.9% direct: 7.3% skip:59.8% L0:42.8% L1:38.3% BI:19.0%
[libx264 @ 0000000000347340] 8x8 transform intra:79.4% inter:71.7%
[libx264 @ 0000000000347340] direct mvs spatial:97.3% temporal:2.7%
[libx264 @ 0000000000347340] coded y,uvDC,uvAC intra: 92.8% 80.1% 26.3% inter: 2
4.2% 28.8% 8.1%
[libx264 @ 0000000000347340] i16 v,h,dc,p: 64% 17% 3% 16%
[libx264 @ 0000000000347340] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 1% 33% 4% 3% 8%
2% 35% 2% 11%
[libx264 @ 0000000000347340] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 3% 23% 5% 4% 11%
5% 33% 4% 13%
[libx264 @ 0000000000347340] i8c dc,h,v,p: 38% 40% 14% 8%
[libx264 @ 0000000000347340] Weighted P-Frames: Y:2.0% UV:0.0%
[libx264 @ 0000000000347340] ref P L0: 39.9% 10.0% 25.6% 8.7% 15.3% 0.6%
[libx264 @ 0000000000347340] ref B L0: 76.9% 15.1% 5.7% 2.3%
[libx264 @ 0000000000347340] ref B L1: 96.3% 3.7%
[libx264 @ 0000000000347340] kb/s:851.49