
Recherche avancée
Médias (91)
-
Corona Radiata
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Lights in the Sky
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Head Down
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Echoplex
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Discipline
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Letting You
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
Autres articles (16)
-
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 ;
-
Ecrire une actualité
21 juin 2013, parPrésentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
Vous pouvez personnaliser le formulaire de création d’une actualité.
Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...) -
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir
Sur d’autres sites (4065)
-
video after ffmpeg command conversion is not playing on windows
10 décembre 2015, par Hemant KumarI am stuck at a very weird and complex problem, hoping if anyone know the solution :
I am converting user uploaded video using ffmpeg command on server and it was working fine as well. Today I found that if a video is recorded by a webcam from windows, is playing well in linux as well as on windows where as if user is creating a video by webcam from linux, is playing only on linux (any browser). On window it’s screen either show loading icon or black screen while audio is working fine.
I am using following codec :
['-strict', '-2', '-preset slow', '-maxrate 500k', '-bufsize 1000k', vfOption, '-threads 0', '-ab 64k', '-movflags faststart','-vf scale=-1:480', '-metadata:s:v:0 rotate=0', '-vcodec libx264']
I work on linux and using html5 player on my website. I am converting video in mp4 format.
Input :
ffmpeg -i /<server path="path">/stream_FE2AF05B-E630-1F7B-390B-37325B31B362.flv -strict -2 -vcodec libx264 -preset slow -vb 500k -maxrate 500k -bufsize 1000k -vf 'scale=-1:480 ' -threads 0 -ab 64k -s 640x480 -movflags faststart -metadata:s:v:0 rotate=0 /<server path="path">/testing.mp4
</server></server>Output :
ffmpeg version 2.2.5 Copyright (c) 2000-2014 the FFmpeg developers
built on Aug 1 2014 09:24:02 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libtheora --enable-libx264 --enable-libvpx --enable-libmp3lame
libavutil 52. 66.100 / 52. 66.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 2.100 / 4. 2.100
libswscale 2. 5.102 / 2. 5.102
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100
Input #0, flv, from '/<server path="path">/stream_FE2AF05B-E630-1F7B-390B-37325B31B362.flv':
Metadata:
canSeekToEnd : true
Duration: 00:00:04.04, start: 0.000000, bitrate: 636 kb/s
Stream #0:0: Video: flv1, yuv420p, 640x480, 1k tbr, 1k tbn, 1k tbc
Stream #0:1: Audio: nellymoser, 44100 Hz, mono, flt
[libx264 @ 0x23c5340] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x23c5340] profile High, level 5.2
[libx264 @ 0x23c5340] 264 - core 142 r2453 ea0ca51 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=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_pskip=1 chroma_qp_offset=-2 threads=24 lookahead_threads=3 sliced_threads=0 nr=0 decimate=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=25 scenecut=40 intra_refresh=0 rc_lookahead=50 rc=cbr mbtree=1 bitrate=500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=500 vbv_bufsize=1000 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to '/<server path="path">/testing.mp4':
Metadata:
canSeekToEnd : true
encoder : Lavf55.33.100
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 640x480, q=-1--1, 500 kb/s, 16k tbn, 1k tbc
Metadata:
rotate : 0
Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, mono, fltp, 64 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (flv -> libx264)
Stream #0:1 -> #0:1 (nellymoser -> aac)
Press [q] to stop, [?] for help
[mp4 @ 0x23c0200] Starting second pass: moving the moov atom to the beginning of the file2 drop=0
frame= 4020 fps=706 q=-1.0 Lsize= 355kB time=00:00:04.08 bitrate= 712.0kbits/s dup=3931 drop=0
video:271kB audio:32kB subtitle:0 data:0 global headers:0kB muxing overhead 16.957901%
[libx264 @ 0x23c5340] frame I:17 Avg QP:27.55 size: 7119
[libx264 @ 0x23c5340] frame P:1013 Avg QP:25.37 size: 88
[libx264 @ 0x23c5340] frame B:2990 Avg QP:27.32 size: 22
[libx264 @ 0x23c5340] consecutive B-frames: 0.8% 0.0% 0.1% 99.1%
[libx264 @ 0x23c5340] mb I I16..4: 42.0% 55.1% 2.9%
[libx264 @ 0x23c5340] mb P I16..4: 0.3% 0.4% 0.0% P16..4: 0.6% 0.1% 0.0% 0.0% 0.0% skip:98.6%
[libx264 @ 0x23c5340] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.2% 0.0% 0.0% direct: 0.0% skip:99.8% L0:35.7% L1:64.3% BI: 0.0%
[libx264 @ 0x23c5340] 8x8 transform intra:55.0% inter:84.5%
[libx264 @ 0x23c5340] direct mvs spatial:87.6% temporal:12.4%
[libx264 @ 0x23c5340] coded y,uvDC,uvAC intra: 33.4% 51.9% 0.7% inter: 0.0% 0.1% 0.0%
[libx264 @ 0x23c5340] i16 v,h,dc,p: 26% 54% 15% 5%
[libx264 @ 0x23c5340] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 17% 16% 53% 3% 1% 2% 2% 3% 3%
[libx264 @ 0x23c5340] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 15% 20% 13% 14% 5% 7% 7% 11% 8%
[libx264 @ 0x23c5340] i8c dc,h,v,p: 43% 31% 23% 3%
[libx264 @ 0x23c5340] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x23c5340] ref P L0: 80.9% 9.0% 6.9% 2.6% 0.7%
[libx264 @ 0x23c5340] ref B L0: 89.4% 8.6% 1.8% 0.2%
[libx264 @ 0x23c5340] ref B L1: 91.0% 9.0%
[libx264 @ 0x23c5340] kb/s:551.72
</server></server>
Outout from file recorded on window :
Input :
ffmpeg -i /<server path="path">/stream_window.flv -strict -2 -vcodec libx264 -preset slow -vb 500k -maxrate 500k -bufsize 1000k -vf 'scale=-1:480 ' -threads 0 -ab 64k -s 640x480 -movflags faststart -metadata:s:v:0 rotate=0 /<server path="path">/testing_1.mp4
</server></server>Output :
ffmpeg version 2.2.5 Copyright (c) 2000-2014 the FFmpeg developers
built on Aug 1 2014 09:24:02 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libtheora --enable-libx264 --enable-libvpx --enable-libmp3lame
libavutil 52. 66.100 / 52. 66.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 2.100 / 4. 2.100
libswscale 2. 5.102 / 2. 5.102
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100
Input #0, flv, from '/<server path="path">/stream_window.flv':
Metadata:
canSeekToEnd : true
Duration: 00:00:09.22, start: 0.000000, bitrate: 420 kb/s
Stream #0:0: Video: flv1, yuv420p, 640x480, 1k tbr, 1k tbn, 1k tbc
Stream #0:1: Audio: nellymoser, 44100 Hz, mono, flt
[libx264 @ 0x1e09fc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x1e09fc0] profile High, level 5.2
[libx264 @ 0x1e09fc0] 264 - core 142 r2453 ea0ca51 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=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_pskip=1 chroma_qp_offset=-2 threads=24 lookahead_threads=3 sliced_threads=0 nr=0 decimate=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=25 scenecut=40 intra_refresh=0 rc_lookahead=50 rc=cbr mbtree=1 bitrate=500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=500 vbv_bufsize=1000 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to '/<server path="path">/testing_1.mp4':
Metadata:
canSeekToEnd : true
encoder : Lavf55.33.100
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 640x480, q=-1--1, 500 kb/s, 16k tbn, 1k tbc
Metadata:
rotate : 0
Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, mono, fltp, 64 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (flv -> libx264)
Stream #0:1 -> #0:1 (nellymoser -> aac)
Press [q] to stop, [?] for help
[mp4 @ 0x1e06220] Starting second pass: moving the moov atom to the beginning of the file7 drop=0
frame= 8936 fps=703 q=-1.0 Lsize= 771kB time=00:00:09.26 bitrate= 681.5kbits/s dup=8907 drop=0
video:585kB audio:73kB subtitle:0 data:0 global headers:0kB muxing overhead 17.106213%
[libx264 @ 0x1e09fc0] frame I:40 Avg QP:29.54 size: 7449
[libx264 @ 0x1e09fc0] frame P:2248 Avg QP:30.88 size: 69
[libx264 @ 0x1e09fc0] frame B:6648 Avg QP:39.17 size: 22
[libx264 @ 0x1e09fc0] consecutive B-frames: 0.8% 0.0% 0.1% 99.1%
[libx264 @ 0x1e09fc0] mb I I16..4: 36.8% 60.7% 2.5%
[libx264 @ 0x1e09fc0] mb P I16..4: 0.2% 0.3% 0.0% P16..4: 0.4% 0.0% 0.0% 0.0% 0.0% skip:98.9%
[libx264 @ 0x1e09fc0] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.2% 0.0% 0.0% direct: 0.0% skip:99.8% L0:34.2% L1:65.8% BI: 0.0%
[libx264 @ 0x1e09fc0] 8x8 transform intra:60.6% inter:87.6%
[libx264 @ 0x1e09fc0] direct mvs spatial:72.8% temporal:27.2%
[libx264 @ 0x1e09fc0] coded y,uvDC,uvAC intra: 36.3% 62.8% 4.7% inter: 0.0% 0.0% 0.0%
[libx264 @ 0x1e09fc0] i16 v,h,dc,p: 33% 46% 15% 7%
[libx264 @ 0x1e09fc0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 19% 46% 3% 1% 1% 1% 2% 4%
[libx264 @ 0x1e09fc0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 36% 17% 14% 9% 4% 4% 5% 5% 7%
[libx264 @ 0x1e09fc0] i8c dc,h,v,p: 42% 31% 23% 4%
[libx264 @ 0x1e09fc0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x1e09fc0] ref P L0: 82.6% 9.9% 5.2% 1.7% 0.5%
[libx264 @ 0x1e09fc0] ref B L0: 87.1% 11.0% 1.4% 0.4%
[libx264 @ 0x1e09fc0] ref B L1: 90.3% 9.7%
[libx264 @ 0x1e09fc0] kb/s:536.03
</server></server>
Can anyone figure what could be the problem ?
@LordNeckbeard : Please find the command and its output above. Thanks
-
ffmpeg Bmp to yuv : Crash at sws_scale
28 décembre 2015, par the-ownerThe context :
I have a succession of continuous bitmap and I want to encode them into a light video format.
I use ffmpeg version 2.8.3 (the build here), under qt5, qt IDE, and msvc2013 for win32.The problem :
My code crash at sws_scale () (and sometimes at avcodec_encode_video2()). When I explore the stack, the crash event occurs at sws_getCachedContext (). (I can only see the stack with these ffmpeg builds).
I only use these ffmpeg libraries (from the Qt .pro file) :LIBS += -lavcodec -lavformat -lswscale -lavutil
It’s swscale which bug. And this is the code :
void newVideo ()
{
ULONG_PTR gdiplusToken;
GdiplusStartupInput gdiplusStartupInput;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
initBitmap (); //init bmp
int screenWidth = bmp.bmiHeader.biWidth;
int screenHeight = bmp.bmiHeader.biHeight;
AVCodec * codec;
AVCodecContext * c = NULL;
uint8_t * outbuf;
int i, out_size, outbuf_size;
avcodec_register_all();
qDebug () << "Video encoding\n";
// Find the mpeg1 video encoder
codec = avcodec_find_encoder(AV_CODEC_ID_H264);
if (!codec)
{
qDebug () << "Codec not found\n";
avcodec_close(c);
av_free(c);
return;
}
else
qDebug () << "H264 codec found\n";
c = avcodec_alloc_context3(codec);
c->bit_rate = 1000000;
c->width = 800; // resolution must be a multiple of two (1280x720),(1900x1080),(720x480)
c->height = 600;
c->time_base.num = 1; // framerate numerator
c->time_base.den = 25; // framerate denominator
c->gop_size = 30; // emit one intra frame every ten frames
c->max_b_frames = 1; // maximum number of b-frames between non b-frames
c->pix_fmt = AV_PIX_FMT_YUV420P; //Converstion RGB to YUV ?
c->codec_id = AV_CODEC_ID_H264;
struct SwsContext* fooContext = sws_getContext(screenWidth, screenHeight,
AV_PIX_FMT_RGB32,
c->width, c->height,
AV_PIX_FMT_YUV420P,
SWS_FAST_BILINEAR,
NULL, NULL, NULL);
// Open the encoder
if (avcodec_open2(c, codec, NULL) < 0)
{
qDebug () << "Could not open codec\n";
avcodec_close(c);
av_free(c);
return;
}
else qDebug () << "H264 codec opened\n";
outbuf_size = 100000 + c->width*c->height*(32>>3);//*(32>>3); // alloc image and output buffer
outbuf = static_cast(malloc(outbuf_size));
qDebug() << "Setting buffer size to: " << outbuf_size << "\n";
FILE* f = fopen("TEST.mpg","wb");
if(!f) qDebug() << "x - Cannot open video file for writing\n";
else qDebug() << "Opened video file for writing\n";
// encode 5 seconds of video
for (i = 0; i < STREAM_FRAME_RATE*STREAM_DURATION; i++) //the stop condition i < 5.0*5
{
qDebug () << "i = " << i;
fflush(stdout);
HBITMAP hBmp;
if (GetScreen(hBmp) == -1) return;
BYTE * pPixels;// = new BYTE [bmp.bmiHeader.biSizeImage];
pPixels = getPixels (hBmp);
DeleteObject (hBmp);
int nbytes = avpicture_get_size(AV_PIX_FMT_YUV420P, c->width, c->height);
uint8_t* outbuffer = (uint8_t*)av_malloc(nbytes*sizeof(uint8_t));
if(!outbuffer) // check if(outbuf) instead
{
qDebug () << "Bytes cannot be allocated";
return;
}
AVFrame* inpic = avcodec_alloc_frame(); //av_frame_alloc () ?
AVFrame* outpic = avcodec_alloc_frame();
outpic->pts = (int64_t)((float)i * (1000.0/((float)(c->time_base.den))) * 90);
if (avpicture_fill((AVPicture*) inpic, (uint8_t*) pPixels, AV_PIX_FMT_RGB32,
screenWidth, screenHeight) < 0)
qDebug () << "avpicture_fill Fill picture with image failed"; //Fill picture with image
if(avpicture_fill((AVPicture*) outpic, outbuffer, AV_PIX_FMT_YUV420P,
c->width, c->height) < 0)
qDebug () << "avpicture_fill failed";
if (av_image_alloc(outpic->data, outpic->linesize, c->width, c->height,
c->pix_fmt, 1) < 0)
qDebug () << "av_image_alloc failed";
inpic->data[0] += inpic->linesize[0]*(screenHeight - 1); // Flipping frame
inpic->linesize[0] = -inpic->linesize[0]; // Flipping frame
////////////////////////////HERE THE BUG////////////////////////////////
sws_scale(fooContext,
inpic->data, inpic->linesize,
0, c->height,
outpic->data, outpic->linesize); //HERE THE BUG
av_free_packet((AVPacket *)outbuf);
// encode the image
out_size = avcodec_encode_video2 (c, (AVPacket *) outbuf,
(AVFrame *) outbuf_size, (int *) outpic);
///////////////////////THE CODE DONT GO BEYOND/////////////////////////////////
qDebug () << "Encoding frame" << i <<" (size=" << out_size <<"\n";
fwrite(outbuf, 1, out_size, f);
delete [] pPixels;
av_free(outbuffer);
av_free(inpic);
av_freep(outpic);
}
// get the delayed frames
for(; out_size; i++)
{
fflush(stdout);
out_size = avcodec_encode_video2 (c, (AVPacket *) outbuf,
(AVFrame *) outbuf_size, NULL);
qDebug () << "Writing frame" << i <<" (size=" << out_size <<"\n";
fwrite(outbuf, 1, out_size, f);
}
// add sequence end code to have a real mpeg file
outbuf[0] = 0x00;
outbuf[1] = 0x00;
outbuf[2] = 0x01;
outbuf[3] = 0xb7;
fwrite(outbuf, 1, 4, f);
fclose(f);
avcodec_close(c);
free(outbuf);
av_free(c);
qDebug () << "Closed codec and Freed\n";
}And the output :
Video encoding
H264 codec found
H264 codec opened
Setting buffer size to: 2020000
Opened video file for writing
i = 0
**CRASH**I have thougth that my bitmap wasn’t good so I have crafted a bitmap just for testing, the code was :
uint8_t* pPixels = new uint8_t[Width * 3 * Height];
int x = 50;
for(unsigned int i = 0; i < Width * 3 * Height; i = i + 3) // loop for generating color changing images
{
pPixels [i] = x % 255; //R
pPixels [i + 1] = (x) % 255; //G
pPixels [i + 2] = (255 - x) % 255; //B
}However the crash continue. Perhaps, it might prove that it’s not the bitmap (pPixels) which has a problem.
If anyone know, why I get this bug : Maybe don’t I set one parameter well ? Or one ffmpeg deprecated function ? etc.
EDIT 1 27/12/15
Thanks to Ronald S. Bultje The function sws_scale () does not crash with this code, however I get an error from it bad dst image pointers. My code :
//DESTINATION FRAME
if (avpicture_alloc ((AVPicture*) dst_frame, AV_PIX_FMT_YUV420P, c->width, c->height) < 0)
{
qDebug () << "# avpicture_alloc failed";
return;
}
if(avpicture_fill((AVPicture*) dst_frame, NULL, AV_PIX_FMT_YUV420P,
c->width, c->height) < 0)
qDebug () << "avpicture_fill failed";
avcodec_align_dimensions2 (c, &c->width, &c->height, dst_frame->linesize);
//SOURCE FRAME
if (avpicture_fill((AVPicture*) src_frame, (uint8_t *) pPixels, AV_PIX_FMT_RGB32,
tmp_screenWidth, tmp_screenHeight) < 0)
qDebug () << "# avpicture_fill Fill picture with image failed"; //Fill picture with image
avcodec_align_dimensions2 (c, &tmp_screenWidth, &tmp_screenHeight, src_frame->linesize);
struct SwsContext* conversionContext = sws_getContext(tmp_screenWidth,tmp_screenHeight,AV_PIX_FMT_RGB32,c->width, c->height, AV_PIX_FMT_YUV420P,SWS_FAST_BILINEAR, NULL, NULL, NULL);
int output_Height = sws_scale(conversionContext,
src_frame->data, src_frame->linesize,
0, tmp_screenHeight,
dst_frame->data, dst_frame->linesize); //return 0 -> bad dst image pointers errorEDIT 2 28/12/15
I have tried to follow the Ronald S. Bultje’s suggestion and now I get a bad src image pointers error, I have investigated and worked many hours but I do not find a solution. Here, there is the new snippet :
AVFrame* src_frame = av_frame_alloc ();
AVFrame* dst_frame = av_frame_alloc ();
AVFrame* tmp_src_frame = av_frame_alloc ();
/*........I do not use them until this snippet..........*/
//DESTINATION
//avpicture_free ((AVPicture*)dst_frame);
avcodec_align_dimensions2 (c, &c->width, &c->height, dst_frame->linesize);
if (avpicture_alloc ((AVPicture*) dst_frame, AV_PIX_FMT_YUV420P, c->width, c->height) < 0)
{
qDebug () << "# avpicture_alloc failed";
return;
}
//SOURCE
//stride = src_frame->linesize [0] = ((((screenWidth * bitPerPixel) + 31) & ~31) >> 3); do I need to do that ?
//== stride - I have gotten this formula from : https://msdn.microsoft.com/en-us/library/windows/desktop/dd318229(v=vs.85).aspx
if (avpicture_fill((AVPicture*) src_frame, (uint8_t *) pPixels, AV_PIX_FMT_RGB32,
screenWidth, screenHeight) < 0)
qDebug () << "# avpicture_fill Fill picture with image failed"; //Fill picture with image
//linesize [0] == 21760 like commented stride
//Source TO TMP Source
avcodec_align_dimensions2 (c, &tmp_screenWidth, &tmp_screenHeight, tmp_src_frame->linesize);
if (avpicture_fill((AVPicture*) tmp_src_frame, NULL, AV_PIX_FMT_RGB32,
tmp_screenWidth, tmp_screenHeight) < 0)
qDebug () << "# avpicture_fill Fill picture with image failed"; //Fill picture with image
av_picture_copy ((AVPicture*) tmp_src_frame, (const AVPicture*) src_frame, AV_PIX_FMT_RGB32,
screenWidth, screenHeight);
struct SwsContext* conversionContext = sws_getContext(tmp_screenWidth, tmp_screenHeight,
AV_PIX_FMT_RGB32,
c->width, c->height,
AV_PIX_FMT_YUV420P,
SWS_FAST_BILINEAR,
NULL, NULL, NULL);
int output_Height = sws_scale(conversionContext,
tmp_src_frame->data, tmp_src_frame->linesize,
0, tmp_screenHeight,
dst_frame->data, dst_frame->linesize);
//ffmpeg error = bad src image pointers
// output_Height == 0EDIT 3
For temp Picture I have done an
avcode_align_dimension2()
then aavpicture_alloc()
for allocating memory andavpicture_fill()
in order to fill the picture pointer. Below the updated code ://DESTINATION
//avpicture_free ((AVPicture*)dst_frame);
avcodec_align_dimensions2 (c, &c->width, &c->height, dst_frame->linesize);
if (avpicture_alloc ((AVPicture*) dst_frame, AV_PIX_FMT_YUV420P, c->width, c->height) < 0)
{
qDebug () << "# avpicture_alloc failed";
return;
}
//SOURCE
//src_frame->linesize [0] = ((((screenWidth * bpp) + 31) & ~31) >> 3);
//src_frame->linesize [0] = stride;
if (avpicture_fill((AVPicture*) src_frame, (uint8_t *) pPixels, AV_PIX_FMT_RGB32,
screenWidth, screenHeight) < 0)
qDebug () << "# avpicture_fill Fill picture with image failed"; //Fill picture with image
//Source TO TMP Source
avcodec_align_dimensions2 (c, &tmp_screenWidth, &tmp_screenHeight, tmp_src_frame->linesize);
if (avpicture_alloc ((AVPicture*) tmp_src_frame, AV_PIX_FMT_RGB32, tmp_screenWidth, tmp_screenHeight) < 0)
{
qDebug () << "# avpicture_alloc failed";
return;
}
int outbuf_size = tmp_screenWidth*tmp_screenHeight*4;// alloc image and output buffer
outbuf = static_cast(malloc(outbuf_size));
if (avpicture_fill((AVPicture*) tmp_src_frame, outbuf, AV_PIX_FMT_RGB32,
tmp_screenWidth, tmp_screenHeight) < 0)
qDebug () << "# avpicture_fill Fill picture with image failed"; //Fill picture with image
av_picture_copy ((AVPicture*) tmp_src_frame, (const AVPicture*) src_frame, AV_PIX_FMT_RGB32,
tmp_screenWidth, tmp_screenHeight);
struct SwsContext* conversionContext = sws_getContext(tmp_screenWidth, tmp_screenHeight,
AV_PIX_FMT_RGB32,
c->width, c->height,
AV_PIX_FMT_YUV420P,
SWS_FAST_BILINEAR,
NULL, NULL, NULL);
int output_Height = sws_scale(conversionContext,
tmp_src_frame->data, tmp_src_frame->linesize,
0, tmp_screenHeight,
dst_frame->data, dst_frame->linesize);The call stack is as follow :
av_picture_copy()
is called thenav_image_copy()
then_VEC_memcpy()
thenfastcopy_I()
and crash ... The problem is not the dimensions (tmp_screenWidth/Height) ? (Withav_picture_copy ()
could we copy a picture P1 with dim W1xH1 to a picture P2 with dimension W2xH2 ?)EDIT 4
Crash at
av_picture_copy()
whichcall _aligned_malloc()
thenav_image_copy _VEC_memcpy()
andfastcopy_I()
//SOURCE
if (avpicture_fill((AVPicture*) src_frame, (uint8_t *) pPixels, AV_PIX_FMT_RGB32,
screenWidth, screenHeight) < 0)
qDebug () << "# avpicture_fill Fill picture with image failed"; //Fill picture with image
//Source TO TMP Source
avcodec_align_dimensions2 (c, &tmp_screenWidth, &tmp_screenHeight, tmp_src_frame->linesize);
if (avpicture_alloc ((AVPicture*) tmp_src_frame, AV_PIX_FMT_RGB32, tmp_screenWidth, tmp_screenHeight) < 0)
{
qDebug () << "# avpicture_alloc failed";
return;
}
av_picture_copy ((AVPicture*) tmp_src_frame, (const AVPicture*) src_frame, AV_PIX_FMT_RGB32,
tmp_screenWidth, tmp_screenHeight); -
ffmpeg video conversion from webm to mp4 is adding lag to the video
21 janvier 2016, par Hemant KumarHi I am trying to convert video from .webm extension to .mp4 extension and it is adding lags to the video, also not showing me the full video.
I am using following video conversion command.
"ffmpeg -i {$input} -strict -2 -vcodec libx264 -preset slow -vb 500k -maxrate 500k -bufsize 1000k -vf 'scale=-1:480 ".fix_video_orientation($input)."' -threads 0 -ab 64k -s {$resolution} -movflags faststart -metadata:s:v:0 rotate=0 {$output}";
"fix_video_orientation" function is given below. It rotate the resulting video if video while recording is rotated to certain angle.
function fix_video_orientation($input){
$return= ", transpose=1 ";
$dd= exec("ffprobe -of json -show_streams {$input} | grep rotate");
if(!empty($dd)){
$dd=explode(":",$dd);
$rotate=str_replace(",","",str_replace('"',"",$dd[1]));
if($rotate=="90")return $return;
else if ($rotate=="180") return ", transpose=2,transpose=2 ";
else if($rotate == "270") return ", transpose=2 ";
}Currently above script is supporting "flv","avi","mp4","mkv","mpg","wmv","asf","webm","mov","3gp","3gpp" extensions, also the script is supporting the resulting .mp4 file to play on all browsers and devices.
For query :
ffmpeg -i <server path="path">/g9zyy2qg54qp1l5spo2-mergedFile.webm -strict -2 -vcodec libx264 -preset slow -vb 500k -maxrate 500k -bufsize 1000k -vf 'scale=-1:480 ' -threads 0 -ab 64k -s 640x480 -movflags faststart -metadata:s:v:0 rotate=0 <server path="path">/g9zyy2qg54qp1l5spo2-mergedFile5.mp4
</server></server>Console output :
ffmpeg version 2.2.5 Copyright (c) 2000-2014 the FFmpeg developers
built on Aug 1 2014 09:24:02 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libtheora --enable-libx264 --enable-libvpx --enable-libmp3lame
libavutil 52. 66.100 / 52. 66.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 2.100 / 4. 2.100
libswscale 2. 5.102 / 2. 5.102
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100
Input #0, matroska,webm, from '<server path="path">/g9zyy2qg54qp1l5spo2-mergedFile.webm':
Metadata:
encoder : Lavf55.33.100
Duration: 00:00:13.53, start: 0.000000, bitrate: 387 kb/s
Stream #0:0: Audio: vorbis, 44100 Hz, stereo, fltp
Stream #0:1: Video: vp8, yuv420p, 320x240, SAR 1:1 DAR 4:3, 1k fps, 1k tbr, 1k tbn, 1k tbc (default)
[libx264 @ 0x38fcf40] using SAR=1/1
[libx264 @ 0x38fcf40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x38fcf40] profile High, level 5.2
[libx264 @ 0x38fcf40] 264 - core 142 r2453 ea0ca51 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=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_pskip=1 chroma_qp_offset=-2 threads=24 lookahead_threads=3 sliced_threads=0 nr=0 decimate=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=25 scenecut=40 intra_refresh=0 rc_lookahead=50 rc=cbr mbtree=1 bitrate=500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=500 vbv_bufsize=1000 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to '<server path="path">/g9zyy2qg54qp1l5spo2-mergedFile5.mp4':
Metadata:
encoder : Lavf55.33.100
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 640x480 [SAR 1:1 DAR 4:3], q=-1--1, 500 kb/s, 16k tbn, 1k tbc (default)
Metadata:
rotate : 0
Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp, 64 kb/s
Stream mapping:
Stream #0:1 -> #0:0 (vp8 -> libx264)
Stream #0:0 -> #0:1 (vorbis -> aac)
Press [q] to stop, [?] for help
frame= 358 fps=0.0 q=39.0 size= 27kB time=00:00:00.74 bitrate= 295.4kbits/frame= 723 fps=691 q=41.0 size= 57kB time=00:00:01.39 bitrate= 335.1kbits/frame= 1410 fps=706 q=45.0 size= 108kB time=00:00:01.74 bitrate= 509.0kbits/frame= 1777 fps=710 q=45.0 size= 134kB time=00:00:02.13 bitrate= 512.7kbits/frame= 2126 fps=707 q=45.0 size= 164kB time=00:00:02.50 bitrate= 535.0kbits/frame= 2497 fps=710 q=45.0 size= 191kB time=00:00:02.85 bitrate= 547.8kbits/frame= 2869 fps=708 q=45.0 size= 225kB time=00:00:03.20 bitrate= 575.7kbits/frame= 3226 fps=707 q=45.0 size= 250kB time=00:00:03.59 bitrate= 568.2kbits/frame= 3586 fps=709 q=46.0 size= 282kB time=00:00:03.94 bitrate= 585.7kbits/frame= 3956 fps=710 q=45.0 size= 305kB time=00:00:04.59 bitrate= 543.8kbits/frame= 4358 fps=710 q=46.0 size= 340kB time=00:00:04.71 bitrate= 591.1kbits/frame= 4751 fps=712 q=45.0 size= 362kB time=00:00:05.10 bitrate= 581.3kbits/frame= 5133 fps=713 q=45.0 size= 393kB time=00:00:05.50 bitrate= 584.9kbits/frame= 5510 fps=715 q=45.0 size= 416kB time=00:00:05.89 bitrate= 578.5kbits/frame= 5880 fps=715 q=45.0 size= 448kB time=00:00:06.24 bitrate= 587.6kbits/frame= 6250 fps=715 q=45.0 size= 472kB time=00:00:06.64 bitrate= 582.3kbits/frame= 6651 fps=715 q=45.0 size= 501kB time=00:00:06.98 bitrate= 587.1kbits/frame= 7012 fps=713 q=50.0 size= 524kB time=00:00:07.68 bitrate= 559.0kbits/frame= 7396 fps=714 q=45.0 size= 551kB time=00:00:07.75 bitrate= 582.5kbits/frame= 7771 fps=714 q=47.0 size= 575kB time=00:00:08.10 bitrate= 581.1kbits/frame= 8139 fps=714 q=50.0 size= 604kB time=00:00:08.52 bitrate= 580.8kbits/frame= 8509 fps=715 q=46.0 size= 628kB time=00:00:08.87 bitrate= 580.4kbits/frame= 8885 fps=715 q=46.0 size= 655kB time=00:00:09.19 bitrate= 583.1kbits/frame= 9233 fps=714 q=46.0 size= 677kB time=00:00:09.54 bitrate= 581.2kbits/frame= 9603 fps=714 q=46.0 size= 706kB time=00:00:09.96 bitrate= 580.6kbits/frame= 9975 fps=714 q=46.0 size= 728kB time=00:00:10.65 bitrate= 559.8kbits/frame=10376 fps=715 q=46.0 size= 757kB time=00:00:10.75 bitrate= 577.0kbits/frame=10730 fps=714 q=46.0 size= 780kB time=00:00:11.07 bitrate= 577.1kbits/frame=11090 fps=713 q=47.0 size= 808kB time=00:00:11.42 bitrate= 579.7kbits/frame=11447 fps=713 q=46.0 size= 832kB time=00:00:11.79 bitrate= 578.0kbits/frame=11802 fps=712 q=48.0 size= 858kB time=00:00:12.14 bitrate= 578.5kbits/frame=12181 fps=713 q=46.0 size= 880kB time=00:00:12.51 bitrate= 576.3kbits/frame=12563 fps=713 q=46.0 size= 908kB time=00:00:12.95 bitrate= 573.9kbits/frame=13527 fps=715 q=46.0 size= 960kB time=-577014:-32:-22.-77 bitrate=N/A [mp4 @ 0x3912e00] Starting second pass: moving the moov atom to the beginning of the file
frame=13527 fps=713 q=-1.0 Lsize= 1139kB time=00:00:13.52 bitrate= 689.8kbits/s dup=13036 drop=0
video:863kB audio:107kB subtitle:0 data:0 global headers:0kB muxing overhead 17.479137%
[libx264 @ 0x38fcf40] frame I:55 Avg QP:33.13 size: 6072
[libx264 @ 0x38fcf40] frame P:3409 Avg QP:32.90 size: 95
[libx264 @ 0x38fcf40] frame B:10063 Avg QP:39.74 size: 22
[libx264 @ 0x38fcf40] consecutive B-frames: 0.8% 0.0% 0.0% 99.2%
[libx264 @ 0x38fcf40] mb I I16..4: 25.7% 69.5% 4.8%
[libx264 @ 0x38fcf40] mb P I16..4: 0.2% 0.2% 0.0% P16..4: 1.4% 0.1% 0.4% 0.0% 0.0% skip:97.7%
[libx264 @ 0x38fcf40] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.3% 0.0% 0.0% direct: 0.0% skip:99.7% L0:41.0% L1:58.9% BI: 0.0%
[libx264 @ 0x38fcf40] 8x8 transform intra:67.9% inter:94.6%
[libx264 @ 0x38fcf40] direct mvs spatial:86.6% temporal:13.4%
[libx264 @ 0x38fcf40] coded y,uvDC,uvAC intra: 36.1% 36.9% 1.7% inter: 0.1% 0.1% 0.0%
[libx264 @ 0x38fcf40] i16 v,h,dc,p: 32% 27% 9% 31%
[libx264 @ 0x38fcf40] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 13% 18% 7% 7% 8% 8% 9% 8%
[libx264 @ 0x38fcf40] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 16% 7% 7% 9% 10% 9% 7% 8%
[libx264 @ 0x38fcf40] i8c dc,h,v,p: 73% 14% 9% 4%
[libx264 @ 0x38fcf40] Weighted P-Frames: Y:0.6% UV:0.0%
[libx264 @ 0x38fcf40] ref P L0: 77.5% 12.2% 9.1% 0.9% 0.2% 0.0%
[libx264 @ 0x38fcf40] ref B L0: 86.6% 13.2% 0.2% 0.0%
[libx264 @ 0x38fcf40] ref B L1: 89.8% 10.2%
[libx264 @ 0x38fcf40] kb/s:522.05
</server></server>