FFmpeg RTSP流通過UDP傳輸問題


 

我自己在使用SRS服務的Ingest功能時發現在讀取一個網絡攝像頭的RTSP流時一直不成功,

具體分析后發現SRS在調用FFmpeg時出了問題:

/usr/local/ffmpeg/bin/ffmpeg -i rtsp://admin:admin123@192.168.50.187:554/profile1 -vcodec copy -acodec copy -f flv -y rtmp://192.168.50.212/live/test

報錯如下:

[rtsp @ 0x55842477d740] UDP timeout, retrying with TCP
[rtsp @ 0x55842477d740] method SETUP failed: 404 Unknown Error!
[rtsp @ 0x55842477d740] Could not find codec parameters for stream 0 (Video: h264, none): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Guessed Channel Layout for Input Stream #0.1 : mono
Input #0, rtsp, from 'rtsp://admin:admin123@192.168.50.187:554/profile1':
  Metadata:
    title           : profile1
  Duration: N/A, start: 0.000000, bitrate: 64 kb/s
    Stream #0:0: Video: h264, none, 90k tbr, 90k tbn, 180k tbc
    Stream #0:1: Audio: pcm_alaw, 8000 Hz, mono, s16, 64 kb/s
Output #0, flv, to 'rtmp://192.168.50.212/live/test':
  Metadata:
    title           : profile1
    encoder         : Lavf58.27.103
    Stream #0:0: Audio: pcm_alaw ([7][0][0][0] / 0x0007), 8000 Hz, mono, s16, 64 kb/s
Stream mapping:
  Stream #0:1 -> #0:0 (copy)
Press [q] to stop, [?] for help
[flv @ 0x5584247e5a00] Failed to update header with correct duration.
[flv @ 0x5584247e5a00] Failed to update header with correct filesize.
size=       0kB time=00:00:00.00 bitrate=N/A speed=   0x    
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)

 

在網上搜了一下,發現命令中強制使用TCP鏈接就不會報錯:

/usr/local/ffmpeg/bin/ffmpeg -rtsp_transport tcp -i rtsp://admin:admin123@192.168.50.187:554/profile1 -vcodec copy -acodec copy -f flv -y rtmp://192.168.50.212/live/test

 

但是搜了半天也沒人解釋的清楚為什么,暫且找到相關的兩篇記錄下來:

https://github.com/ZoneMinder/ZoneMinder/issues/811

 

http://mamicode.com/info-detail-1871429.html

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM