avatar

松果工作室

欢迎光临

  • 首页
  • ESP
  • LVGL
  • freeRTOS
  • 快速笔记
  • 考察日志
  • 个人收藏
  • 我的服务
Home (Linux)FFMPEG 哔哩哔哩推流直播
文章

(Linux)FFMPEG 哔哩哔哩推流直播

Posted 2024-01-21 Updated 2024-01- 21
By YCP
10~13 min read

安装 ffmpeg

apt install ffmpeg

目录依次推流脚本

#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
 
folders=(
# 推流目录
    "/opt/video"
)
 
stream_start(){
# 推流直播地址
    rtmp="rtmp://live-push.bilivideo.com/live-bvc/?streamname=live_93819271_7214171&key=b575bfd5e4769dad3c708f201af3889c&schedule=rtmp&pflag=1"
 
    if [[ $rtmp =~ "rtmp://" ]]; then
        echo -e "${green} 推流地址输入正确,程序将进行下一步操作. ${font}"
        sleep 2
    else  
        echo -e "${red} 你输入的地址不合法,请重新运行程序并输入! ${font}"
        exit 1
    fi 
 
    while true
    do
        for folder in "${folders[@]}"
        do
            if [ -d "$folder" ]; then
                cd "$folder"
                for video in $(ls *.mp4 | sort -V)
                do
                    ffmpeg -re -i "$video" -preset ultrafast -vcodec copy -g 60 -b:v 5000k -c:a aac -b:a 92k -strict -2 -f flv $rtmp
                done
            else
                echo -e "${red} 文件夹不存在: $folder ${font}"
            fi
        done
    done
}
 
# 开始菜单设置
echo -e "${yellow} CentOS7 X86_64mpeg无人值守循环推流 For LALA.IM ${font}"
echo -e "${red} 请确定此脚本目前是在screen窗口内运行的! ${font}"
echo -e "${green} 1.开始无人值守循环推流 ${font}"
echo -e "${green} 2.停止推流 ${font}"
 
start_menu(){
    read -p "请输入数字(1-2),选择你要进行的操作:" num
    case "$num" in
        1)
        stream_start
        ;;
        2)
        screen -S stream -X quit
        killall ffmpeg
        ;;
        *)
        echo -e "${red} 请输入正确的数字 (1-2) ${font}"
        ;;
    esac
}
 
# 运行开始菜单
stream_start
坑和笔记
Linux
License:  CC BY 4.0
Share

Further Reading

Sep 27, 2025

(LIB)一个好用的Modbus解析函数

一个好用的Modbus解析函数 包含03/10/04/06 #include <stdio.h> #include <stdint.h> #include <string.h> #

Jun 21, 2024

(LIB)环形滤波算法

#include <stdio.h> #include <stdlib.h> #define BUFFER_SIZE 10 // 缓冲区大小 #define THRESHOLD 180

Jun 17, 2024

(STM32)STM32 ADC采集的三种方式

采样周期 单个采集模式 ADC_Settings: 程序使用 uint16_t ADC_Read(

OLDER

(Linux)Arm64 中运行 X86_64 Docker镜像

NEWER

(LIB)软件I2C

Recently Updated

  • (ESP-IDF)LVGL 模拟器
  • (ESP-IDF)LVGL 自定义对象加入编码器组
  • (ESP-IDF)vscode配置文件
  • (Elec)来复再生式晶体管单管收音机
  • (ESP-IDF)ESPNOW

Trending Tags

LVGL WCH Linux Elec ThatProject freeRTOS STM ESP Flutter Others

Contents

©2026 松果工作室. Some rights reserved.

Using the Halo theme Chirpy