如何使用ffmpeg将实时m3u8文件流式传输到youtube rtmp

如何使用ffmpeg将实时m3u8文件流式传输到youtube rtmp,ffmpeg,http-live-streaming,m3u8,youtube-livestreaming-api,m3u,Ffmpeg,Http Live Streaming,M3u8,Youtube Livestreaming Api,M3u,我想将一个实时m3u8文件重新传输到youtube .我使用了以下代码 fmpeg -re -i <http://mypanel.tv:8080/live/****/slyv0955k9/14131.m3u8 > -c:v copy -c:a aac -ar 44100 -ab 128k -ac 2 -strict -2 -flags +global_header -bsf:a aac_adtstoasc -bufsize 3000k -f flv "<rtmp://live-

我想将一个实时m3u8文件重新传输到youtube .我使用了以下代码

fmpeg -re -i <http://mypanel.tv:8080/live/****/slyv0955k9/14131.m3u8
> -c:v copy -c:a aac -ar 44100 -ab 128k -ac 2 -strict -2 -flags +global_header -bsf:a aac_adtstoasc -bufsize 3000k -f flv "<rtmp://live-dfw.twitch.tv/app/{live_231566994_FS4BN0qoJMeXEuWklm6j0l1ODQj9u6}>"
fmpeg-re-i-c:v copy-c:aac-ar 44100-ab 128k-ac 2-strict-2-flags+global_header-bsf:aac_adtstoasc-bufsize 3000k-f flv“
我从我的linux服务器上得到这个

[root@server ~]# ffmpeg -re -i http://mypanel.tv:8080/live/****/slyv0955k9/14131.m3u8
 -c:v copy -c:a aac -ar 44100 -ab 128k -ac 2 -strict -2 -flags +global_header -bsf:a aac_adtstoasc -bufsize 3000k -f flv "<rtmp://live-dfw.twitch.tv/app/{live_23156556994_FS4BN0qoJMeXEuWklm6j0l1ODQj9u6}>"ffmpeg version 2.6.8 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-4)
  configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --enable-bzlib --disable-crystalhd --enable-gnutls --enable-ladspa --enable-libass --enable-libcdio --enable-libdc1394 --enable-libfaac --enable-nonfree --enable-libfdk-aac --enable-nonfree --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect
  libavutil      54. 20.100 / 54. 20.100
  libavcodec     56. 26.100 / 56. 26.100
  libavformat    56. 25.101 / 56. 25.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 11.102 /  5. 11.102
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
[h264 @ 0x1029ba0] non-existing SPS 0 referenced in buffering period
    Last message repeated 1 times
[h264 @ 0x1073680] non-existing SPS 0 referenced in buffering period
Input #0, hls,applehttp, from 'http://mypanel.tv:8080/live/***/slyv0955k9/14131.m3u8':
  Duration: N/A, start: 39062.400000, bitrate: N/A
  Program 0
    Metadata:
      variant_bitrate : 0
    Stream #0:0: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 133 kb/s
At least one output file must be specified
[root@server~]#ffmpeg-re-ihttp://mypanel.tv:8080/live/****/slyv0955k9/14131.m3u8
-c:v copy-c:a aac-ar 44100-ab 128k-ac 2-strict-2-flags+global_header-bsf:a aac_adtstoasc-bufsize 3000k-f flv“ffmpeg版本2.6.8版权所有(c)2000-2016 ffmpeg开发者
根据gcc 4.8.5(gcc)20150623(红帽4.8.5-4)构建
配置:--prefix=/usr--bindir=/usr/bin--datadir=/usr/share/ffmpeg--incdir=/usr/ffmpeg--libdir=/usr/lib64--mandir=/usr/share/man--arch=x86_64--optflags='-O2-g-pipe-Wall-Wp,-D_FORTIFY_SOURCE=2-feexceptions-fstack protector strong--param=ssp buffer size=4-grecord gcc开关-m64-mtune=generic'--enable bzlib--disable crystalhd--enable gnutls--enable ladspa--enable libass enable libcdio--enable-libfaac--enable nonfree--enable libfdk aac--enable nonfree--disable indev jack--启用libfreetype--enable libgsm--enable-libmp3lame--enable openal--enable libopenjpeg--enable libopus--enable libpulse--enable libschroedinger--enable libsoxr--enable libspeex--enable libvorbis--enable-libv4l2--enable-libx264--enable-libx265--enable libxvid enable-x11grab--enable avfilter--enable avresample--enable postproc--enable pthreads--disable static--enable shared--enable gpl--disable debug--disable stripping--shlibdir=/usr/lib64--enable runtime cpudetec
libavutil 54。20.100 / 54. 20.100
libavcodec56。26.100 / 56. 26.100
libav56格式。25.101 / 56. 25.101
libav56设备。4.100 / 56.  4.100
libavfilter 5。11.102 /  5. 11.102
libavresample2。1.0 /  2.  1.0
libswscale 3。1.101 /  3.  1.101
libswresample1。1.100 /  1.  1.100
Libroc 53。3.100 / 53.  3.100
[h264@0x1029ba0]缓冲期中引用的不存在SPS 0
最后一条消息重复了1次
[h264@0x1073680]缓冲期中引用的不存在SPS 0
输入#0,hls,applehttp,从'http://mypanel.tv:8080/live/***/slyv0955k9/14131.m3u8':
持续时间:不适用,起始时间:39062.400000,比特率:不适用
程序0
元数据:
变量\u比特率:0
流#0:0:视频:h264(主)([27][0][0][0]/0x001B),yuv420p,1280x720[SAR 1:1 DAR 16:9],每秒25帧,每小时25次,每小时90千次,每小时50次
流#0:1:音频:aac(LC)([15][0][0][0]/0x000F),48000 Hz,立体声,fltp,133 kb/s
必须至少指定一个输出文件
有人能帮我吗?请注意,我不是linux专家,所以请给我特定的命令来重新格式化一个实时m3u8文件

试试看:

#! /bin/bash

PRESET="ultrafast" # ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo
SOURCE="http://sample.vodobox.net/skate_phantom_flex_4k/skate_phantom_flex_4k.m3u8"
YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2"
KEY="xxxx-xxxx-xxxx-xxxx" # Your youtube key. (https://www.youtube.com/live_dashboard > encoder config > name/key)

ffmpeg \
    -re -i "$SOURCE" -vcodec libx264 -preset $PRESET -maxrate 3000k -b:v 2500k \
    -bufsize 600k -pix_fmt yuv420p -g 60 -c:a aac -b:a 160k -ac 2 \
    -ar 44100 -f flv -s 1280x720 "$YOUTUBE_URL/$KEY"

这也适用于windows构建,您只需要填写变量或使用批处理脚本。非常感谢!