LoginSignup
0
0

More than 1 year has passed since last update.

ChatGPT:複数の動画ファイルをpythonで結合するプログラム(完動)

Posted at

ChatGPTでのプログラミング

課題

複数のmkvファイルを受け取り、python ffmpegを用いて、再エンコードなしで結合するpythonプログラムを作成してください。 mkvファイルはGUIで選択できるようにpysimpleguiを使ってファイルを選択できる仕様にしてください。

追加のお願い
subprocessは使わずpython-ffmpegというライブラリでお願い

import ffmpeg
import PySimpleGUI as sg

def merge_mkv_files(file_list):
    inputs = [ffmpeg.input(file) for file in file_list]
    output = ffmpeg.concat(*inputs)
    output = ffmpeg.output(output, 'output.mkv', vcodec="copy")
    ffmpeg.run(output)

def file_picker():
    layout = [
        [sg.Text('Select MKV Files to Merge:')],
        [sg.Input(), sg.FilesBrowse()],
        [sg.Submit(), sg.Cancel()]
    ]
    window = sg.Window('MKV Merge', layout)

    event, values = window.Read()
    window.Close()

    if event == 'Submit':
        file_list = values[0].split(';')
        merge_mkv_files(file_list)

if __name__ == '__main__':
    file_picker()

結果

再エンコードなしでという指定は無視されたものの、結合プログラムは完璧にできた

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0