如何从视频文件中提取音轨并将其保存为 MP3?

Rob*_*ník 35 sound video mp3 extract

从视频文件中提取音轨并将其另存为 MP3 文件的最简单方法是什么?

小智 67

非常简单的 CLI 解决方案:

ffmpeg -i VIDEOFILE -acodec libmp3lame -metadata TITLE="Name of Song" OUTPUTFILE.mp3
Run Code Online (Sandbox Code Playgroud)

如果您没有安装 ffmpeg:

sudo apt-get install ffmpeg
Run Code Online (Sandbox Code Playgroud)

  • 如果 ffmpeg 说‘未知编码器‘libmp3lame’,请尝试‘sudo apt-get install libavcodec-extra-53’ (2认同)

jwe*_*rny 37

您可以在VLC 中执行此操作。

启动 VLC 后:

  1. 选择“媒体”-->“转换/保存”
  2. 单击“添加...”并选择您想要的文件
  3. 单击“转换/保存”(底部)
  4. 提供“目标文件:”
  5. 选择“配置文件”(即“音频 - MP3”、“音频 - Vorbis (OGG)”等)
  6. 点击“开始”
  7. 放松并享受您的鞋子

您可以从 Synaptic 或软件中心安装 VLC。


Rin*_*ind 11

avidemux可以做到这一点。

它位于 Ubuntu 软件中心内,或者您可以从命令行安装它:

sudo apt-get install avidemux
Run Code Online (Sandbox Code Playgroud)


小智 10

使用avconv(从命令行,不需要安装 ffmpeg,因为 avconv 是它到 ubuntu 的端口)

  1. 用于avconv -i "input file name"发现文件(视频和音频映射)。在下面显示的示例中,我想删除的音频的“索引”为 0:0。(如果你仔细阅读avconv -i ...命令的输出,你会得到这个。
  2. 然后发出命令 avconv -i "input file name" -map 0:0 -c:a copy -metadata TITLE="title name" -metadata AUTHOR="author name" "output file name"

使用几种输出文件格式对其进行测试并查看。


Liv*_*eBT 7

最好的方法是使用只处理容器的工具。对于 MP4,我会推荐gpac 包中MP4Box工具。对于像 Matroska 这样的其他容器,有像MKVToolNix这样的项目和工具。

检索有关文件的信息(注意:您也可以使用mediainfo):

$ MP4Box -info 29c3-5400-en-hacking_cisco_phones_h264.mp4 
* Movie Info *
    Timescale 1000 - Duration 00:54:30.144
    Fragmented File no - 2 track(s)
    File Brand isom - version 512
    Created: UNKNOWN DATE
File has no MPEG4 IOD/OD

iTunes Info:
    Name: Hacking Cisco Phones
    Artist: Ang Cui, Michael Costello
    Album: Chaos Communication Congress 2012 (29C3)
    Comment: http://events.ccc.de/congress/2012/Fahrplan/events/5400.en.html
    Genre: lecture
    Encoder Software: Lavf54.29.104

Track # 1 Info - TrackID 1 - TimeScale 25 - Duration 00:54:30.080
Media Info: Language "Undetermined" - Type "vide:avc1" - 81752 samples
Visual Track layout: x=0 y=0 width=1024 height=576
MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x21
AVC/H264 Video - Visual Size 720 x 576
    AVC Info: 1 SPS - 1 PPS - Profile Main @ Level 3
    NAL Unit length bits: 32
    Pixel Aspect Ratio 64:45 - Indicated track size 1024 x 576
Self-synchronized

Track # 2 Info - TrackID 2 - TimeScale 48000 - Duration 00:54:30.143
Media Info: Language "English" - Type "soun:mp4a" - 153285 samples
MPEG-4 Config: Audio Stream - ObjectTypeIndication 0x40
MPEG-4 Audio MPEG-4 Audio AAC LC - 2 Channel(s) - SampleRate 48000
Synchronized on stream 1
Alternate Group ID 1
Run Code Online (Sandbox Code Playgroud)

将单个轨道提取为原始格式:

$ MP4Box -raw 1 29c3-5400-en-hacking_cisco_phones_h264.mp4 
Extracting MPEG-4 AVC-H264 stream to h264
$ MP4Box -raw 2 29c3-5400-en-hacking_cisco_phones_h264.mp4 
Extracting MPEG-4 AAC
Run Code Online (Sandbox Code Playgroud)

显示原始文件和结果:

$ ls -1 29c3-5400-en-hacking_cisco_phones_h264*
29c3-5400-en-hacking_cisco_phones_h264.mp4
29c3-5400-en-hacking_cisco_phones_h264_track1.h264
29c3-5400-en-hacking_cisco_phones_h264_track2.aac
Run Code Online (Sandbox Code Playgroud)


小智 5

您想要转换哪种视频格式?我使用 audacity 从 mp4 和 flv 视频中提取音频(没有尝试过其他格式,但我认为它的工作原理是一样的)。当您打开文件时,视频部分将被忽略,而您将只处理音频(例如规范化或截断静音),然后将其导出为包括 mp3 在内的任何格式。