ffmpeg - 无法在 os x 上使用 ffmpeg 从 mp4(h264) 文件中蒸汽 rtsp:连接被拒绝 无法为输出文件写入标头
问题描述
我在我的 macbook os high sierra 上使用以下命令使用 ffmpeg 从 mp4 文件流式传输 rtsp:
sudo ffmpeg -re -i ./Big_Buck_Bunny_1080_10s_1MB.mp4 -c:v libx264 -preset superfast -tune zerolatency -c:a aac -ar 44100 -f rtsp -rtsp_transport udp rtsp://127.0.0.1:8888/live
但得到以下错误:
[tcp @ 0x7fb979e22ec0] Connection to tcp://127.0.0.1:1935?timeout=0 failed: Connection refused
Could not write header for output file #0 (incorrect codec parameters ?): Connection refused
Error initializing output stream 0:0 --
Conversion failed!
这是命令的全部输出:
ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
built with Apple LLVM version 10.0.0 (clang-1000.11.45.5)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './Big_Buck_Bunny_1080_10s_1MB.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
title : Big Buck Bunny, Sunflower version
artist : Blender Foundation 2008, Janus Bager Kristensen 2013
composer : Sacha Goedegebure
encoder : Lavf57.63.100
comment : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
genre : Animation
Duration: 00:00:10.00, start: 0.000000, bitrate: 815 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 812 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x7fb97a00de00] using SAR=1/1
[libx264 @ 0x7fb97a00de00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7fb97a00de00] profile High, level 4.0, 4:2:0, 8-bit
[libx264 @ 0x7fb97a00de00] 264 - core 160 r3011 cde9a93 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x3 me=dia subme=1 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=12 lookahead_threads=12 sliced_threads=1 slices=12 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=1 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc=crf mbtree=0 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[tcp @ 0x7fb979e22ec0] Connection to tcp://127.0.0.1:1935?timeout=0 failed: Connection refused
Could not write header for output file #0 (incorrect codec parameters ?): Connection refused
Error initializing output stream 0:0 --
Conversion failed!
尝试使用和不使用 sudo,尝试将 rtsp://... 更改为 http:// 也尝试了 udp 但得到相同的输出..
查出该端口未使用(8888)和不同的端口(1935 ...),但仍然相同。
我通过 brew install 安装了ffmpeg ...
当我在我的本地主机上运行一些测试服务器时,我从来没有遇到过使用未使用端口的问题
真的被困在这里,任何帮助都会很棒......谢谢
解决方案
推荐阅读
- angular - Confirm message before closing material dialog accidentally in Angular?
- sql-server - 将日期从 Nvarchar 转换为 smalldatetime
- spring - Spring Cloud 流无法自动装配 Source.class
- javascript - 为 Gutenberg 块定义 Javascript 类型(wordpress)
- python - 如何在 python 中解析 Json 数据并加载到 SQL Server?
- latex - 用 LaTex 画图(图论)
- python - 将“+”号添加到 pandas df 中的正数
- node.js - Implementing interface from different package (callback from other module)
- docker - 如何让 docker-compose 拉取新图像?
- mysql - 我试图对一个 mysql 模型进行正向工程,但它不起作用