nginx + rtmp module + ffmpeg + ffplay 的RTMP例子

本文详细介绍了使用FFmpeg工具进行实时音视频编码,并将其推流至Nginx RTMP模块搭建的直播服务器的具体过程。涵盖FFmpeg参数详解,如-iurl、-ffmt、-c、-re等,以及Nginx配置示例,适用于直播场景。

省略nginx + rtmpmodule的过程,可以参考:https://www.cnblogs.com/jys509/p/5649066.html

####################################################################################################
# -i url (input)
#  input file url
#
# -f fmt (input/output)
#  Force input or output file format. The format is normally auto detected for input files
#   and guessed from the file extension for output files, so this option is not needed in 
#   most cases.
#
# -c[:stream_specifier] codec (input/output,per-stream)
# -codec[:stream_specifier] codec (input/output,per-stream)
#  Select an encoder (when used before an output file) or a decoder (when used before an 
#    input file) for one or more streams. codec is the name of a decoder/encoder or a 
#    special value copy (output only) to indicate that the stream is not to be re-encoded.
#
# -re (input)
#   Read input at native frame rate. Mainly used to simulate a grab device, or live 
#    input stream (e.g. when reading from a file). Should not be used with actual grab 
#    devices or live input streams (where it can cause packet loss). By default ffmpeg attempts
#    to read the input(s) as fast as possible. This option will slow down the reading of the 
#    input(s) to the native frame rate of the input(s). It is useful for real-time 
#    output (e.g. live streaming).
#
# -strict 2
#  Native FFmpeg AAC encoder 
#  The native FFmpeg AAC encoder. This is currently the second highest-quality AAC encoder 
#   available in FFmpeg and does not require an external library like the other AAC encoders 
#   described here. This is the default AAC encoder.
#  Note: -strict experimental (or -strict -2) was previously required for this encoder, but 
#   it is  no longer experimental and these options are unnecessary since 5 December 2015.
#
# add the below to nginx.conf(nginx + rtmp module)
# rtmp {
#     server 1935;
#     application rtmplive {
#         live on;
#         record off;
#     }
# }
#
# ffplay rtmp://localhost/rtmplive/room
##########################################################################################

ffmpeg -re -i a.mp4 -vcodec copy -acodec copy -f flv rtmp://192.168.1.11:1935/rtmplive/room

#ffmpeg -re -i a.mp4 -vcodec libx264 -acodec aac -f flv rtmp://192.168.1.11:1935/rtmplive/room


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值