import
os
import
subprocess
import
time
import
re
push_url
=
"rtmp://tx.direct.huya.com/huyalive/1299644932728-1299644932728-0-2399289286892-10057-A-1722472914-1?seq=1722472915126&type=simple"
video_dir
=
"/home/lee/Desktop/video"
def
natural_sort_key(s):
numbers
=
[
int
(text)
for
text
in
re.findall(r
'\d+'
, s)]
if
not
numbers:
return
float
(
'-inf'
)
return
numbers[
0
]
while
True
:
video_list
=
sorted
(os.listdir(video_dir), key
=
natural_sort_key)
for
video_file
in
video_list:
video_path
=
os.path.join(video_dir, video_file)
print
(f
"Processing file: {video_path}"
)
cmd
=
f
"ffmpeg -re -i \"{video_path}\" -c:v libx264 -preset fast -c:a aac -strict -2 -f flv \"{push_url}\""
print
(f
"Running command: {cmd}"
)
subprocess.call(cmd, shell
=
True
)
time.sleep(
0.1
)