[SOLVED] Can we specify the codec separately from the format for mpeg live streaming

Forum for questions and support relating to the 1.29.x releases only.
Locked
kevin186
Posts: 55
Joined: Mon May 10, 2010 4:11 am
Location: Worth, IL

[SOLVED] Can we specify the codec separately from the format for mpeg live streaming

Post by kevin186 »

I have been testing 1.29 on ubuntu 15 for a couple weeks and I really like it. Thanks guys. The recent release has inspired me to start rebuilding my old app and I am experimenting with different video formats for streaming to determine best quality vs bandwidth vs server load. As of a couple days ago, I am able to stream flv into my app with an unlimited number of live streams because I am bypassing the limits of max simulatenous connections by using low level sockets. When debugging streams of flv, I can see that they are encoded with h263. I would like to get an flv live stream encoded with h264 to see if there can be any perceivable benefits. I tried reading the current data output as an h264 format, but since it is not in a flv container, I cannot use the as3 air netStream component because it needs to have "FLV" in the file header to be compatible.

For testing purposes, I was able to use ffmpeg to create a video clip which is encoded as H264 in a format of FLV. I then streamed that file from server to my app and was able to read the data and interpret the video.

Code: Select all

ffmpeg -analyzeduration 2147483647 -probesize 2147483647 -rtsp_transport tcp -i 'rtsp://192.168.1.161:554/user=admin&password=&channel=3&stream=1.sdp' -c:v libx264 -f flv testFile
I was also poking around the source code @ github/zoneminder but cannot determine which file sets the "codec" and "format" for the live stream. I would appreciate any advice to determine if it is already possible to select a format and codec separately for mpeg, or would I have to dig in the source and make a pull request. Thanks.
Last edited by kevin186 on Mon Apr 11, 2016 12:29 am, edited 1 time in total.
kevin186
Posts: 55
Joined: Mon May 10, 2010 4:11 am
Location: Worth, IL

Re: Can we specify the codec separately from the format for mpeg live streaming

Post by kevin186 »

Yes, we can. I realize that this was a difficult question because the solution was not well documented, or atleast not easy for me to find. Much digging, testing, and building from source led me to https://github.com/ZoneMinder/ZoneMinde ... 229cfb7926 line 435. You can pass a value such as "flv/libx264" in MPEG_LIVE_FORMAT. The code in zm_mpeg.cpp will split the MPEG_LIVE_FORMAT value at the "/" and use "flv" as the format and "libx264" as the codec. This also applies to webm and any other format that may benefit from specifying a codec. I tested "webm/libvpx" for vp8 and "webm/libvpx-vp9" for vp9, although I would not use webm because it seems to cause an extremely high cpu load on my server.

Comparing the different streams by opening them with VLC and monitoring the server cpu usage with htop -u www-data, I have found that for the one particular stream I am testing the cpu load, in order from best to worst when it comes to hogging server resources: mjpeg = 0.8%, flv or flv/flv = 1.1%, swf = 1.1%, flv/libx264 = 3.8%, ogg= 4.2%, webm or webm/libvpx = 10%, webm/libvpx-vp = 75% . Still unable to get any type of mp4 stream to work at this point.
Locked