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

Issues using exec, curl, and pipes #551

Closed
Sammy1Am opened this issue Jul 28, 2023 · 6 comments
Closed

Issues using exec, curl, and pipes #551

Sammy1Am opened this issue Jul 28, 2023 · 6 comments
Labels
question Further information is requested

Comments

@Sammy1Am
Copy link

Sammy1Am commented Jul 28, 2023

I'm running into an issue with a bit of a niche use case. I have a KC401 camera that exposes a sort of weird MJPEG stream that I can only seem to consume via ffmpeg. This command successfully creates a working .mp4 file:

curl -vv -k -u "me@example.com:pAsShAsH" --ignore-content-length https://192.168.0.127:19443/https/stream/mixed --output - | ffmpeg -i - test.mp4

I think the root problem ends up being a combination of curl's parsing and go2rtc's QuoteSplit function.

I initially (naively) tried:

streams:
  test1: exec:curl -vv -k -u "me@example.com:pAsShAsH" --ignore-content-length https://192.168.0.127:19443/https/stream/mixed --output - | ffmpeg -i - test.mp4

But go.exec doesn't do pipes, so I have to wrap things in a bash -c command. This is where the quote issues come to play. There's two ways I can think of to do this:

streams:
  test2: exec:bash -c 'curl -vv -k -u "me@example.com:pAsShAsH" --ignore-content-length https://192.168.0.127:19443/https/stream/mixed --output - | ffmpeg -i - test.mp4'
  test3: exec:bash -c "curl -vv -k -u 'me@example.com:pAsShAsH' --ignore-content-length https://192.168.0.127:19443/https/stream/mixed --output - | ffmpeg -i - test.mp4"

But test2 fails, I think, because QuoteSplit is only looking for double quotes so the bash argument gets all mangled. And test3 fails because for whatever reason curl just includes the single quotes as part of the username. The quotes around the username:password is required because without them curl's parser gets confused by the username being an email address and I get a "no such file or directory" error.

Am I missing some other way to process this stream? Can QuoteSplit be modified to also look for single quotes and support quotes-in-quotes as escaped quotes? Or some other quote-escaping process so I can pass double-quotes to the curl command?

Additional context: ffmpeg can't directly consume the stream because of the required --ignore-content-length which only curl seems to support. If I just put curl in without the ffmpeg, I get an unknown format error.

@Sammy1Am
Copy link
Author

Alright, FWIW, I've worked around the issue by putting the original command that works in a shell script, mounting that script via docker, and then using exec:bash thescript.sh.

Will leave this open just for a bit to see if:

  • Anyone knows of a way to simplify ingesting this stream.
  • It's still useful to support escaping quotes (the script file is an easy work around for this though).

@AlexxIT AlexxIT added the question Further information is requested label Jul 28, 2023
@AlexxIT
Copy link
Owner

AlexxIT commented Jul 28, 2023

Here you output video to file. But not to go2rtc exec:curl xxx - | ffmpeg -i - test.mp4

@Sammy1Am
Copy link
Author

Ah, yeah, sorry, just copy-pasted wrong. It's ... | ffmpeg -i - -f h264 -

@AlexxIT
Copy link
Owner

AlexxIT commented Aug 23, 2023

Can you share stream with me?
https://github.com/AlexxIT/go2rtc/wiki/Tunnel-RTSP-camera-to-Intenet
You can find contacts in the github profile.

@Sammy1Am
Copy link
Author

Info sent on Discord.

@AlexxIT
Copy link
Owner

AlexxIT commented Sep 10, 2023

TP-Link Kasa source added to latest version https://github.com/AlexxIT/go2rtc/releases/tag/v1.7.0

@AlexxIT AlexxIT closed this as completed Sep 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants