1. 准备 ffmpeg for win32
ffmpeg-2023-05-08-git-2d43c23b81-full_build.7z
2. 准备mp4文件,与播放列表文件
# filelist.txt
file 1.Ice.Age.2002.BD1080P.X264.AAC.Mandarin&English.CHS-ENG.mp4
file 2.Ice.Age.The.Meltdown.2006.BD1080P.X264.AAC.Mandarin&English.CHS-ENG.mp4
file 3.Ice.Age.Dawn.of.the.Dinosaurs.2009.BD1080P.X264.AAC.Mandarin&English.CHS-ENG.mp4
file 4.Ice.Age.Continental.Drift.2012.BD1080P.X264.AAC.Mandarin&English.CHS-ENG.mp4
file 5.Ice.Age.Collision.Course.2016.BD1080P.X264.AAC.Mandarin&English.CHS-ENG.mp4
3. 去 bilibili开直播
推流地址是 ① + ②
4. 命令行执行:
"D:\Downloads\ffmpeg-2023-05-08-git-2d43c23b81-full_build\bin\ffmpeg.exe" \
-stream_loop -1 -safe 0 -f concat -i "E:\Downloads\bilbili_live\filelist.txt" \
-vcodec copy -acodec copy -f flv \
"rtmp://live-push.bilivideo.com/live-bvc/?streamname=live_87453990_8834092&key=d6ce52b73db05365c5d529c5b0dec8c1&schedule=rtmp&pflag=1"
离线
推流成功:
51633@DESKTOP-8AVNF99 MINGW64 /d
$ "D:\Downloads\ffmpeg-2023-05-08-git-2d43c23b81-full_build\bin\ffmpeg.exe" -stream_loop -1 -safe 0 -f concat -i "E:\Downloads\bilbili_live\filelist.txt" -vcodec copy -acodec copy -f flv "rtmp://live-push.bilivideo.com/live-bvc/?streamname=live_87453990_8834092&key=d6ce52b73db05365c5d529c5b0dec8c1&schedule=rtmp&pflag=1"
ffmpeg version 2023-05-08-git-2d43c23b81-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers
built with gcc 12.2.0 (Rev10, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
libavutil 58. 7.100 / 58. 7.100
libavcodec 60. 11.100 / 60. 11.100
libavformat 60. 5.100 / 60. 5.100
libavdevice 60. 2.100 / 60. 2.100
libavfilter 9. 7.101 / 9. 7.101
libswscale 7. 2.100 / 7. 2.100
libswresample 4. 11.100 / 4. 11.100
libpostproc 57. 2.100 / 57. 2.100
[matroska,webm @ 000002b016c9aa40] Auto-inserting h264_mp4toannexb bitstream filter
Input #0, concat, from 'E:\Downloads\bilbili_live\filelist.txt':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: h264 (High), yuv420p(progressive), 1920x1040 [SAR 1:1 DAR 24:13], 23.98 fps, 23.98 tbr, 1k tbn
Metadata:
BPS-eng : 4456500
DURATION-eng : 01:21:09.865000000
NUMBER_OF_FRAMES-eng: 116760
NUMBER_OF_BYTES-eng: 2712819676
_STATISTICS_WRITING_APP-eng: mkvmerge v22.0.0 ('At The End Of The World') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2019-02-26 05:40:59
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:1: Audio: aac (LC), 48000 Hz, 5.1, fltp
Metadata:
title : 英语
BPS-eng : 128000
DURATION-eng : 01:21:09.952000000
NUMBER_OF_FRAMES-eng: 228279
NUMBER_OF_BYTES-eng: 77919233
_STATISTICS_WRITING_APP-eng: mkvmerge v22.0.0 ('At The End Of The World') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2019-02-26 05:40:59
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:2: Audio: ac3, 48000 Hz, stereo, fltp, 224 kb/s
Metadata:
title : 国语
BPS-eng : 224000
DURATION-eng : 01:21:09.920000000
NUMBER_OF_FRAMES-eng: 152185
NUMBER_OF_BYTES-eng: 136357760
_STATISTICS_WRITING_APP-eng: mkvmerge v22.0.0 ('At The End Of The World') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2019-02-26 05:40:59
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Output #0, flv, to 'rtmp://live-push.bilivideo.com/live-bvc/?streamname=live_87453990_8834092&key=d6ce52b73db05365c5d529c5b0dec8c1&schedule=rtmp&pflag=1':
Metadata:
encoder : Lavf60.5.100
Stream #0:0: Video: h264 (High) ([7][0][0][0] / 0x0007), yuv420p(progressive), 1920x1040 [SAR 1:1 DAR 24:13], q=2-31, 23.98 fps, 23.98 tbr, 1k tbn
Metadata:
BPS-eng : 4456500
DURATION-eng : 01:21:09.865000000
NUMBER_OF_FRAMES-eng: 116760
NUMBER_OF_BYTES-eng: 2712819676
_STATISTICS_WRITING_APP-eng: mkvmerge v22.0.0 ('At The End Of The World') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2019-02-26 05:40:59
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:1: Audio: aac (LC) ([10][0][0][0] / 0x000A), 48000 Hz, 5.1, fltp
Metadata:
title : 英语
BPS-eng : 128000
DURATION-eng : 01:21:09.952000000
NUMBER_OF_FRAMES-eng: 228279
NUMBER_OF_BYTES-eng: 77919233
_STATISTICS_WRITING_APP-eng: mkvmerge v22.0.0 ('At The End Of The World') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2019-02-26 05:40:59
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[in#0/concat @ 000002b016c8e800] New audio stream with index 2 at pos:15039 and DTS:0sed=N/A
frame= 2100 fps=120 q=-1.0 size= 39773kB time=00:01:27.80 bitrate=3710.6kbits/s speed=5.03x
观看地址:
离线
frame=1369038 fps= 63 q=-1.0 size=39847858kB time=15:51:41.31 bitrate=frame=1369040 fps= 63 q=-1.0 size=39847955kB time=15:51:41.33 bitrate=frame=1369045 fps= 63 q=-1.0 size=39848268kB time=15:51:41.68 bitrate=frame=1369051 fps= 63 q=-1.0 size=39848583kB time=15:51:41.78 bitrate=frame=1369071 fps= 63 q=-1.0 size=39848903kB time=15:51:42.79 bitrate=frame=1369088 fps= 63 q=-1.0 size=39849110kB time=15:51:43.49 bitrate=frame=1369129 fps= 63 q=-1.0 size=39849465kB time=15:51:45.03 bitrate=frame=1369155 fps= 63 q=-1.0 size=39849907kB time=15:51:46.20 bitrate=frame=1369182 fps= 63 q=-1.0 size=39850172kB time=15:51:47.46 bitrate=frame=1369205 fps= 63 q=-1.0 size=39850575kB time=15:51:48.20 bitrate=frame=1369207 fps= 63 q=-1.0 size=39850600kB time=15:51:48.35 bitrate=frame=1369223 fps= 63 q=-1.0 size=39850762kB time=15:51:49.04 bitrate=frame=1369236 fps= 63 q=-1.0 size=39850868kB time=15:51:49.57 bitrate=frame=1369245 fps= 63 q=-1.0 size=39850966kB time=15:51:49.91 bitrate=av_interleaved_write_frame(): Error number -10054 occurred
[out#0/flv @ 000001c997a6be00] Error muxing a packet
frame=1369257 fps= 63 q=-1.0 size=39851059kB time=15:51:50.42 bitrate=[flv @ 000001c998015440] Failed to update header with correct duration.
[flv @ 000001c998015440] Failed to update header with correct filesize.
[out#0/flv @ 000001c997a6be00] Error writing trailer: Error number -10054 occurred
[out#0/flv @ 000001c997a6be00] Error closing file: Error number -10054 occurred
[out#0/flv @ 000001c997a6be00] video:38887853kB audio:892194kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.178915%
frame=1369257 fps= 63 q=-1.0 Lsize=39851220kB time=15:51:50.45 bitrate=5716.3kbits/s speed=2.64x
Conversion failed!
ffmpeg直接推rtmp流到bilibili服务器,如果碰到网络10054 问题会退出进程,所以上面的脚本需要优化一下,或者配合nginx推流。
离线