ffmpeg 视频流输出的问题

标签 ffmpeg stream video-streaming rtsp

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

method SETUP failed: 455 Method Not Valid In This State



谁能告诉我这个错误的原因以及如何解决它?

工作
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:password@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

最佳答案

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

我检查了它,它给了我 mpeg4:

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: mpeg4 (Simple Profile), yuv420p, 720x480 [SAR 1:1 DAR 3:2], 30 tbr, 30k tbn



因此,您可能编译了 ffmpeg 没有 mpeg4 解码器(或解码器损坏)。

关于ffmpeg 视频流输出的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34686926/

相关文章:

ffmpeg - 如何加快声音和视频的速度并修改音调?

ios - 在 iOS 上以编程方式将 flv 转换为 mp4

javascript - node.js 中管道和流的区别

ffmpeg - 使用ffmpeg将rtsp流式传输到rtmp时丢失数据包错误

html - 在没有 Canvas /显示器的情况下拍摄不可见的 WebRTC/视频照片

laravel - 从 Azure Blob 存储流式传输视频无法搜索且速度极慢

windows - 如何在长 PowerShell 命令中使用变量而不破坏命令

c - SDL Audio - 只播放静态噪音

audio - 如何让 FFmpeg 在单循环静音视频中自动注入(inject) mp3 音轨?

video-streaming - 下载实时 Twitch 流