
Recherche avancée
Autres articles (94)
-
Qu’est ce qu’un éditorial
21 juin 2013, parEcrivez votre de point de vue dans un article. Celui-ci sera rangé dans une rubrique prévue à cet effet.
Un éditorial est un article de type texte uniquement. Il a pour objectif de ranger les points de vue dans une rubrique dédiée. Un seul éditorial est placé à la une en page d’accueil. Pour consulter les précédents, consultez la rubrique dédiée.
Vous pouvez personnaliser le formulaire de création d’un éditorial.
Formulaire de création d’un éditorial Dans le cas d’un document de type éditorial, les (...) -
Contribute to translation
13 avril 2011You can help us to improve the language used in the software interface to make MediaSPIP more accessible and user-friendly. You can also translate the interface into any language that allows it to spread to new linguistic communities.
To do this, we use the translation interface of SPIP where the all the language modules of MediaSPIP are available. Just subscribe to the mailing list and request further informantion on translation.
MediaSPIP is currently available in French and English (...) -
Des sites réalisés avec MediaSPIP
2 mai 2011, parCette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page.
Sur d’autres sites (7424)
-
value of got_picture_ptr is always 0. when use avcodec_decode_video2()
4 septembre 2014, par user3867261I’m using visual studio 2013 professional.
below code is simple decode tutorial using ffmpeg.
///> Include FFMpeg
extern "C" {
#include <libavformat></libavformat>avformat.h>
}
///> Library Link On Windows System
#pragma comment( lib, "avformat.lib" )
#pragma comment( lib, "avutil.lib" )
#pragma comment( lib, "avcodec.lib" )
static void write_ascii_frame(const char *szFileName, const AVFrame *pVframe);
int main(void)
{
const char *szFilePath = "C:\\singlo\\example.avi";
///> Initialize libavformat and register all the muxers, demuxers and protocols.
av_register_all();
///> Do global initialization of network components.
avformat_network_init();
int ret;
AVFormatContext *pFmtCtx = NULL;
///> Open an input stream and read the header.
ret = avformat_open_input( &pFmtCtx, szFilePath, NULL, NULL );
if( ret != 0 ) {
av_log( NULL, AV_LOG_ERROR, "File [%s] Open Fail (ret: %d)\n", ret );
exit( -1 );
}
av_log( NULL, AV_LOG_INFO, "File [%s] Open Success\n", szFilePath );
av_log( NULL, AV_LOG_INFO, "Format: %s\n", pFmtCtx->iformat->name );
///> Read packets of a media file to get stream information.
ret = avformat_find_stream_info( pFmtCtx, NULL );
if( ret < 0 ) {
av_log( NULL, AV_LOG_ERROR, "Fail to get Stream Information\n" );
exit( -1 );
}
av_log( NULL, AV_LOG_INFO, "Get Stream Information Success\n" );
///> Find Video Stream
int nVSI = -1;
int nASI = -1;
int i;
for( i = 0 ; i < pFmtCtx->nb_streams ; i++ ) {
if( nVSI < 0 && pFmtCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO ) {
nVSI = i;
}
else if( nASI < 0 && pFmtCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO ) {
nASI = i;
}
}
if( nVSI < 0 && nASI < 0 ) {
av_log( NULL, AV_LOG_ERROR, "No Video & Audio Streams were Found\n");
exit( -1 );
}
///> Find Video Decoder
AVCodec *pVideoCodec = avcodec_find_decoder( pFmtCtx->streams[nVSI]->codec->codec_id );
if( pVideoCodec == NULL ) {
av_log( NULL, AV_LOG_ERROR, "No Video Decoder was Found\n" );
exit( -1 );
}
///> Initialize Codec Context as Decoder
if( avcodec_open2( pFmtCtx->streams[nVSI]->codec, pVideoCodec, NULL ) < 0 ) {
av_log( NULL, AV_LOG_ERROR, "Fail to Initialize Decoder\n" );
exit( -1 );
}
///> Find Audio Decoder
AVCodec *pAudioCodec = avcodec_find_decoder( pFmtCtx->streams[nASI]->codec->codec_id );
if( pAudioCodec == NULL ) {
av_log( NULL, AV_LOG_ERROR, "No Audio Decoder was Found\n" );
exit( -1 );
}
///> Initialize Codec Context as Decoder
if( avcodec_open2( pFmtCtx->streams[nASI]->codec, pAudioCodec, NULL ) < 0 ) {
av_log( NULL, AV_LOG_ERROR, "Fail to Initialize Decoder\n" );
exit( -1 );
}
AVCodecContext *pVCtx = pFmtCtx->streams[nVSI]->codec;
AVCodecContext *pACtx = pFmtCtx->streams[nASI]->codec;
AVPacket pkt;
AVFrame* pVFrame, *pAFrame;
int bGotPicture = 0; // flag for video decoding
int bGotSound = 0; // flag for audio decoding
int bPrint = 0; // ë¹ëì¤ ì²« ì¥ë©´ë§ íì¼ë¡ ë¨ê¸°ê¸° ìí ìì flag ìëë¤
pVFrame = avcodec_alloc_frame();
pAFrame = avcodec_alloc_frame();
while( av_read_frame( pFmtCtx, &pkt ) >= 0 ) {
///> Decoding
if( pkt.stream_index == nVSI ) {
if( avcodec_decode_video2( pVCtx, pVFrame, &bGotPicture, &pkt ) >= 0 ) {
///////////////////////problem here/////////////////////////////////////////////
if( bGotPicture ) {
///> Ready to Render Image
av_log( NULL, AV_LOG_INFO, "Got Picture\n" );
if( !bPrint ) {
write_ascii_frame( "output.txt", pVFrame );
bPrint = 1;
}
}
}
// else ( < 0 ) : Decoding Error
}
else if( pkt.stream_index == nASI ) {
if( avcodec_decode_audio4( pACtx, pAFrame, &bGotSound, &pkt ) >= 0 ) {
if( bGotSound ) {
///> Ready to Render Sound
av_log( NULL, AV_LOG_INFO, "Got Sound\n" );
}
}
// else ( < 0 ) : Decoding Error
}
///> Free the packet that was allocated by av_read_frame
av_free_packet( &pkt );
}
av_free( pVFrame );
av_free( pAFrame );
///> Close an opened input AVFormatContext.
avformat_close_input( &pFmtCtx );
///> Undo the initialization done by avformat_network_init.
avformat_network_deinit();
return 0;
}
static void write_ascii_frame(const char *szFileName, const AVFrame *frame)
{
int x, y;
uint8_t *p0, *p;
const char arrAsciis[] = " .-+#";
FILE* fp = fopen( szFileName, "w" );
if( fp ) {
/* Trivial ASCII grayscale display. */
p0 = frame->data[0];
for (y = 0; y < frame->height; y++) {
p = p0;
for (x = 0; x < frame->width; x++)
putc( arrAsciis[*(p++) / 52], fp );
putc( '\n', fp );
p0 += frame->linesize[0];
}
fflush(fp);
fclose(fp);
}
}there is a problem in below part
if( avcodec_decode_video2( pVCtx, pVFrame, &bGotPicture, &pkt ) >= 0 ) {
///////////////////////problem here/////////////////////////////////////////////
if( bGotPicture ) {
///> Ready to Render Image
av_log( NULL, AV_LOG_INFO, "Got Picture\n" );
if( !bPrint ) {
write_ascii_frame( "output.txt", pVFrame );
bPrint = 1;
}
}
}the value of bGotPicture is always 0.. So i can’t decode video
plz help me.
where do problem occurs from ? in video ? in my code ? -
OCPA, FDBR and TDPSA – What you need to know about the US’s new privacy laws
22 juillet 2024, par Daniel Crough -
GC and onTouch cause Fatal signal 11 (SIGSEGV) error in app using ffmpeg through ndk
30 janvier 2015, par grzebykI am getting a nasty but well known error while working with FFmpeg and NDK :
A/libc(9845): Fatal signal 11 (SIGSEGV), code 1, fault addr 0xa0a9f000 in tid 9921 (AsyncTask #4)
UPDATE
After couple hours i found out that there might be two sources of the problem. One was related to multithreading. I checked it and I fixed it. Now the app crashes ONLY when the video playback (ndk) is on.
I put a "counter" in touch event
surfaceSterowanieKamera.setOnTouchListener(new View.OnTouchListener() {
int counter = 0;
@Override
public boolean onTouch(View v, MotionEvent event) {
if ((event.getAction() == MotionEvent.ACTION_MOVE)){
Log.i(TAG, "counter = " + counter);
//cameraMover.setPanTilt(some parameters);
counter++;
}And I started disabling other app functionalities one by one, but no video. I found out, that with every single functionality less, it takes app longer to crush - counter reaches higher values. After turning off everything besides video playback and touch interface (
cameraMover.setPanTilt()
commented out) the app crushes usually when counter is between 1600 - 1700.In such case logcat shows the above error and GC related info. For me it seems like GC is messing up with the ndk.
01-23 12:27:13.163: I/Display Activity(20633): n = 1649
01-23 12:27:13.178: I/art(20633): Background sticky concurrent mark sweep GC freed 158376(6MB) AllocSpace objects, 1(3MB) LOS objects, 17% free, 36MB/44MB, paused 689us total 140.284ms
01-23 12:27:13.169: A/libc(20633): Fatal signal 11 (SIGSEGV), code 1, fault addr 0x9bd6ec0c in tid 20734 (AsyncTask #3)Why is GC causing problem with ndk part of application ?
ORIGINAL PROBLEM
What am I doing ?
I am developing an application that streams live video feed from a webcam and enables user to pan and tilt the remote camera. I am using FFmpeg library built with NDK to achieve smooth playback with little delay.
I am using FFMpeg library to connect to the video stream. Then the ndk part creates bitmap, does the image processing and render frames on the
SurfaceView videoSurfaceView
object which is located in the android activity (java part).To move the webcam I created a separate class -
public class CameraMover implements Runnable{/**/}
. This class is a separate thread that connects through sockets with the remote camera and manages tasks connected ONLY with pan-tilt movement.Next in the main activity i created a touch listener
videoSurfaceView.setOnTouchListener(new View.OnTouchListener() {/**/
cameraMover.setPanTilt(some parameters);
/**/}which reads user’s finger movement and sends commands to the camera.
All tasks - moving camera around, touch interface and video playback are working perfectly when the one of the others is disabled, i.e. when I disable possibility to move camera, I can watch video streaming and register touch events till the end of time (or battery at least). The problem occurs only when task are configured to work simultaneously.
I am unable to find steps to reproduce the problem. It just happens, but only after user touches the screen to move camera. It can be 15 seconds after first interaction, but sometimes it takes app 10 or more minutes to crash. Usually it is something around a minute.
What have I done to fix it ?
- I tried to display millions of logs in logcat to find an error but
the last log was always different. - I created a transparent surface, that I put over the
videoSurfaceView
and assigned touch listener to it. It all ended in the same error. - As I mentioned before, I turned off some functionalities to find which one produces the error, but it appears that error occurs only when everything is working simultaneously.
Types of the error
Almost every time the error looks like this :
A/libc(11528): Fatal signal 11 (SIGSEGV), code 1, fault addr 0x9aa9f00c in tid 11637 (AsyncTask #4)
the difference between two errors is the number right after libc, addr number and tid number. Rarely the AsyncTask number varies - i received #1 couple times but I was unable to reproduce it.
Question
How can i avoid this error ? What can be the source of it ?
- I tried to display millions of logs in logcat to find an error but