
Recherche avancée
Médias (1)
-
1 000 000 (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
Autres articles (15)
-
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" (...) -
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 -
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 ;
Sur d’autres sites (3987)
-
close the running application in vb.net from background
22 janvier 2016, par TOMi want to stop the running (ffmpeg) process from background . i use the
process.kill()
i wrote the code . but in this process the output file is getting corrupted.
Dim pProcess() As Process = Process.GetProcesses
For Each p As Process In pProcess
If p.ProcessName = "ffmpeg" Then
p.WaitForExit(1000)
p.Kill()
p.Close()
End If
Nextis there any other method to terminate the process without file being corrupt
thanks
-
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> -
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);