AlexxIT / go2rtc

Ultimate camera streaming application with support RTSP, RTMP, HTTP-FLV, WebRTC, MSE, HLS, MP4, MJPEG, HomeKit, FFmpeg, etc.
https://github.com/AlexxIT/Blog
MIT License
7.08k stars 504 forks source link

FFMPEG Stream Fails #1324

Open weswitt opened 3 months ago

weswitt commented 3 months ago

Running Version: 1.9.3, Docker on Ubuntu

Trying to convert a H.264 RTSP stream to MJPEG, but it fails. Wondering what I'm doing wrong as I seemed to follow the examples in the README.

Config:

streams:
  test: ffmpeg:rtsp://admin:pwd@192.168.40.13:554/cam/realmonitor?channel=1&subtype=0#video=mjpeg

Log:

08:19:32.070 DBG [exec] run pipe args=["ffmpeg","-hide_banner","-v","error","-allowed_media_types","video","-fflags","nobuffer","-flag
s","low_delay","-timeout","5000000","-user_agent","go2rtc/ffmpeg","-rtsp_flags","prefer_tcp","-i","rtsp://admin:pwd@192.168.40.13:554/cam/realmonitor?channel=1&subtype=0","-c:v","mjpeg","-an","-f","mjpeg","-"]
08:19:34.363 DBG [exec] run pipe launch=2.293563923s
08:19:34.363 WRN [rtsp] error="streams: exec/pipe: %!w(<nil>)\n" stream=test
08:19:35.168 DBG [exec] [vost#0:0/mjpeg @ 0x7f3c0d5df380] Error submitting a packet to the muxer: Broken pipe
08:19:35.168 DBG [exec] [out#0/mjpeg @ 0x7f3c1181d6c0] Error muxing a packet
08:19:35.168 DBG [exec] [out#0/mjpeg @ 0x7f3c1181d6c0] Error writing trailer: Broken pipe
08:19:35.168 DBG [exec] [out#0/mjpeg @ 0x7f3c1181d6c0] Error closing file: Broken pipe
weswitt commented 3 months ago

Another data point. I can execute the exact ffmpeg command in the log and it works perfectly.

AlexxIT commented 3 months ago

Please check v1.9.4 and v1.8.5

weswitt commented 3 months ago

Thanks, upgrading to v1.9.4 seems to have fixed it.

I can connect via the stream link in the GO2RTC web UI just fine. But I have a basic usage question. What URL would I use to connect to the stream from something like VLC? Using the stream URL in the GO2RTC UI does not work from VLC.

weswitt commented 3 months ago

I can do "ffplay rtsp://192.168.10.166:8556/test" and the stream plays perfectly. But VLC cannot connect and play the stream. Any ideas why?

AlexxIT commented 3 months ago

I don't know why you wants to transcoding your RTSP stream to MJPEG. It's better to use default camera format. Transcoding input to MJPEG via FFmpeg is not a cheap operation. Getting RTSP MJPEG from go2rtc also is not a cheap operation. I'll check this situation. Maybe there is some bug with converting MJPEG to RTSP format.

weswitt commented 3 months ago

I want to transcode to MJPEG so that I can view the camera feed from the IP Camera app on my TV. The app does not support H.264 and MJPEG is what it wants.

I'm guessing that the transcode is working given that ffplay works. Is that not a correct assumption??

AlexxIT commented 3 months ago

MJPEG inside RTSP has very limited implementation. It's no surprise if some player works and some doesn't.

Gagi2k commented 2 months ago

Did you try something like this ?

  test:
    - ffmpeg:rtsp://camera-address/mpeg/media.amp?videoframeskipmode=empty#media=video#backchannel=0#hardware
    - ffmpeg:test#video=mjpeg#hardware