Hi Javier,

Javier Rojo wrote:
> Hi all,
>  
> I am working with an IP Camera (Lumenera Le 165m, 
> http://www.lumenera.com/security/le165.php). With the command 
> http://MY_CAMERA_IP/cgi-bin/nph-video?type=multipart/x-mixed-replace the 
> camera starts sending jpeg files. Well, my goal is to develop in C/C++ and 
> application to record that streaming, in mpg, for example.
>  
> Up to now, I have used curl to retrieve JPGs from network, ImageMagick to 
> load JPG from memory and to obtain RAW data in PIX_FMT_GRAY8 format, then 
> img_convert to change from PIX_FMT_GRAY8 to PIX_FMT_YUVJ420P, and finally I 
> have encoded the stream with avcodec_encode_video (CODEC_ID_MPEG1VIDEO)

I think you can use libavformat instead of curl to fetch the jpeg files,
and libavcodec to decode them. Also, note that img_convert() has been
deprecated, and you should use sws_* instead (see ffmpeg.c or
libswscale/swscale-example.c for an usage example).

I _suspect_ you can also use the "ffmpeg" program directly to fetch the
images and convert them to an mpeg file, but I have no idea about the
correct command line.


> But the speed of the video is altered cause I am using m_c->time_base= 
> (AVRational){1,25}; but the FPS of the IP camera are not constant and 
> sometimes are 15 (encoded video is faster than reality) or 50 (encoded video 
> is slower than reality), depending on the image size, network overload and so 
> on...

If the frame rate is not constant and you want to encode at variable
frame rate, time_base = 1/25 is a bad choice.
(however, you should use a codec and file format that support variable
frame rate - I do not know if mpeg is OK)
You can probably set it to 1/1000, and pass timestamps in ms.
The real problem is that you must be able to associate a PTS to your
input frames, and if the camera is not providing a timestamps for the
frames you are in a bad shape.

The alternative is to duplicate/drop frames to achieve constant frame
rate for the encoded video (see the "vsynch" in ffmpeg.c).


> My questions are: 
>  - how should I do it to encode that stream in a more easy/fast way? 

See above


>  - Is there any example to have a look about encoding http stream?

I do not know about any... You can try to have a look at ffmpeg.c.


>  - Is there any documentation about ffmpeg (avformat, avutil, avcodec...)

There is the doxygen documentation in avformat.h, avcodec.h, and avutil.h.
This is not very practical (it requires some previous knowledge in the reader,
and is far from a tutorial), but it's the most reliable source of information.
You can also search this mailing list archives, and you'll find useful 
suggestions
and references to some tutorials.


                                Luca
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to