mirror of
https://github.com/kkroening/ffmpeg-python.git
synced 2025-04-06 04:15:44 +08:00
Added Facebook Live Test case
This commit is contained in:
parent
76bc4179c6
commit
ca31154cef
@ -44,7 +44,6 @@ def header(*args, **kwargs):
|
|||||||
"""Add extra header command-line argument(s), e.g. ``-re``.
|
"""Add extra header command-line argument(s), e.g. ``-re``.
|
||||||
"""
|
"""
|
||||||
stream = None
|
stream = None
|
||||||
print("in header: {}, {}, {}".format(repr(stream), args, kwargs))
|
|
||||||
return HeaderNode(name=header.__name__, args=args, kwargs=kwargs).stream()
|
return HeaderNode(name=header.__name__, args=args, kwargs=kwargs).stream()
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,6 +69,7 @@ def _format_output_stream_name(stream_name_map, edge):
|
|||||||
def _get_filter_spec(node, outgoing_edge_map, stream_name_map):
|
def _get_filter_spec(node, outgoing_edge_map, stream_name_map):
|
||||||
incoming_edges = node.incoming_edges
|
incoming_edges = node.incoming_edges
|
||||||
outgoing_edges = get_outgoing_edges(node, outgoing_edge_map)
|
outgoing_edges = get_outgoing_edges(node, outgoing_edge_map)
|
||||||
|
|
||||||
inputs = [
|
inputs = [
|
||||||
_format_input_stream_name(stream_name_map, edge) for edge in incoming_edges
|
_format_input_stream_name(stream_name_map, edge) for edge in incoming_edges
|
||||||
]
|
]
|
||||||
@ -110,8 +111,6 @@ def _get_filter_arg(filter_nodes, outgoing_edge_maps, stream_name_map):
|
|||||||
def _get_header_args(node):
|
def _get_header_args(node):
|
||||||
kwargs = copy.copy(node.kwargs)
|
kwargs = copy.copy(node.kwargs)
|
||||||
args = []
|
args = []
|
||||||
print(node.args)
|
|
||||||
print(node.kwargs)
|
|
||||||
for arg in node.args:
|
for arg in node.args:
|
||||||
args += arg
|
args += arg
|
||||||
args += convert_kwargs_to_cmd_line_args(kwargs)
|
args += convert_kwargs_to_cmd_line_args(kwargs)
|
||||||
@ -131,7 +130,6 @@ def _get_output_args(node, stream_name_map):
|
|||||||
raise ValueError('Output node {} has no mapped streams'.format(node))
|
raise ValueError('Output node {} has no mapped streams'.format(node))
|
||||||
|
|
||||||
for edge in node.incoming_edges:
|
for edge in node.incoming_edges:
|
||||||
# edge = node.incoming_edges[0]
|
|
||||||
stream_name = _format_input_stream_name(
|
stream_name = _format_input_stream_name(
|
||||||
stream_name_map, edge, is_final_arg=True
|
stream_name_map, edge, is_final_arg=True
|
||||||
)
|
)
|
||||||
@ -167,7 +165,6 @@ def get_args(stream_spec, overwrite_output=False):
|
|||||||
sorted_nodes, outgoing_edge_maps = topo_sort(nodes)
|
sorted_nodes, outgoing_edge_maps = topo_sort(nodes)
|
||||||
header_nodes = [node for node in sorted_nodes if isinstance(node, HeaderNode)]
|
header_nodes = [node for node in sorted_nodes if isinstance(node, HeaderNode)]
|
||||||
|
|
||||||
print('{}'.format(repr(header_nodes)))
|
|
||||||
input_nodes = [node for node in sorted_nodes if isinstance(node, InputNode)]
|
input_nodes = [node for node in sorted_nodes if isinstance(node, InputNode)]
|
||||||
output_nodes = [node for node in sorted_nodes if isinstance(node, OutputNode)]
|
output_nodes = [node for node in sorted_nodes if isinstance(node, OutputNode)]
|
||||||
global_nodes = [node for node in sorted_nodes if isinstance(node, GlobalNode)]
|
global_nodes = [node for node in sorted_nodes if isinstance(node, GlobalNode)]
|
||||||
|
@ -198,7 +198,6 @@ class Node(KwargReprNode):
|
|||||||
kwargs={},
|
kwargs={},
|
||||||
):
|
):
|
||||||
stream_map = get_stream_map(stream_spec)
|
stream_map = get_stream_map(stream_spec)
|
||||||
print('{}'.format(stream_map))
|
|
||||||
self.__check_input_len(stream_map, min_inputs, max_inputs)
|
self.__check_input_len(stream_map, min_inputs, max_inputs)
|
||||||
self.__check_input_types(stream_map, incoming_stream_types)
|
self.__check_input_types(stream_map, incoming_stream_types)
|
||||||
incoming_edge_map = self.__get_incoming_edge_map(stream_map)
|
incoming_edge_map = self.__get_incoming_edge_map(stream_map)
|
||||||
|
45
ffmpeg/tests/test_facebook.py
Normal file
45
ffmpeg/tests/test_facebook.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
|
from builtins import bytes
|
||||||
|
from builtins import range
|
||||||
|
from builtins import str
|
||||||
|
import ffmpeg
|
||||||
|
import os
|
||||||
|
import pytest
|
||||||
|
import random
|
||||||
|
import re
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
try:
|
||||||
|
import mock # python 2
|
||||||
|
except ImportError:
|
||||||
|
from unittest import mock # python 3
|
||||||
|
|
||||||
|
def pip_to_facebook(stream_key: str):
|
||||||
|
""" Capture Facetime camera and screen in macOS and stream it to facebook
|
||||||
|
"""
|
||||||
|
facetime_camera_input = (
|
||||||
|
ffmpeg
|
||||||
|
.input('FaceTime:1', format='avfoundation', pix_fmt='uyvy422', framerate=30, s='320x240', probesize='200M')
|
||||||
|
)
|
||||||
|
|
||||||
|
audio = facetime_camera_input.audio
|
||||||
|
|
||||||
|
video = (
|
||||||
|
ffmpeg
|
||||||
|
.header(thread_queue_size='512', vsync='2')
|
||||||
|
.input('1:1', format='avfoundation',
|
||||||
|
pix_fmt='uyvy422', framerate=30, probesize='200M')
|
||||||
|
.overlay(facetime_camera_input)
|
||||||
|
|
||||||
|
)
|
||||||
|
output = (
|
||||||
|
ffmpeg
|
||||||
|
.output(video, audio, 'rtmps://live-api-s.facebook.com:443/rtmp/{}'.format(stream_key), vsync='2', s='1280x720', pix_fmt='yuv420p', video_bitrate='1500000', f='flv',
|
||||||
|
vcodec='libx264', preset='superfast', x264opts='keyint=15', g='30', ac='2', ar='48000', acodec="aac", audio_bitrate="128000")
|
||||||
|
)
|
||||||
|
|
||||||
|
output.overwrite_output().run()
|
||||||
|
|
||||||
|
|
||||||
|
def test_fluent_equality():
|
||||||
|
pip_to_facebook('351682605501180?s_bl=1&s_ps=1&s_sml=1&s_sw=0&s_vt=api-s&a=AbzMoYVOuxBYwxs7')
|
@ -137,10 +137,6 @@ def test_global_args():
|
|||||||
|
|
||||||
def test_header_args():
|
def test_header_args():
|
||||||
|
|
||||||
# header = ffmpeg.header('-re', '-s', thread_queue_size=512)
|
|
||||||
|
|
||||||
# print('in test: {}'.format(repr(header)))
|
|
||||||
|
|
||||||
out_file = (
|
out_file = (
|
||||||
ffmpeg.header(thread_queue_size='512')
|
ffmpeg.header(thread_queue_size='512')
|
||||||
.input("input.mp4")
|
.input("input.mp4")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user