FFmpeg 错误地渲染面向纵向的 .mov 文件
FFmpeg render portrait oriented .mov files incorrectly
当我尝试使用以下命令将纵向 .mov 文件转换为 mp4 文件时
ffmpeg -i "2.mov" -s 720x404 -ac 2 -threads 0 -c:v libx264 -pix_fmt yuv420p -vprofile high -level 4.1 -preset medium -crf 25 -maxrate:v 1000k -b:a 128k "r5.mp4"
创建的 mp4 文件看起来横向拉伸
就像在这个例子中一样。无法粘贴 .mov 或 .mp4 文件,但问题很明显。
运行 获取正常未拉伸文件的正确命令是什么?
完整日志:
C:\ffmpeg> .\ffmpeg -i "1.mov" -s 720x404 -ac 2 -threads 0 -c:v libx264 -pix_fmt yuv420p -vprofile high -level 4.1 -preset medium -crf 25 -maxrate:v 1000k -b:a 128k "r7.mp4"
ffmpeg version N-79906-gc8c14d0 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.3.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmfx --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
libavutil 55. 24.100 / 55. 24.100
libavcodec 57. 40.100 / 57. 40.100
libavformat 57. 36.100 / 57. 36.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 45.100 / 6. 45.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.mov':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2019-12-30 14:54:06
com.apple.quicktime.make: Apple
com.apple.quicktime.model: iPhone XR
com.apple.quicktime.software: 13.1.2
com.apple.quicktime.creationdate: 2019-12-30T08:54:06-0600
Duration: 00:00:09.11, start: 0.000000, bitrate: 15792 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 15543 kb/s, 29.97 fps, 29.97 tbr, 600 tbn (default)
Metadata:
rotate : 90
creation_time : 2019-12-30 14:54:06
handler_name : Core Media Data Handler
encoder : H.264
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 195 kb/s (default)
Metadata:
creation_time : 2019-12-30 14:54:06
handler_name : Core Media Data Handler
Stream #0:2(und): Data: none (mebx / 0x7862656D), 20 kb/s (default)
Metadata:
creation_time : 2019-12-30 14:54:06
handler_name : Core Media Data Handler
Stream #0:3(und): Data: none (mebx / 0x7862656D), 0 kb/s (default)
Metadata:
creation_time : 2019-12-30 14:54:06
handler_name : Core Media Data Handler
Stream #0:4(und): Data: none (mebx / 0x7862656D), 23 kb/s (default)
Metadata:
creation_time : 2019-12-30 14:54:06
handler_name : Core Media Data Handler
[libx264 @ 0569cc00] VBV maxrate specified, but no bufsize, ignored
[libx264 @ 0569cc00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0569cc00] profile High, level 4.1
[libx264 @ 0569cc00] 264 - core 148 r2694 3b70645 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=25.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[mp4 @ 055f0460] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Last message repeated 1 times
Output #0, mp4, to 'r7.mp4':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
com.apple.quicktime.creationdate: 2019-12-30T08:54:06-0600
com.apple.quicktime.make: Apple
com.apple.quicktime.model: iPhone XR
com.apple.quicktime.software: 13.1.2
encoder : Lavf57.36.100
Stream #0:0(und): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 720x404, q=2-31, 29.97 fps, 30k tbn (default)
Metadata:
handler_name : Core Media Data Handler
creation_time : 2019-12-30 14:54:06
encoder : Lavc57.40.100 libx264
Side data:
cpb: bitrate max/min/avg: 1000000/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1(und): Audio: aac (LC) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2019-12-30 14:54:06
handler_name : Core Media Data Handler
encoder : Lavc57.40.100 aac
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
frame= 273 fps= 43 q=-1.0 Lsize= 973kB time=00:00:09.17 bitrate= 869.4kbits/s speed=1.45x
video:817kB audio:145kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.136555%
[libx264 @ 0569cc00] frame I:2 Avg QP:26.36 size: 19820
[libx264 @ 0569cc00] frame P:69 Avg QP:26.68 size: 7276
[libx264 @ 0569cc00] frame B:202 Avg QP:30.73 size: 1459
[libx264 @ 0569cc00] consecutive B-frames: 1.1% 0.7% 0.0% 98.2%
[libx264 @ 0569cc00] mb I I16..4: 6.9% 60.8% 32.3%
[libx264 @ 0569cc00] mb P I16..4: 1.5% 6.2% 2.2% P16..4: 48.0% 20.5% 8.1% 0.0% 0.0% skip:13.5%
[libx264 @ 0569cc00] mb B I16..4: 0.1% 0.2% 0.1% B16..8: 46.6% 4.8% 0.7% direct: 0.9% skip:46.6% L0:40.1% L1:53.0% BI: 6.9%
[libx264 @ 0569cc00] 8x8 transform intra:62.7% inter:75.7%
[libx264 @ 0569cc00] coded y,uvDC,uvAC intra: 68.9% 61.3% 22.1% inter: 13.2% 11.1% 0.7%
[libx264 @ 0569cc00] i16 v,h,dc,p: 6% 52% 6% 36%
[libx264 @ 0569cc00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 11% 33% 13% 4% 6% 3% 15% 4% 12%
[libx264 @ 0569cc00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 17% 38% 12% 3% 5% 3% 12% 2% 8%
[libx264 @ 0569cc00] i8c dc,h,v,p: 48% 39% 9% 4%
[libx264 @ 0569cc00] Weighted P-Frames: Y:8.7% UV:7.2%
[libx264 @ 0569cc00] ref P L0: 57.7% 25.2% 12.1% 4.8% 0.2%
[libx264 @ 0569cc00] ref B L0: 94.9% 3.7% 1.4%
[libx264 @ 0569cc00] ref B L1: 97.6% 2.4%
[libx264 @ 0569cc00] kb/s:734.59
[aac @ 0569abc0] Qavg: 1236.647
使用 scale filter 而不是 -s
来保持宽高比:
ffmpeg -i input.mov -c:v libx264 -vf "scale=720:-2,format=yuv420p" -c:a copy -movflags +faststart output.mp4
此外,您的 ffmpeg
是旧版本:download 新版本。
当我尝试使用以下命令将纵向 .mov 文件转换为 mp4 文件时
ffmpeg -i "2.mov" -s 720x404 -ac 2 -threads 0 -c:v libx264 -pix_fmt yuv420p -vprofile high -level 4.1 -preset medium -crf 25 -maxrate:v 1000k -b:a 128k "r5.mp4"
创建的 mp4 文件看起来横向拉伸 就像在这个例子中一样。无法粘贴 .mov 或 .mp4 文件,但问题很明显。 运行 获取正常未拉伸文件的正确命令是什么?
完整日志:
C:\ffmpeg> .\ffmpeg -i "1.mov" -s 720x404 -ac 2 -threads 0 -c:v libx264 -pix_fmt yuv420p -vprofile high -level 4.1 -preset medium -crf 25 -maxrate:v 1000k -b:a 128k "r7.mp4"
ffmpeg version N-79906-gc8c14d0 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.3.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmfx --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
libavutil 55. 24.100 / 55. 24.100
libavcodec 57. 40.100 / 57. 40.100
libavformat 57. 36.100 / 57. 36.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 45.100 / 6. 45.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.mov':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2019-12-30 14:54:06
com.apple.quicktime.make: Apple
com.apple.quicktime.model: iPhone XR
com.apple.quicktime.software: 13.1.2
com.apple.quicktime.creationdate: 2019-12-30T08:54:06-0600
Duration: 00:00:09.11, start: 0.000000, bitrate: 15792 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 15543 kb/s, 29.97 fps, 29.97 tbr, 600 tbn (default)
Metadata:
rotate : 90
creation_time : 2019-12-30 14:54:06
handler_name : Core Media Data Handler
encoder : H.264
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 195 kb/s (default)
Metadata:
creation_time : 2019-12-30 14:54:06
handler_name : Core Media Data Handler
Stream #0:2(und): Data: none (mebx / 0x7862656D), 20 kb/s (default)
Metadata:
creation_time : 2019-12-30 14:54:06
handler_name : Core Media Data Handler
Stream #0:3(und): Data: none (mebx / 0x7862656D), 0 kb/s (default)
Metadata:
creation_time : 2019-12-30 14:54:06
handler_name : Core Media Data Handler
Stream #0:4(und): Data: none (mebx / 0x7862656D), 23 kb/s (default)
Metadata:
creation_time : 2019-12-30 14:54:06
handler_name : Core Media Data Handler
[libx264 @ 0569cc00] VBV maxrate specified, but no bufsize, ignored
[libx264 @ 0569cc00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0569cc00] profile High, level 4.1
[libx264 @ 0569cc00] 264 - core 148 r2694 3b70645 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=25.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[mp4 @ 055f0460] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Last message repeated 1 times
Output #0, mp4, to 'r7.mp4':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
com.apple.quicktime.creationdate: 2019-12-30T08:54:06-0600
com.apple.quicktime.make: Apple
com.apple.quicktime.model: iPhone XR
com.apple.quicktime.software: 13.1.2
encoder : Lavf57.36.100
Stream #0:0(und): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 720x404, q=2-31, 29.97 fps, 30k tbn (default)
Metadata:
handler_name : Core Media Data Handler
creation_time : 2019-12-30 14:54:06
encoder : Lavc57.40.100 libx264
Side data:
cpb: bitrate max/min/avg: 1000000/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1(und): Audio: aac (LC) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2019-12-30 14:54:06
handler_name : Core Media Data Handler
encoder : Lavc57.40.100 aac
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
frame= 273 fps= 43 q=-1.0 Lsize= 973kB time=00:00:09.17 bitrate= 869.4kbits/s speed=1.45x
video:817kB audio:145kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.136555%
[libx264 @ 0569cc00] frame I:2 Avg QP:26.36 size: 19820
[libx264 @ 0569cc00] frame P:69 Avg QP:26.68 size: 7276
[libx264 @ 0569cc00] frame B:202 Avg QP:30.73 size: 1459
[libx264 @ 0569cc00] consecutive B-frames: 1.1% 0.7% 0.0% 98.2%
[libx264 @ 0569cc00] mb I I16..4: 6.9% 60.8% 32.3%
[libx264 @ 0569cc00] mb P I16..4: 1.5% 6.2% 2.2% P16..4: 48.0% 20.5% 8.1% 0.0% 0.0% skip:13.5%
[libx264 @ 0569cc00] mb B I16..4: 0.1% 0.2% 0.1% B16..8: 46.6% 4.8% 0.7% direct: 0.9% skip:46.6% L0:40.1% L1:53.0% BI: 6.9%
[libx264 @ 0569cc00] 8x8 transform intra:62.7% inter:75.7%
[libx264 @ 0569cc00] coded y,uvDC,uvAC intra: 68.9% 61.3% 22.1% inter: 13.2% 11.1% 0.7%
[libx264 @ 0569cc00] i16 v,h,dc,p: 6% 52% 6% 36%
[libx264 @ 0569cc00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 11% 33% 13% 4% 6% 3% 15% 4% 12%
[libx264 @ 0569cc00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 17% 38% 12% 3% 5% 3% 12% 2% 8%
[libx264 @ 0569cc00] i8c dc,h,v,p: 48% 39% 9% 4%
[libx264 @ 0569cc00] Weighted P-Frames: Y:8.7% UV:7.2%
[libx264 @ 0569cc00] ref P L0: 57.7% 25.2% 12.1% 4.8% 0.2%
[libx264 @ 0569cc00] ref B L0: 94.9% 3.7% 1.4%
[libx264 @ 0569cc00] ref B L1: 97.6% 2.4%
[libx264 @ 0569cc00] kb/s:734.59
[aac @ 0569abc0] Qavg: 1236.647
使用 scale filter 而不是 -s
来保持宽高比:
ffmpeg -i input.mov -c:v libx264 -vf "scale=720:-2,format=yuv420p" -c:a copy -movflags +faststart output.mp4
此外,您的 ffmpeg
是旧版本:download 新版本。