Rtspg rtsp decode buffer too small

I am decoding rtsp on Android with ffmpeg and I see pixelation quickly when the image is refreshed quickly or at high resolution:

working decoded frame

non working decoded frame

After googling, I found that this can be related to the UDP buffer size. Then I recompiled the ffmpeg library with the following parameters inside ffmpeg / libavformat / udp.c

#define UDP_TX_BUF_SIZE 327680
#define UDP_MAX_PKT_SIZE 655360

      

It seems to be improving, but at some point it still starts to fail. Any idea which buffer I should increase and how?

+3


source to share


1 answer


For my problem ( http://libav-users.943685.n4.nabble.com/UDP-Stream-Read-Pixelation-Macroblock-Corruption-td4655270.html ), I was trying to capture from a multicast UDP stream that was configured by someone then to others, Since I had no way of linking to the source, I stopped using libav to use libvlc as a wrapper and it worked fine. Here is a summary of what worked for me:

stream.h:

#include <vlc/vlc.h>
#include <vlc/libvlc.h>

struct ctx {
   uchar* frame;
};

      

stream.cpp:



void* lock(void* data, void** p_pixels){
  struct ctx* ctx = (struct ctx*)data;
  *p_pixels = ctx->frame;
  return NULL;
}

void unlock(void* data, void* id, void* const* p_pixels){
  struct ctx* ctx = (struct ctx*)data;
  uchar* pixels = (uchar*)*p_pixels;
  assert(id == NULL);
}

      

main.cpp:

struct ctx* context = (struct ctx*)malloc(sizeof(*context));
const char* const vlc_args[] = {"-vvv",
                                 "-q",
                                 "--no-audio"};
libvlc_media_t* media = NULL;
libvlc_media_player_t* media_player = NULL;
libvlc_instance_t* instance = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);

media = libvlc_media_new_location(instance, "udp://@123.123.123.123:1000");
media_player = libvlc_media_player_new(instance);
libvlc_media_player_set_media(media_player, media);
libvlc_media_release(media);
context->frame = new uchar[height * width * 3];
libvlc_video_set_callbacks(media_player, lock, unlock, NULL, context);
libvlc_video_set_format(media_player, "RV24", VIDEOWIDTH, VIDEOHEIGHT, VIDEOWIDTH * 3);
libvlc_media_player_play(media_player);

      

0


source







All Articles