[FFmpeg-user] Best media converter container for IPCam network streams

Giuseppe Modugno giuseppe.modugno.loqed at gmail.com
Thu Sep 14 13:33:29 EEST 2023


I have several IPCams from different manufacturers. All of them transmit 
audio/video stream through a well-known RTSP URL.

They can use different video codecs, mainly H.264 or H.265 (in some 
cases, MJPEG for low resolution streams).

Also audio codecs are different: G.711a, G.711u, AAC, G.726, MP3, PCM, 
MP2L2 and so on.

I'm trying to use ffmpeg to receive streams from those IPCams. I'm using 
segment muxer to keep always a certain number of segments in memory, 
that is what I need. I finally reached the following command line:

   ffmpeg -hide_banner -rtsp_transport tcp -stimeout 10000000 -i <rtsp 
addr> -f segment -segment_time 2 -reset_timestamps 1 -segment_wrap 11 -c 
copy %d.<output format>

ffmpeg runs on a small embedded Linux box based on iMX6ULL CPU. It isn't 
a powerful CPU, so I'd like to use "-c copy" to avoid overloading the 
CPU when transcoding 10 streams at the same time.

Now the problem is the output format to use (the muxer?).

I started with mp4, but it doesn't support G.711 and similar audio codecs.

I tried with mkv, but ffmpeg exits with error for some IPCams, because 
it couldn't find timestamps. The error is:

   [matroska @ 000001e89e880e00] Can't write packet with unknown timestamp
   av_interleaved_write_frame(): Invalid argument
   frame=    3 fps=0.0 q=-1.0 Lsize=N/A time=00:00:00.12 bitrate=N/A 
speed=48.2x
   video:56kB audio:1kB subtitle:0kB other streams:0kB global 
headers:0kB muxing overhead: unknown
   Conversion failed!

I tried to fix this error with '-fflags +genpts' and other solutions I 
found on the web, without success.

So I tried mov and it appears to work for all my IPCams, but I'm 
wondering if it will work for other IPCams I will use.

First question: could ffmpeg save the stream in a "raw" format as it is 
received from RTSP, without too much problems? I don't need to play the 
video continuously, only when I want. Only at that moment, I could use 
ffmpeg to join segments and transcode to mp4. In this case the 
transcoding is limited in time and only for short videos.

Second question: is there another media container format that could be 
better to use in my situation?




More information about the ffmpeg-user mailing list