C ++ - What libraries or command line programs will I need to create a program that takes an AVI file and burns it to a DVD?

My goal is to create a program that will include an AVI file, and then do whatever it takes to burn to a DVD.

I currently use three separate programs for this. The first tool requires me to convert it from an AVI file to MPEG. The second tool accepts this MPEG and creates DVD files (VIDEO_TS folder, with several files inside it). The third tool burns a folder on a DVD. I would like to combine these three tools into one and, if possible, skip the conversion of AVI to MPEG and just create DVD files and burn them.

The target platform is Windows 7, and the language I'm going to use is C ++.

What libraries or command line programs will help me in my quest for fame?

EDIT: To clarify, I want to create a DVD video to play movies on a DVD player. (Thanks Jerry)

EDIT 2: I ended up using Python for Linux to automate everything. Here is a script if someone needs it. (Note: this is my first python script, so it's probably not very good)

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)
+3
source share
3 answers

, Windows, , DVD AVI Linux. : ffmpeg , dvdauthor DVD growisofs, DVD- DVD. , Windows Google ( , ).

  • avi:

    ffmpeg -i <infile.avi> -target ntsc-dvd -threads 2 <outfile.mpg>
    
  • xml DVD:

    :

    <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>
    
  • DVD ( ):

    dvdauthor -x <xmlfile.xml>
    
  • .

    growisofs -Z /dev/dvd -dvd-video dvd/
    

    dvd/, DVD.

, dvdauthor xml. dvdauthor, xml, DVD. , , /dev/dvd/ growisofs DVD- Windows.

, avi mpeg-2: - DVD, MPEG-2 MPEG-PS (Program Stream).

+4

Primo DVD, mpeg-2.

, ffmpeg avis.

+1

, DVD (, -, DVD-) , DVD- .

-, DVD-, AVI MPEG 2, DVD, MPEG2 VOB VIDEO_TS ( ) , DVD.

If you want to burn a file to a data DVD, you can use (for example) the Microsoft Image Mastering API (IMAPI); I believe that version 2 of the API is relevant, so the main functions that you will need are the IFileSystemImage COM interfaces (for creating the image file) and IDiscFormat2Data for writing data to disk.

+1
source

Source: https://habr.com/ru/post/1732914/


All Articles