我的目标是创建一个程序,将AVI文件作为输入,然后执行将其刻录到DVD所需的任何操作.
目前,我使用三个独立的程序来完成此任务.第一个工具要求我将其从AVI文件转换为MPEG.第二个工具采用MPEG并创建DVD文件(VIDEO_TS文件夹,其中包含一些文件).第三个工具将文件夹刻录到DVD.我想将这三个工具合二为一,如果可能的话,跳过AVI到MPEG的转换,只需创建DVD文件并刻录它们.
目标平台是Windows 7,我将使用的语言是C.
什么图书馆或命令行程序将帮助我追求荣耀?
编辑:为了澄清,我想创建一个视频DVD来播放DVD播放器上的电影. (谢谢杰里)
编辑2:我最终在Linux上使用Python来自动化一切.这是脚本,以防任何人需要它. (注意:这是我的第一个python脚本,所以它可能不是很好)
import sys
import os
import shutil
from subprocess import call
# step 1: call ffmpeg and convert the input avi to an mpeg-2
def avi_to_mpeg(input, output):
return call(["ffmpeg", "-i", input, "-target", "ntsc-dvd", "-threads", "4", output])
# step 2: create the xml file needed for dvdauthor
def create_xml_file(mpg_source, xml_file):
with open(xml_file, "w") as file:
file.write("<dvdauthor>\n")
file.write("\t<vmgm />\n")
file.write("\t<titleset>\n")
file.write("\t\t<titles>\n")
file.write("\t\t\t<pgc>\n")
file.write("\t\t\t\t<vob file=\"" + mpg_source + "\" />\n")
file.write("\t\t\t</pgc>\n")
file.write("\t\t</titles>\n")
file.write("\t</titleset>\n")
file.write("</dvdauthor>\n")
return os.path.isfile(xml_file)
# step 3: invoke dvdauthor
def author_dvd(mpg_source):
return call(["dvdauthor", "-o", "mkdvd_temp", "-x", xml_file])
# step 4: finally, burn the files to the dvd
def burn_dvd(dvd_target):
return call(["growisofs", "-Z", dvd_target, "-dvd-video", "mkdvd_temp"])
# step 5: clean up the mess
def clean_up(mpg_source, xml_file):
shutil.rmtree("mkdvd_temp")
os.remove(mpg_source)
os.remove(xml_file)
def eject(dvd_target):
return call(["eject", dvd_target])
def print_usage():
print "mkdvd by kitchen"
print "usage: mkdvd -s file.avi -t /dev/disc"
print " -s : Input .AVI file"
print " -t : Target disc, /dev/dvd for example"
def get_arg(sentinel):
last_arg = ""
for arg in sys.argv:
if last_arg == sentinel:
return arg
last_arg = arg
return None
# program start
avi_source = get_arg("-s") # input .avi file
dvd_target = get_arg("-t") # the disc to burn it to (/dev/dvd for example)
if avi_source == None or dvd_target == None:
print_usage()
sys.exit("Not enough parameters.")
if os.path.isfile(avi_source) == False:
sys.exit("File does not exists (" + avi_source + ")")
mpg_source = avi_source + ".mpg"
if avi_to_mpeg(avi_source, mpg_source) != 0:
sys.exit("Failed to convert the AVI to an MPG")
xml_file = mpg_source + ".xml"
if create_xml_file(mpg_source, xml_file) == False:
sys.exit("Failed to create the XML file required by dvdauthor")
if author_dvd(mpg_source) != 0:
sys.exit("Failed to create the DVD files")
if burn_dvd(dvd_target) != 0:
sys.exit("Failed to burn the files to the disc")
print "mkdvd has finished burning " + avi_source + " to " + dvd_target
print "Cleaning up"
clean_up(mpg_source, xml_file)
eject(dvd_target)
解决方法:
我知道你使用的是Windows,但这里是我从linux上的多个AVI创建DVD的步骤.主要的三个程序是ffmpeg进行转码,dvdauthor用于构建DVD文件系统,以及用于从DVD文件系统制作DVD映像的增长程序.我认为你可以通过谷歌找到每个人的Windows二进制文件(我只能很快,但我不想粘贴所有链接).
>转码每个avi:
ffmpeg -i <infile.avi> -target ntsc-dvd -threads 2 <outfile.mpg>
例:
<dvdauthor dest="dvd">
<vmgm>
</vmgm>
<titleset>
<titles>
<pgc>
<vob file="<file1.mpg>" chapters="0,5:00,10:00,15:00,20:00,25:00,30:00,35:00,40:00" />
</pgc>
<pgc>
<vob file="<file2.mpg>" chapters="0,5:00,10:00,15:00,20:00,25:00,30:00,35:00,40:00" />
</pgc>
</titles>
</titleset>
</dvdauthor>
dvdauthor -x <xmlfile.xml>
>将文件系统转换为iso并刻录它.
growisofs -Z /dev/dvd -dvd-video dvd/
其中dvd /是创建DVD文件系统的地方.
只需调用正确的命令行程序并创建dvdauthor xml文件,即可轻松实现此过程的自动化.您需要阅读dvdauthor的文档,以了解有关定义DVD的xml文件的所有详细信息.您还可能需要将growisofs命令中的/ dev / dvd /替换为Windows DVD刻录机驱动器号.
关于你希望你可以跳过从avi到mpeg-2的转码:没有办法做到这一点,仍然使它与DVD标准兼容,后者严格要求在MPEG-PS(节目流)容器中使用MPEG-2视频.