![将 mkv 转换为 ogv](https://linux22.com/image/863735/%E5%B0%86%20mkv%20%E8%BD%AC%E6%8D%A2%E4%B8%BA%20ogv.png)
如何将 mkv 文件(包含多个音轨)转换为 ogv 格式并保留所有音轨?
是否可以创建具有多条音轨的 ogg 文件(音频)?
答案1
在 Linux 中,您有一个通用媒体转换程序,称为avconv
(或ffmpeg
)。它的基本形式由扩展控制,因此
avconv -i input.mkv output.ogm
将进行适当的转换。
但是,要保留所有流,您需要使用-map
选项。我仅引用手册:
-map [-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]] | [linklabel] (output)
Designate one or more input streams as a source for the output file. Each input stream is identified by the input file index input_file_id and
the input stream index input_stream_id within the input file. Both indices start at 0. If specified, sync_file_id:stream_specifier sets which
input stream is used as a presentation sync reference.
The first "-map" option on the command line specifies the source for output stream 0, the second "-map" option specifies the source for output
stream 1, etc.
A "-" character before the stream identifier creates a "negative" mapping. It disables matching streams from already created mappings.
An alternative [linklabel] form will map outputs from complex filter graphs (see the -filter_complex option) to the output file. linklabel
must correspond to a defined output link label in the graph.
For example, to map ALL streams from the first input file to output
avconv -i INPUT -map 0 output
For example, if you have two audio streams in the first input file, these streams are identified by "0:0" and "0:1". You can use "-map" to
select which streams to place in an output file. For example:
avconv -i INPUT -map 0:1 out.wav
will map the input stream in INPUT identified by "0:1" to the (single) output stream in out.wav.
For example, to select the stream with index 2 from input file a.mov (specified by the identifier "0:2"), and stream with index 6 from input
b.mov (specified by the identifier "1:6"), and copy them to the output file out.mov:
avconv -i a.mov -i b.mov -c copy -map 0:2 -map 1:6 out.mov
To select all video and the third audio stream from an input file:
avconv -i INPUT -map 0:v -map 0:a:2 OUTPUT
To map all the streams except the second audio, use negative mappings
avconv -i INPUT -map 0 -map -0:a:1 OUTPUT
Note that using this option disables the default mappings for this output file.
因此你需要这个:
avconv -i nput.mkv -map 0:v -map 0:a output.ogm
是的,您可以在 OGG 文件中存储多个音轨,甚至视频和文本,因为它是一个通用媒体容器。
答案2
您可以使用媒体转换器并在转换模式下将 ogg 或 ogv 扩展名放入输出文件(如 audio.ogg)。此外,取消选中视频流上的“启用”,它仅是音频。您可以复制流如果他们被这个容器接受. h264/h265/vp8/vp9 不被 ogg 接受。
答案3
- 首先使用ffmpeg识别音频流编码。
- 然后使用 ffmpeg 提取音频流(原始编码)。
然后,如果你真的想要,你可以将其重新编码为 ogg。但保留原始音频编码可能最有用。
首先使用ffmpeg识别音频流编码。
$ ffmpeg -i $f Stream #0:0(und): Video: h264 (Main), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, s16 (default)
然后使用 ffmpeg 提取音频流(原始编码为 .mka 格式)。
ffmpeg -i song.mkv -acodec: copy -vn song.mka
我发现这很有用:
http://www.hecticgeek.com/2012/12/extract-audio-using-ffmpeg-ubuntu/
这是一个非常好的建议:
注意:如果您有疑问(不知道要使用什么扩展名),那么您可以简单地使用“.mka”扩展名(“output.mka”)。因为“MKA”容器格式可以存储大量音频编解码器。但是,如果您选择它,那么某些播放器可能无法播放音轨。所以请注意这一点。
将任何 mmv 和 mp4 转换为 mka 音频(保留原始音频编码)的有用脚本:convert_vtoa.sh
#!/bin/bash
for f in *.mkv *.mp4; do
# ffmpeg -i $f
bn=${f%%-[A-Za-z0-9]*}
echo -n bn=$bn
if [[ ! -e "$bn.mka" ]] ; then
echo ffmpeg -i "$f" -acodec: copy -vn "$bn.mka"
ffmpeg -i "$f" -acodec: copy -vn "$bn.mka"
else
echo " ##### already done. #####"
fi
done