![如何使用 ffmpeg 命令将 mp4 文件转换为带有音频编解码器 ac3 的 mpg](https://linux22.com/image/1405625/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%20ffmpeg%20%E5%91%BD%E4%BB%A4%E5%B0%86%20mp4%20%E6%96%87%E4%BB%B6%E8%BD%AC%E6%8D%A2%E4%B8%BA%E5%B8%A6%E6%9C%89%E9%9F%B3%E9%A2%91%E7%BC%96%E8%A7%A3%E7%A0%81%E5%99%A8%20ac3%20%E7%9A%84%20mpg.png)
我有一个 mp4 文件,我想用 ac3 音频编解码器将其转换为 mpg。
我试过:
ffmpeg -i input.mp4 -c:a ac3 output.mpg
命令输出:
bash$ ffmpeg -i input.mp4 -c:a ac3 output.mpg
ffmpeg version 2.1.3 Copyright (c) 2000-2013 the FFmpeg developers
built on Jan 15 2014 20:53:51 with gcc 4.8.2 (GCC) 20131219 (prerelease)
configuration: --prefix=/usr --disable-debug --disable-static --enable-avresample --enable-dxva2 --enable-fontconfig --enable-gnutls --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libv4l2 --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-pic --enable-postproc --enable-runtime-cpudetect --enable-shared --enable-swresample --enable-vdpau --enable-version3 --enable-x11grab
libavutil 52. 48.101 / 52. 48.101
libavcodec 55. 39.101 / 55. 39.101
libavformat 55. 19.104 / 55. 19.104
libavdevice 55. 5.100 / 55. 5.100
libavfilter 3. 90.100 / 3. 90.100
libavresample 1. 1. 0 / 1. 1. 0
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './input.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 1970-01-01 00:00:00
encoder : Lavf52.43.0
Duration: 00:08:41.86, start: 0.000000, bitrate: 437 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 512x272 [SAR 215:213 DAR 6880:3621], 358 kb/s, SAR 129:128 DAR 129:68, 23.98 fps, 23.98 tbr, 2997 tbn, 47.95 tbc (default)
Metadata:
creation_time : 1970-01-01 00:00:00
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 22050 Hz, stereo, fltp, 75 kb/s (default)
Metadata:
creation_time : 1970-01-01 00:00:00
handler_name : SoundHandler
[mpeg @ 0x9361f60] VBV buffer size not set, muxing may fail
Output #0, mpeg, to './output.mpg':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf55.19.104
Stream #0:0(und): Video: mpeg1video, yuv420p, 512x272 [SAR 129:128 DAR 129:68], q=2-31, 200 kb/s, 90k tbn, 23.98 tbc (default)
Metadata:
creation_time : 1970-01-01 00:00:00
handler_name : VideoHandler
Stream #0:1(und): Audio: ac3, 22050 Hz, stereo, fltp, 192 kb/s (default)
Metadata:
creation_time : 1970-01-01 00:00:00
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> mpeg1video)
Stream #0:1 -> #0:1 (aac -> ac3)
Press [q] to stop, [?] for help
frame=12170 fps=343 q=21.2 size= 24850kB time=00:08:27.57 bitrate= 401.1kbits/s
命令运行没有任何错误。但打开文件时没有音频。它只显示视频。但 mp4 文件可以播放音频和视频。
在转换为 ac3 音频编解码器时我遗漏了什么吗?
bash$ mplayer output.mpg
MPlayer SVN-r36498-snapshot-4.8.2 (C) 2000-2013 MPlayer Team
206 audio & 433 video codecs
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.
Playing output.mpg.
libavformat version 55.19.104 (internal)
MPEG-PS file format detected.
MPEG: No audio stream found -> no sound.
VIDEO: MPEG1 512x272 (aspect 1) 23.976 fps 0.0 kbps ( 0.0 kbyte/s)
Load subtitles in ./
Opening video filter: [expand osd=1 aspect=16/9 round=16]
Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 1.777778, round: 16
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
libavcodec version 55.39.100 (internal)
Selected video codec: [ffmpeg1] vfm: ffmpeg (FFmpeg MPEG-1)
==========================================================================
Audio: no sound
Starting playback...
[VD_FFMPEG] Trying pixfmt=0.
[VD_FFMPEG] XVMC-accelerated MPEG-2.
The selected video_out device is incompatible with this codec.
Try appending the scale filter to your filter list,
e.g. -vf spp,scale instead of -vf spp.
[VD_FFMPEG] Trying pixfmt=1.
[VD_FFMPEG] XVMC-accelerated MPEG-2.
The selected video_out device is incompatible with this codec.
Try appending the scale filter to your filter list,
e.g. -vf spp,scale instead of -vf spp.
[VD_FFMPEG] Trying pixfmt=3.
[VD_FFMPEG] XVMC-accelerated MPEG-2.
The selected video_out device is incompatible with this codec.
Try appending the scale filter to your filter list,
e.g. -vf spp,scale instead of -vf spp.
Movie-Aspect is 1.88:1 - prescaling to correct movie aspect.
VO: [xv] 512x288 => 512x288 Planar YV12
New_Face failed. Maybe the font path is wrong.
Please supply the text font file (~/.mplayer/subfont.ttf).
subtitle font: load_sub_face failed.
New_Face failed. Maybe the font path is wrong.
Please supply the text font file (~/.mplayer/subfont.ttf).
subtitle font: load_sub_face failed.
[mpeg1video @ 0xb75a8d20]ac-tex damaged at 12 0
[mpeg1video @ 0xb75a8d20]Warning MVs not available
[mpeg1video @ 0xb75a8d20]concealing 544 DC, 544 AC, 544 MV errors in I frame