1
def cut_file(file, start_time, end_time):
""" Cut the mp3 file with start and end time. """
output = file[:-4] + "_cut.mp3"
try:
os.remove(output)
except Exception:
pass
p=Popen(["ffmpeg", "-i", file, "-c:a copy -ss", start_time, "-to", end_time, output], stdout=PIPE)
p.communicate()
os.remove(file)
os.rename(output,file)
return file
この機能を使用してmp3ファイルをカットすると、ffmpegからエラーが発生します。エラーは次のとおりです。pythonでmp3をカットするためにffmpegを使用する - コーデックコピーエラー
不明エンコーダのPythonを使用しているとき「0時07分」
なぜコピーコマンドを認識しffmpegのではないでしょうか?シェルでコマンドを実行してもエラーは発生しません。
私は引数の順序を変更しようとしましたが、これは私に同じ種類のエラーを与えます。
I got the code out of the official documentation.