ffmpeg问题与视频流的输出

时间:2016-01-08 22:06:53

标签: ffmpeg stream video-streaming rtsp

我有两个视频流,我想从中获取一个帧,两个都是RTSP。我正在为它们使用相同的FFMPEG指令,但更改流的URL,第一个工作,但第二个抛出错误:

  

方法SETUP失败:455方法在此状态下无效

有谁能告诉我这个错误可能是什么原因以及如何解决?

WORKING

ffmpeg -ss 1 -i rtsp://streamreader:trudat55@69.84.126.216:88/videoMain -an -vcodec mjpeg -vframes 1 -aspect 16:9 -q:v 2 -y test.jpg

ffmpeg version 2.8.2 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.9.2 (Debian 4.9.2-10)
  configuration: --enable-gpl --enable-avresample --enable-libopencore-amrnb --enable-libx264 --enable-libxvid --enable-postproc --enable-version3 --enable-shared --enable-pic --extra-ldexeflags=-pie
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
[rtsp @ 0x55a60a0a7420] UDP timeout, retrying with TCP
Guessed Channel Layout for  Input Stream #0.1 : mono
Input #0, rtsp, from 'rtsp://streamreader:trudat55@69.84.126.216:88/videoMain':
  Metadata:
    title           : IP Camera Video
    comment         : videoMain
  Duration: N/A, start: 0.200044, bitrate: N/A
    Stream #0:0: Video: h264 (Baseline), yuv420p, 640x480, 50 tbr, 90k tbn, 180k tbc
    Stream #0:1: Audio: pcm_mulaw, 8000 Hz, 1 channels, s16, 64 kb/s
[swscaler @ 0x55a60a102460] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to 'test.jpg':
  Metadata:
    title           : IP Camera Video
    comment         : videoMain
    encoder         : Lavf56.40.101
    Stream #0:0: Video: mjpeg, yuvj420p(pc), 640x480 [SAR 4:3 DAR 16:9], q=2-31, 200 kb/s, 50 fps, 50 tbn, 50 tbc
    Metadata:
      encoder         : Lavc56.60.100 mjpeg
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
Press [q] to stop, [?] for help
frame=    1 fps=0.5 q=2.0 Lsize=N/A time=00:00:00.02 bitrate=N/A dup=1 drop=1    
video:66kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

不工作

ffmpeg -ss 1 -i rtsp://camaras.corredorautomotriz.cl:554/live.sdp -an -vcodec mjpeg -vframes 1 -aspect 16:9 -q:v 2 -y test.jpg

ffmpeg version 2.8.2 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.9.2 (Debian 4.9.2-10)
  configuration: --enable-gpl --enable-avresample --enable-libopencore-amrnb --enable-libx264 --enable-libxvid --enable-postproc --enable-version3 --enable-shared --enable-pic --extra-ldexeflags=-pie
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
[rtsp @ 0x55b98f2de420] UDP timeout, retrying with TCP
[rtsp @ 0x55b98f2de420] method SETUP failed: 455 Method Not Valid In This State
[rtsp @ 0x55b98f2de420] Could not find codec parameters for stream 0 (Video: mjpeg, none(bt470bg/unknown/unknown)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, rtsp, from 'rtsp://camaras.corredorautomotriz.cl:554/live.sdp':
  Metadata:
    title           : RTSP server
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: mjpeg, none(bt470bg/unknown/unknown), 90k tbr, 90k tbn, 90k tbc
    Stream #0:1: Data: none
Output #0, image2, to 'test.jpg':
Output file #0 does not contain any stream

2 个答案:

答案 0 :(得分:1)

正如我在输出中看到的,ffmpeg在第二种情况下无法确定输入流类型(rtsp://camaras.corredorautomotriz.cl:554 / live.sdp)。

我查了一下,它让我 mpeg4

  

输入#0,rtsp,来自'rtsp://camaras.corredorautomotriz.cl:554 / live.sdp':

     

元数据:

     

标题:RTSP服务器

     

持续时间:N / A,开始:0.000000,比特率:N / A

     

流#0:0:视频:mpeg4(简单配置文件),yuv420p,720x480 [SAR 1:1 DAR 3:2],30 tbr,30k tbn

因此,您可能在没有 mpeg4 解码器(或解码器损坏)的情况下编译 ffmpeg

答案 1 :(得分:0)

我发现如果我使用指令-rtsp_transport tcp指定协议是TCP,那么我不会收到错误:

ffmpeg -ss 5 -rtsp_transport tcp -i rtsp://camaras.corredorautomotriz.cl:554 / live.sdp -s 640x480 -aspect 16:9 -b:v 800k -r 24 video.flv

但我仍然想知道我之前遇到的问题的原因和解决方法,因为我不确定我是否可以使用此参数。有人知道吗?

由于