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- ը ՇՊԱԿ-ին

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 to 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

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

MOV- ը 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

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում