我正在尝试从mkv文件中获得干净的h264视频。干净意味着我只有视频流和立体声。 输入文件可以具有多个通道和字幕以及其他未知内容,而我不需要。 我通过以下命令使用ffmpeg:
ffmpeg -i "input.mkv" -ac 2 -vf scale=trunc(oh*a/2)*2:480 -c:v libx264 "output.mp4"
这应该给我提供带有立体声的480p视频,这是我所需要的。 我尝试使用ffmpeg使用多个-map或dispositions命令删除字幕,但没有成功。
如何使用ffmpeg删除视频和立体声流以外的所有内容,并获得480p立体声视频?
编辑: ffmpeg的输出-“ input.mkv” -i“ output.mp4”:
ffmpeg -i "input.mkv" -i "output.mp4"
ffmpeg version N-91972-gbd10c1e9a8 Copyright (c) 2000-2018 the FFmpeg developer
built with gcc 8.2.1 (GCC) 20180813
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconf
g --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-li
freetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-am
wb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy -
enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-
ibwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 -
enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --e
able-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --e
able-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --
nable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --ena
le-avisynth
libavutil 56. 19.101 / 56. 19.101
libavcodec 58. 30.100 / 58. 30.100
libavformat 58. 18.101 / 58. 18.101
libavdevice 58. 4.103 / 58. 4.103
libavfilter 7. 32.100 / 7. 32.100
libswscale 5. 2.100 / 5. 2.100
libswresample 3. 2.100 / 3. 2.100
libpostproc 55. 2.100 / 55. 2.100
[hevc @ 00000000004a5940] Invalid default display window
Input #0, matroska,webm, from 'input.mkv':
Metadata:
title : Elysium (2013)
encoder : libebml v1.3.3 + libmatroska v1.4.4
creation_time : 2016-01-05T22:30:41.000000Z
Duration: 00:01:02.73, start: 0.166000, bitrate: 53638 kb/s
Chapter #0:0: start 0.000000, end 62.896000
Metadata:
title : 00:00:00.000
Stream #0:0(eng): Video: hevc (Main 10), yuv420p10le(tv), 3840x1606, SAR 1:
DAR 1920:803, 23.98 fps, 23.98 tbr, 1k tbn, 23.98 tbc (default)
Metadata:
title : Elysium (2013) - Release for ULTRAHDCLUB
BPS : 51036975
BPS-eng : 51036975
DURATION : 00:01:02.604000000
DURATION-eng : 00:01:02.604000000
NUMBER_OF_FRAMES: 1501
NUMBER_OF_FRAMES-eng: 1501
NUMBER_OF_BYTES : 399389852
NUMBER_OF_BYTES-eng: 399389852
_STATISTICS_WRITING_APP: mkvmerge v8.7.0 ('All of the above') 64bit
_STATISTICS_WRITING_APP-eng: mkvmerge v8.7.0 ('All of the above') 64bit
_STATISTICS_WRITING_DATE_UTC: 2016-01-05 22:30:41
_STATISTICS_WRITING_DATE_UTC-eng: 2016-01-05 22:30:41
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:1(eng): Audio: dts (DTS-HD MA), 48000 Hz, 7.1, s16p (default)
Metadata:
title : DTS-HD MA 7.1 - Blu-ray CEE
BPS : 2706639
BPS-eng : 2706639
DURATION : 00:01:02.561000000
DURATION-eng : 00:01:02.561000000
NUMBER_OF_FRAMES: 5865
NUMBER_OF_FRAMES-eng: 5865
NUMBER_OF_BYTES : 21166260
NUMBER_OF_BYTES-eng: 21166260
_STATISTICS_WRITING_APP: mkvmerge v8.7.0 ('All of the above') 64bit
_STATISTICS_WRITING_APP-eng: mkvmerge v8.7.0 ('All of the above') 64bit
_STATISTICS_WRITING_DATE_UTC: 2016-01-05 22:30:41
_STATISTICS_WRITING_DATE_UTC-eng: 2016-01-05 22:30:41
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
title : Elysium (2013)
encoder : Lavf58.18.101
Duration: 00:01:02.73, start: 0.000000, bitrate: 1671 kb/s
Chapter #1:0: start 0.000000, end 62.730000
Metadata:
title : 00:00:00.000
Stream #1:0(eng): Video: h264 (High 10) (avc1 / 0x31637661), yuv420p10le, 1
46x480 [SAR 2030:2027 DAR 38773:16216], 1543 kb/s, SAR 15563:15540 DAR 1920:803
23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #1:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fl
p, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream #1:2(eng): Data: bin_data (text / 0x74786574), 0 kb/s
Metadata:
handler_name : SubtitleHandler
At least one output file must be specified
答案 0 :(得分:0)
使用
ffmpeg -i "input.mkv" -sn -dn -vf scale=trunc(oh*a/2)*2:480 -c:v libx264 -ac 2 "output.mp4"
-sn
禁用字幕选择。
答案 1 :(得分:0)
我可以弄清楚: -map_metadata -1 做到了这一点。尽管视频仍无法与JavaFX Media Player一起使用
编辑: 使用
-profile:v high -level:v 4.0 -pix_fmt yuv420p
我终于得到了与JavaFX Media Player兼容的视频文件:)
答案 2 :(得分:0)
要删除字幕,请使用-map -0:s
选项(注意:s前面应减去“ -0”),如下所示:
-map 0:v -map 0:a -map -0:s
位于视频和音频编码选项的前面。
例如,仅使用第一视频和第一音频将MKV转码为MP4:
ffmpeg -y -i "input.mkv" -map 0:v:0 -map 0:a:0 -map -0:s -c copy "output.mp4"
如果要对所有视频和音频流进行编码而没有字幕:
ffmpeg -y -i "input.mkv" -map 0:v -map 0:a -map -0:s -c copy "output.mp4"