代码之家  ›  专栏  ›  技术社区  ›  Jason Donegan

视频转换器使用电影。py项目建议

  •  0
  • Jason Donegan  · 技术社区  · 5 年前

    你好,我正在制作一个youtube视频下载程序和一个练习python语言的视频转换器。使用视频转换器,我试图将mp4文件转换为mp3文件。我希望用户无需打开文本编辑器即可输入指定路径。我的问题是这个。如果可能的话,我很难想出如何使用用户的输入转换文件。有人能帮我吗?

    以下是我目前掌握的代码:

    import moviepy.editor as mp 
    
    #ask the user for the location of the file
    loca = (input("Please input the location of the video file you wish to convert: "))
    
    # Insert Local Video File Path  
    clip = mp.VideoFileClip(r'loca') 
      
    # Insert Local Audio File Path 
    clip.audio.write_audiofile(r'loca')
    
    0 回复  |  直到 5 年前
        1
  •  0
  •   Timelessnesses    5 年前

    只需输入文件的扩展名
    如果你想象不出这是什么样子。

    import moviepy.editor as mp 
    
    #ask the user for the location of the file
    loca = (input("Please input the location of the video file you wish to convert: "))
    filename = input("File name. : ")
    # Insert Local Video File Path  
    clip = mp.VideoFileClip(loca) 
      
    # Insert Local Audio File Path 
    clip.audio.write_audiofile(filename)
    
    推荐文章