How to add force format parameter to ffmpeg

Forum for questions and support relating to the 1.34.x releases only.
Post Reply
srb
Posts: 5
Joined: Sun Jul 04, 2021 8:03 am

How to add force format parameter to ffmpeg

Post by srb »

Hi guys,

I am trying to configure my h264 cameras with zm(using ffmpeg). For some reason, ffmpeg is not able to identify the stream format and returns "Invalid data found when processing input". However if I pass on "-f h264" (which means force format) as parameter before -i <url>, that is able to force the format and thus ffmpeg is able to decode the stream.

Not working:
ffmpeg -i 'http://admin:@172.20.14.35:80/livestrea ... audio_data' ~/sss.mp4
ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
...
...
http://admin:@172.20.14.35:80/livestrea ... audio_data: Invalid data found when processing input

Working if "-f h264" is passed:
ffmpeg -f h264 -i 'http://admin:@172.20.14.35:80/livestrea ... audio_data' ~/sss.mp4
ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
...
...
Input #0, h264, from 'http://admin:@172.20.14.35:80/livestrea ... audio_data':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (High), yuvj420p(pc, bt709, progressive), 1280x960, 25 fps, 25 tbr, 1200k tbn, 50 tbc

I am seeing the same error in zoneminder logs, and seems the reason is same. I want to know if there is way out that I can pass "-f h264" before -i (camera url) in zoneminder monitor somewhere to get it working? I have tried setting f=h264 in ffmpeg options, but it has not helped.
dougmccrary
Posts: 1205
Joined: Sat Aug 31, 2019 7:35 am
Location: San Diego

Re: How to add force format parameter to ffmpeg

Post by dougmccrary »

I don't recall if it's present in 1.34, but in 1.36 on the Source page of the monitor, there is "Options" for that purpose.
mikb
Posts: 595
Joined: Mon Mar 25, 2013 12:34 pm

Re: How to add force format parameter to ffmpeg

Post by mikb »

srb wrote: Sun Jul 18, 2021 7:56 am
ffmpeg -f h264 -i ....

I have tried setting f=h264 in ffmpeg options
As per the other post, but don't take it upon yourself to invent a new syntax -- "-f h264" should work fine ;)
srb
Posts: 5
Joined: Sun Jul 04, 2021 8:03 am

Re: How to add force format parameter to ffmpeg

Post by srb »

dougmccrary wrote: Sun Jul 18, 2021 9:38 am I don't recall if it's present in 1.34, but in 1.36 on the Source page of the monitor, there is "Options" for that purpose.
Thanks for quick reply. The "Options" are there in 1.34, but if I add the f=h264 in options, I see below in logs. Could it be because of a different version of ffmpeg on my system VS the one being used by zoneminder? Not sure if that is possible.

Code: Select all

zmc_m1[116508].WAR-zm_ffmpeg_camera.cpp/409 [Option f not recognized by ffmpeg]
mikb wrote: Sun Jul 18, 2021 2:53 pm
srb wrote: Sun Jul 18, 2021 7:56 am
ffmpeg -f h264 -i ....

I have tried setting f=h264 in ffmpeg options
As per the other post, but don't take it upon yourself to invent a new syntax -- "-f h264" should work fine ;)
:) It was as per help text.

Code: Select all

Parameters in this field are passed on to FFmpeg. Multiple parameters can be separated by ,
Examples (do not enter quotes)
"allowed_media_types=video" Set datatype to request from cam (audio, video, data)
"reorder_queue_size=nnn" Set number of packets to buffer for handling of reordered packets

if I don't add "-f h264", it errors out while parsing.

Code: Select all

zmc_m5[108853].WAR-zm_ffmpeg_camera.cpp/354 [Could not parse ffmpeg input options '-f h264']
SteveGilvarry
Posts: 494
Joined: Sun Jun 29, 2014 1:12 pm
Location: Melbourne, AU

Re: How to add force format parameter to ffmpeg

Post by SteveGilvarry »

Ffmpeg libraries are in use not the command line so those switches don’t work. The ones listed in help are part of RTSP protocol, as originally this was part of how we chose the RTSP transport method. I think more opts are now passed to the various calls, so maybe you can try that.
Not sure if this will work as I have not tested it, but worth a try.
video_codec_id=AV_CODEC_ID_H264

I have not looked at the ffmpeg code to work out what -f h264 is doing but this seems like a good guess.

Already on the latest ffmpeg so not much to try there. Maybe the camera has some config options that are causing it, like h264+. Prefer to address root cause if we can.
Production Zoneminder 1.37.x (Living dangerously)
Random Selection of Cameras (Dahua and Hikvision)
srb
Posts: 5
Joined: Sun Jul 04, 2021 8:03 am

Re: How to add force format parameter to ffmpeg

Post by srb »

SteveGilvarry wrote: Mon Jul 19, 2021 12:06 am Ffmpeg libraries are in use not the command line so those switches don’t work. The ones listed in help are part of RTSP protocol, as originally this was part of how we chose the RTSP transport method. I think more opts are now passed to the various calls, so maybe you can try that.
Not sure if this will work as I have not tested it, but worth a try.
video_codec_id=AV_CODEC_ID_H264

I have not looked at the ffmpeg code to work out what -f h264 is doing but this seems like a good guess.

Already on the latest ffmpeg so not much to try there. Maybe the camera has some config options that are causing it, like h264+. Prefer to address root cause if we can.
Thanks for your reply. Tried the option, it didn't show any error message but the issue still persists :(

Code: Select all

07/19/21 00:25:35.416300 zmc_m6[21346].ERR-zm_ffmpeg_camera.cpp/393 [Unable to open input http://admin:@172.20.14.36:80/livestream/11?action=play&media=video_audio_data due to: Invalid data found when processing input]
07/19/21 00:25:35.466302 zmc_m6[21346].ERR-zmc.cpp/257 [Failed to prime capture of initial monitor]
My cameras are some Chinese cameras came with an NVR. I couldn't find much settings/documentation for these. I got the url by taking the tcp dump. Lets see how it goes.

Thanks for checking on it!
SteveGilvarry
Posts: 494
Joined: Sun Jun 29, 2014 1:12 pm
Location: Melbourne, AU

Re: How to add force format parameter to ffmpeg

Post by SteveGilvarry »

viewtopic.php?t=18727

Seems very similar url to yours.
Try RTSP://user:pass@ip:554/11
Production Zoneminder 1.37.x (Living dangerously)
Random Selection of Cameras (Dahua and Hikvision)
srb
Posts: 5
Joined: Sun Jul 04, 2021 8:03 am

Re: How to add force format parameter to ffmpeg

Post by srb »

SteveGilvarry wrote: Mon Jul 19, 2021 6:10 am viewtopic.php?t=18727

Seems very similar url to yours.
Try RTSP://user:pass@ip:554/11
Nope, no other ports are open on my cameras :(

Code: Select all

nmap 172.20.14.36
Starting Nmap 7.80 ( https://nmap.org ) at 2021-07-19 23:17 CDT
Nmap scan report for 172.20.14.36
Host is up (0.019s latency).
Not shown: 998 closed ports
PORT   STATE SERVICE
23/tcp open  telnet
80/tcp open  http
Nmap done: 1 IP address (1 host up) scanned in 0.44 seconds
As expected:

Code: Select all

ffmpeg -i rtsp://admin:@172.20.14.36:554/11 aab.mp4
ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
...
...
[tcp @ 0x555df2a6d900] Connection to tcp://172.20.14.36:554?timeout=0 failed: Connection refused
rtsp://admin:@172.20.14.36:554/11: Connection refused
Post Reply