ffmpeg+subprocess+python+srs: subprocess通过推麦克风,音频,话筒到srs服务器中 【只推音频】

代码:

import subprocess
import os
import multiprocessing as mp
import threading
import cv2

def push(comman):
    print('push: ',os.getpid())
    child = subprocess.Popen(
        comman,
        shell=False, stdin=subprocess.PIPE, encoding="utf-8")
    child.wait()
if __name__ == '__main__':
    print('main: ',os.getpid())
    rtmp = 'rtmp://122.95.32.117/only/audio'

    comman =[
        'ffmpeg', '-y' ,
        '-f', 'dshow' ,
        '-i' ,'''audio=Microphone (High Definition Audio Device)''',
        '-sample_rate', '44100',
        '-sample_size', '16',
        '-channels', '1',
        '-acodec', 'aac',
        '-fflags', 'nobuffer',
        '-r', '29.97',
        '-f', 'flv',
        str(rtmp)
        ]
    push(comman)

推流到srs视频服务器中,通过python代码来控制。

你可能感兴趣的:(ffmpeg)