Created
June 10, 2018 13:38
-
-
Save yy0c/ec56a08d6138a1afbb7ef14d1cff60a1 to your computer and use it in GitHub Desktop.
Remux Apple Developer Videos with subtitles using ffmepg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
#*# coding=utf-8 #*# | |
''' | |
使用函数os.dirlist()读取文件夹内的文件名字 | |
2015.08.06 | |
''' | |
from os import listdir, path, remove, getcwd | |
import subprocess | |
import sys | |
#将文件夹内的文件名读进列表m | |
filepath= getcwd() | |
filename_list=listdir(filepath) | |
h=[] | |
print(h) | |
#可以同过简单后缀名判断,筛选出你所需要的文件(这里以.jpg为例) | |
for filename in filename_list:#依次读入列表中的内容 | |
if filename.endswith('m4v'):# 后缀名'jpg'匹对 | |
h.append(filename)#如果是'jpg'文件就添加进列表h | |
for file in h: | |
fpath = path.join(filepath, file) | |
srtpath = fpath[:-3] + "srt" | |
outputpath = fpath[:-3] + "mp4" | |
print(fpath) | |
subprocess.run(["ffmpeg", "-i", fpath, "-c:v", "copy", "-c:a", "copy", "-sn", "output.mp4"]) | |
subprocess.run(["ffmpeg", "-i", "output.mp4", "-i", srtpath, "-c:s", "mov_text", "-c:v", "copy", "-c:a", "copy", outputpath]) | |
remove("output.mp4") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment