
Recherche avancée
Autres articles (52)
-
Mise à jour de la version 0.1 vers 0.2
24 juin 2013, parExplications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...) -
Personnaliser en ajoutant son logo, sa bannière ou son image de fond
5 septembre 2013, parCertains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;
-
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 (9945)
-
Encode video with FFmpeg fps have been wrong
7 novembre 2016, par Burak HamuryenI’m trying to encod a video with FFmpeg but i have a problem about fps.
So i build the sample code as followsAVCodec *codec;
AVCodecContext *c = NULL;
int i, ret, x, y, got_output;
FILE *f;
AVFrame *frame;
AVPacket pkt;
uint8_t endcode[] = { 0, 0, 1, 0xb7 };
printf("Encode video file %s\n", filename);
/* find the mpeg1 video encoder */
codec = avcodec_find_encoder((AVCodecID)codec_id);
if (!codec) {
fprintf(stderr, "Codec not found\n");
exit(1);
}
c = avcodec_alloc_context3(codec);
if (!c) {
fprintf(stderr, "Could not allocate video codec context\n");
exit(1);
}
/* put sample parameters */
c->bit_rate = 400000;
/* resolution must be a multiple of two */
c->width = 352;
c->height = 288;
/* frames per second */
c->time_base.num = 1;
c->time_base.den = 5; //changed
/* emit one intra frame every ten frames
* check frame pict_type before passing frame
* to encoder, if frame->pict_type is AV_PICTURE_TYPE_I
* then gop_size is ignored and the output of encoder
* will always be I frame irrespective to gop_size
*/
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 it */
if (avcodec_open2(c, codec, NULL) < 0) {
fprintf(stderr, "Could not open codec\n");
exit(1);
}
f = fopen(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;
/* the image can be allocated by any means and av_image_alloc() is
* just the most convenient way if av_malloc() is to be used */
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);
}
/* encode 5 second of video */
for (i = 0; i < 25; i++) {
av_init_packet(&pkt);
pkt.data = NULL; // packet data will be allocated by the encoder
pkt.size = 0;
fflush(stdout);
/* prepare a dummy image */
/* Y */
for (y = 0; y < c->height; y++) {
for (x = 0; x < c->width; x++) {
frame->data[0][y * frame->linesize[0] + x] = x + y + i * 3;
}
}
/* Cb and Cr */
for (y = 0; y < c->height / 2; y++) {
for (x = 0; x < c->width / 2; x++) {
frame->data[1][y * frame->linesize[1] + x] = 128 + y + i * 2;
frame->data[2][y * frame->linesize[2] + x] = 64 + x + i * 5;
}
}
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("Write frame %3d (size=%5d)\n", i, pkt.size);
fwrite(pkt.data, 1, pkt.size, f);
av_free_packet(&pkt);
}
}
/* get the delayed frames */
for (got_output = 1; got_output; i++) {
fflush(stdout);
ret = avcodec_encode_video2(c, &pkt, NULL, &got_output);
if (ret < 0) {
fprintf(stderr, "Error encoding frame\n");
exit(1);
}
if (got_output) {
printf("Write frame %3d (size=%5d)\n", i, pkt.size);
fwrite(pkt.data, 1, pkt.size, f);
av_free_packet(&pkt);
}
}
/* add sequence end code to have a real mpeg file */
fwrite(endcode, 1, sizeof(endcode), f);
fclose(f);
avcodec_close(c);
av_free(c);
av_freep(&frame->data[0]);
av_frame_free(&frame);
printf("\n");and I changed the following parts from the original
c->time_base.num = 1;
c->time_base.den = 5;after these changes, i expect a video to be composed of 5 seconds and 5 fps.
But when i play the output video file, the video ends in 1 2 seconds.
The ffprob output of output video is as follows.Edit :
ffprobe output added as a textffprobe version 2.0.1 Copyright (c) 2007-2013 the FFmpeg developers
built on Sep 26 2013 02:00:03 with gcc 4.8.1 (GCC)
configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 38.100 / 52. 38.100
libavcodec 55. 18.102 / 55. 18.102
libavformat 55. 12.100 / 55. 12.100
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 79.101 / 3. 79.101
libswscale 2. 3.100 / 2. 3.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 3.100 / 52. 3.100
Input #0, h264, from 'C:\Users\bhamuryen\Desktop\Dev\Test\ffmpeg_test\ffmpeg_test\test.h264':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (High), yuv420p, 352x288, 5 fps, 5 tbr, 1200k tbn, 10 tbc
[STREAM]
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=High
codec_type=video
codec_time_base=1/10
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
width=352
height=288
has_b_frames=1
sample_aspect_ratio=0:1
display_aspect_ratio=0:1
pix_fmt=yuv420p
level=13
timecode=N/A
id=N/A
r_frame_rate=10/2
avg_frame_rate=5/1
time_base=1/1200000
start_pts=N/A
start_time=N/A
duration_ts=N/A
duration=N/A
bit_rate=N/A
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0The output video file played with VLC and VLC statistic is as follows.
As shown, i setted fps 5 but vlc read it like 10 fps also ffprobe say to us
Stream #0:0 : Video : h264 (High), yuv420p, 352x288, 5 fps, 5 tbr, 1200k tbn, 10 tbc
and
codec_time_base=1/10
i think the important thing is codec_time_base=1/10 and 10 tbc.
What is wrong in this code ? i don’t know exactly the reason for the problem.
How can i create a video(5 fps -10 fps or custom fps) and play correctly the created video ?Thanks for your help.
-
How to encode H.264 video using FFmpeg C API and then open the output with a media player ?
4 avril 2016, par GummiBI’m trying to encode a H.264 video with the FFMPEG C API.
I have successfully compiled and executed the decoding/encoding example provided by FFMPEG.The problem I’m facing is that the .mpg file (encoded with AV_CODEC_ID_MPEG1VIDEO) the example creates works. Windows creates a thumbnail and everything. On the other hand the .h264 (encoded with AV_CODEC_ID_H264) file does not. When I try to play the file in VLC the play/pause button just flickers, no thumbnail in windows, no nothing.
During encoding libx264 reports the following :
[libx264 @ 004b81a0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 004b81a0] profile High, level 1.3
[libx264 @ 004b81a0] frame I:3 Avg QP:26.79 size: 2116
[libx264 @ 004b81a0] frame P:12 Avg QP:26.60 size: 789
[libx264 @ 004b81a0] frame B:10 Avg QP:31.39 size: 499
[libx264 @ 004b81a0] consecutive B-frames: 20.0% 80.0%
[libx264 @ 004b81a0] mb I I16..4: 78.3% 11.6% 10.1%
[libx264 @ 004b81a0] mb P I16..4: 77.4% 0.6% 0.1% P16..4: 20.3% 0.7% 0.9% 0.0% 0.0% skip: 0.0%
[libx264 @ 004b81a0] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 9.4% 0.2% 0.0% direct:11.0% skip:79.4% L0:25.4% L1:35.4% BI:39.2%
[libx264 @ 004b81a0] final ratefactor: 17.03
[libx264 @ 004b81a0] 8x8 transform intra:3.4% inter:31.3%
[libx264 @ 004b81a0] direct mvs spatial:0.0% temporal:100.0%
[libx264 @ 004b81a0] coded y,uvDC,uvAC intra: 4.4% 35.8% 1.6% inter: 1.3% 34.5% 9.5%
[libx264 @ 004b81a0] i16 v,h,dc,p: 0% 0% 0% 100%
[libx264 @ 004b81a0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 7% 20% 17% 49% 0% 0% 0% 1% 6%
[libx264 @ 004b81a0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 14% 7% 18% 45% 2% 7% 2% 3% 2%
[libx264 @ 004b81a0] i8c dc,h,v,p: 2% 6% 4% 88%
[libx264 @ 004b81a0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 004b81a0] ref P L0: 95.6% 1.6% 2.2% 0.5% 0.2%
[libx264 @ 004b81a0] ref B L0: 67.5% 28.5% 3.2% 0.8%
[libx264 @ 004b81a0] kb/s:166.45"ffprobe.exe test.h264 -show_streams" returns
[STREAM]
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=High
codec_type=video
codec_time_base=1/50
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
width=352
height=288
has_b_frames=1
sample_aspect_ratio=0:1
display_aspect_ratio=0:1
pix_fmt=yuv420p
level=13
timecode=N/A
id=N/A
r_frame_rate=50/2
avg_frame_rate=25/1
time_base=1/1200000
start_pts=N/A
start_time=N/A
duration_ts=N/A
duration=N/A
bit_rate=N/A
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
[/STREAM]There you can see :
start_time=N/A
duration_ts=N/A
duration=N/AI have tried countless changes to the AVCodecContext and multitude of parameters options to av_opt_set function. Still no luck getting a working H.264 video. I have even tried different builds of FFmpeg. No luck.
I’m using the "FFmpeg git-0fb64da 32-bit Dev" build from Zeranoe and MinGw 4.7.2
-
FFmpeg only reading one channel
29 août 2017, par AbstractDissonanceTrying to read a stereo wav file and ffmpeg is only reading one channel. ffprobe returns 2 channels.
I have used
-ac 2
and then added-channel_layout stereo
but all return 1 channel(or basically filling half the buffer I created).Basically the output size of ffmpeg is about half the wav file size.
What I would like is for it to return every channel in
Channel1_sample1, channel2_sample1, ..., ChannelN_sample1, channel1_sample2,
etc...But, in reality, I’d rather just have it work with stereo ;) I’m giving it plenty large enough buffer to read to, so that isn’t the problem either.
Here is the output
ffprobe.exe -hide_banner -v quiet -print_format flat -show_streams -i temp.wav
streams.stream.0.index=0
streams.stream.0.codec_name="pcm_s16le"
streams.stream.0.codec_long_name="PCM signed 16-bit little-endian"
streams.stream.0.profile="unknown"
streams.stream.0.codec_type="audio"
streams.stream.0.codec_time_base="1/44100"
streams.stream.0.codec_tag_string="[1][0][0][0]"
streams.stream.0.codec_tag="0x0001"
streams.stream.0.sample_fmt="s16"
streams.stream.0.sample_rate="44100"
streams.stream.0.channels=2
streams.stream.0.channel_layout="unknown"
streams.stream.0.bits_per_sample=16
streams.stream.0.id="N/A"
streams.stream.0.r_frame_rate="0/0"
streams.stream.0.avg_frame_rate="0/0"
streams.stream.0.time_base="1/44100"
streams.stream.0.start_pts="N/A"
streams.stream.0.start_time="N/A"
streams.stream.0.duration_ts=14200200
streams.stream.0.duration="322.000000"
streams.stream.0.bit_rate="1411200"
streams.stream.0.max_bit_rate="N/A"
streams.stream.0.bits_per_raw_sample="N/A"
streams.stream.0.nb_frames="N/A"
streams.stream.0.nb_read_frames="N/A"
streams.stream.0.nb_read_packets="N/A"
streams.stream.0.disposition.default=0
streams.stream.0.disposition.dub=0
streams.stream.0.disposition.original=0
streams.stream.0.disposition.comment=0
streams.stream.0.disposition.lyrics=0
streams.stream.0.disposition.karaoke=0
streams.stream.0.disposition.forced=0
streams.stream.0.disposition.hearing_impaired=0
streams.stream.0.disposition.visual_impaired=0
streams.stream.0.disposition.clean_effects=0
streams.stream.0.disposition.attached_pic=0
streams.stream.0.disposition.timed_thumbnails=0
ffmpeg.exe -i temp.wav -loglevel quiet -f s16le -ac 2 -channel_layout stereo -temp.wav is just a standard stereo wav file.