I'm trying to develop A live streaming app that capture video from web cam encode it to H264 video stream and use rtsp to send it to device, I've looked up some examples and found this: FFMPEG to send RTSP encoded stream C++
I've been using it as a reference to my program.
However I'm keep getting AVCodec type "MPEG", I've been trying to change filename extension and tried different approaches with avformat_alloc_output_context2
This is the relevant code:
const char *filename = "rtsp://127.0.0.1:7003/live.sdp";
AVOutputFormat *fmt;
AVFormatContext *oc;
AVStream *video_st;
AVCodec *video_codec;
video_st = NULL;
av_register_all();
avformat_network_init();
// format context:
avformat_alloc_output_context2(&oc,NULL,"rtsp",filename);
After calling avformat_alloc_output_context2 oc->oformat->video_codec is generated as MPEG codec. I've tried changing filename extension to:
const char *filename = "rtsp://127.0.0.1:7003/live.264";
const char *filename = "rtsp://127.0.0.1:7003/live.h264";
and a bunch of other extensions.
How can I generate a H264 stream?