Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FFMPEG Issues #33

Open
zombielinux opened this issue Jun 7, 2023 · 9 comments
Open

FFMPEG Issues #33

zombielinux opened this issue Jun 7, 2023 · 9 comments

Comments

@zombielinux
Copy link

I'm getting the error:

"rtmp://fqdn/bcs/channel0_main.bcs?user=admin&password=$PASS: No such file or directory"
"Error: ffmpeg error (see stderr output for detail)"
" Recording failed. Error: ffmpeg error (see stderr output for detail)"

How can I redirect the stderr to the docker log?

Further, I had similar issues with this (Reolink) camera in Frigate and had to add specific ffmpeg directives. Specifically:

    ffmpeg:
      input_args:
        - -avoid_negative_ts
        - make_zero
        - -fflags
        - nobuffer
        - -flags
        - low_delay
        - -strict
        - experimental
        - -fflags
        - +genpts+discardcorrupt
        - -rw_timeout
        - '5000000'
        - -use_wallclock_as_timestamps
        - '1'

From my frigate config.

@mmcc-xx
Copy link
Owner

mmcc-xx commented Jun 7, 2023

How can I redirect the stderr to the docker log?

I honestly have no idea. Sorry! Does your password happen to have any special characters in it? I wonder if I'm not handling that correctly.

I am also using a Reolink camera, but instead of pointing this app at the camera directly, I point it at the re-broadcast provided by Frigate.

In my Frigate config, I set up go2rtc like this...

go2rtc:
  streams:
    birdcam:
      - rtsp://admin:[email protected]:554/h264Preview_01_sub
    webrtc:
      candidates:
        - 192.168.1.75:8555
        - stun:8555

And in birdcage, I point at rtsp://192.168.1.75:8554/birdcam with tcp transport. Check out the Frigate docs for the go2rtc section - I think there's a way to reference existing camera definitions.

If you have go2rtc set up in Frigate you can go to this URL (where 192.168.1.75 is your server's IP address and birdcam is the name of your camera):
http://192.168.1.75:5000/live/webrtc/links.html?src=birdcam

And see the various ways that go2rtc will give you to access your camera. This might be easier than figuring out the problems with ffmpeg.

Also for birdcam's purposes you do not need the high res stream. I'm using the rtmp stream from my camera to record from in Frigate (that is rtmp://192.168.1.114/bcs/channel0_main.bcs?channel=0&stream=0&user=admin&password=mypassword) but the lower video res stream has the same audio as the high video res stream (I think). So that's what I have set up in go2rtc.

(FWIW though, I didn't need all of that ffmpeg config in Frigate to get it working with my camera)

I'm using a python library that is just a wrapper around ffmpeg,=, and the ffmpeg command I'm using is really simple. For an rtmp stream:

           ffmpeg
                .input(stream_url)
                .output(output_filename, format='wav', t=seconds, loglevel='warning')
                .run()

so it should be the same as running ffmpeg -i rtmp://fqdn/bcs/channel0_main.bcs?user=admin&password=$PASS output.wav -t 15 or something close to that. If that works from the command line of your server but you're still getting errors from the app, let me know.

@zombielinux
Copy link
Author

Nope! No weird characters in the password. Just standard ASCII (not even unicode).

Neat! I only saw the audio checkbox for the higher resolution stream, so piping through frigate would be much better.

My Reolink (RLC-410) has had significant issues in the past on the RTSP stream, but the RTMP stream has always been fine. There's a million posts about it on all the DVR forums as well as Reolink's forums.

I'll admit to using an ancient version of Frigate (should have been updated, but life is busy). Its probably unnecessary at this point, but I'll get to cleaning that cruft out eventually.

It seems to be working now, so we'll see whats tweeting around here. Thanks for your help!

@WanderingStar
Copy link
Collaborator

I submitted a PR to print the contents of stderr. It doesn't really help in my case, because it just says

  stderr: alsa_input.pci-0000_00_1f.3.analog-stereo.2: Input/output error

@mmcc-xx
Copy link
Owner

mmcc-xx commented Jul 23, 2023

Ahh see the problem is that you've got an Input/output error. ffmpeg can be so helpful.

Thanks for the PR - I merged it in.

There might be a way to increase the loglevel to get ffmpeg to give more info:

kkroening/ffmpeg-python#30

I have not done more than briefly skim that, but it does mention a way to pass in loglevel.

@WanderingStar
Copy link
Collaborator

I ended up using docker exec and running pactl and ffmpeg in the container until I got it to work. I think commenting this out of default.pa is the thing that made it finally work:
load-module module-suspend-on-idle

But now the logs show it's recording audio and analyzing it to have vanishingly small probabilities of birds even when I play bird sounds right into the mic, so further debugging to do.

Incidentally, is there a way to let people PR edits to the wiki?

@mmcc-xx
Copy link
Owner

mmcc-xx commented Jul 23, 2023

Incidentally, is there a way to let people PR edits to the wiki?

I have no idea :) With it being a wiki I'd assume you can just change stuff willy-nilly. What did you have in mind?

When I did my testing of pulse audio, I played bird songs from youtube into a mic and it seemed to work. But, audio in linux always makes me crazy.

@WanderingStar
Copy link
Collaborator

I don't know how much of spam magnet this is, but: https://docs.github.com/en/communities/documenting-your-project-with-wikis/changing-access-permissions-for-wikis

I was going to add some tips on what helped me to debug the PA problems.

@mmcc-xx
Copy link
Owner

mmcc-xx commented Jul 24, 2023

Yeah I don't think I want to open it up - would you object to being made a collaborator?

@WanderingStar
Copy link
Collaborator

No, I'm happy to be a collaborator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants