相同的命令可以翻译成这样的:
#Import library
import ffmpeg
#Define vars
video="input.mp4"
sub1="subs/en/en_srt_sub.srt"
l1="en"
t1="English"
sub2="subs/fr/fr_srt_sub.srt"
l2="fr"
t2="French"
output_file="output.mkv"
#Define input values
input_ffmpeg = ffmpeg.input(video)
input_ffmpeg_sub1 = ffmpeg.input(sub1)
input_ffmpeg_sub2 = ffmpeg.input(sub2)
#Define output file
input_video = input_ffmpeg['v']
input_audio = input_ffmpeg['a']
input_subtitles1 = input_ffmpeg_sub1['s']
input_subtitles2 = input_ffmpeg_sub['s']
output_ffmpeg = ffmpeg.output(
input_video, input_audio, input_subtitles1, input_subtitles2, output_file,
vcodec='copy', acodec='copy',
**{'metadata:s:s:0': "language="+l1, 'metadata:s:s:0': "title="+t1, 'metadata:s:s:1': "language="+l2, 'metadata:s:s:1': "title="+t2 }
)
# If the destination file already exists, overwrite it.
output_ffmpeg = ffmpeg.overwrite_output(output_ffmpeg)
# Print the equivalent ffmpeg command we could run to perform the same action as above.
print(ffmpeg.compile(output_ffmpeg))
# Do it! transcode!
ffmpeg.run(output_ffmpeg)
为了添加其他流元数据,您可以在官方文档中查看自定义过滤器。