NAV
python

Καλώς ορίσατε στην τεκμηρίωση MP4.to API

Για να λάβετε ένα κλειδί προγραμματιστή, μεταβείτε στοπύλη προγραμματιστή

Authorization: <api_key>

Μετατροπή από MP4

MP4 έως WAV

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-wav',
}

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.wav

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως M4A

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-m4a'
}

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.m4a

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως FLAC

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-flac'
}

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.flac

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως WMA

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-wma'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.wma

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως WAV

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-aiff'
}

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.aiff

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως AAC

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-aac'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.aac

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως MP2

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-mp2'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp2

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως M4R

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-m4r'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.m4r

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως OGG

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-ogg'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.ogg

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως AC3

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-ac3'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.ac3

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως AMR

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-amr'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.amr

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως DTS

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-dts'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.dts

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως AMR

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-amr'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.amr

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 σε OPUS

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-opus'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.opus

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως MP3

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-mp3'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp3

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως AVI

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-avi'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.avi

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως WMV

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-wmv'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.wmv

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως MPEG

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-mpeg'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mpeg

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως MOV

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-mov'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mov

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως MPG

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-mpg'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mpg

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως DIVX

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-divx'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.divx

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως WEBM

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-webm'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.webm

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως FLV

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-flv'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.flv

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως 3GP

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-3gp'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.3gp

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως VOB

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-vob'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.vob

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως AV1

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-av1'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.av1

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως M4V

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-m4v'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.m4v

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως HLS

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-hls'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.hls

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως M3U8

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-m3u8'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.m3u8

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως MKV

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-mkv'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mkv

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως GIF

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-gif'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.gif

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως WEBP

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-webp'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.webp

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως ZIP

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp4-zip'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.zip

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

Μετατροπή σε MP4

WAV σε MP4

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'wav-mp4'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp4

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

M4A έως MP4

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'm4a-mp4'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp4

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

FLAC έως MP4

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'flac-mp4'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp4

WMA έως MP4

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'wma-mp4'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp4

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

AIFF έως MP4

import requests
import time
import shutil
import json



headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'aiff-mp4'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp4

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP2 έως MP4

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp2-mp4'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp4

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP2 έως MP4

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mp2-mp4'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp4

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

M4R έως MP4

import requests
import time
import shutil
import json



headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'm4r-mp4'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp4

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

OGG σε MP4

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'ogg-mp4'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp4

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

AC3 έως MP4

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'ac3-mp4'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp4

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

AMR έως MP4

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'amr-mp4'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp4

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

DTS έως MP4

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'dts-mp4'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp4

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

OPUS σε MP4

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'opus-mp4'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp4

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP3 έως MP4

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp3', 'testfiles/blah.mp3', 'testfiles/blah.mp3']

params = {
    'lang': 'en',
    'convert_to': 'mp3-mp4'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp4

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

AVI έως MP4

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'avi-mp4'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp4

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

WMV έως MP4

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'wmv-mp4'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp4

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MPEG έως MP4

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mpeg-mp4'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp4

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

Μετακίνηση σε MP4

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mov-mp4'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp4

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MPG σε MP4

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mpg-mp4'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp4

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

DIVX έως MP4

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'divx-mp4'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp4

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

WEBM έως MP4

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'webm-mp4'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp4

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

FLV σε MP4

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'flv-mp4'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp4

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

VOB έως MP4

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'vob-mp4'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp4

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

M4V έως MP4

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'm4v-mp4'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp4

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

AV1 έως MP4

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'av1-mp4'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp4

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MKV έως MP4

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.mp4', 'testfiles/blah.mp4', 'testfiles/blah.mp4']
params = {
    'lang': 'en',
    'convert_to': 'mkv-mp4'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp4

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

GIF σε MP4

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.gif', 'testfiles/blah.gif', 'testfiles/blah.gif']
params = {
    'lang': 'en',
    'convert_to': 'gif-mp4'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp4

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας

MP4 έως WEBP

import requests
import time
import shutil
import json


headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.webp', 'testfiles/blah.webp', 'testfiles/blah.webp']
params = {
    'lang': 'en',
    'convert_to': 'webp-mp4'
    }

api_url = 'https://api.mp4.to/v1/convert/'
results_url = 'https://api.mp4.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.mp4.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()

def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Θα επιστρέψει

/path/to/local/file_processed.mp4

Για να κάνετε πολλά απλά βάλτε περισσότερα αρχεία στη λίστα σας