我有一个包含数千个flv文件的库,我需要将其转换为mp4。我试图使用ffmpeg这样做,但我遇到了一些问题。
主要:
1)我无法在不重新编码的情况下从FLV切换到MP4。如果我这样做,我会收到来自ffmpeg的消息"无法在流#0中找到编解码器flv1的标签,当前容器中不支持编解码器"
2)如果我重新编码视频,结果视频质量较低(我看到VLC中的伪像)和更大。例如,一个视频从2.5MB变为4.3MB(几乎是大小的两倍)
鉴于第二,你可能会问自己 - 为什么转换呢?
答案是我需要将这些流式传输到移动设备(手机/平板电脑等),并且不支持flv。所以我需要转换文件,但我不能容忍超过最小的质量变化,最好是零到不增加大小。
这是我正在运行的ffmpeg命令:
ffmpeg -i $_.FullName -movflags faststart -profile:v baseline -level 3.0 "$($_.BaseName).mp4"
(请注意,我从powershell运行ffmpeg所以:
$_.FullName = the original file name
"$($_.BaseName).mp4" = the original file name with mp4 extension)
任何FFMPEG大师都可以帮助我理解我做错了什么吗?是否有一些参数我可以使用这些参数来减少质量和类似尺寸?
注意我还试过" -c:v libx264 -preset veryslow -crf 23 -c:副本"。使用礼物" veryslow"没有任何明显的差异。
更新 我使用以下选项:
ffmpeg -i $_.FullName -c:v libx264 -preset veryslow -crf 19 -c:a copy "$($_.BaseName).mp4"
这里有完整的输出:
ffmpeg version 2.8.4 Copyright (c) 2000-2015 the FFmpeg developers built with gcc 5.2.0 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfi g --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca -- enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libm p3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --en able-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --ena ble-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enabl e-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib libavutil 54. 31.100 / 54. 31.100 libavcodec 56. 60.100 / 56. 60.100 libavformat 56. 40.101 / 56. 40.101 libavdevice 56. 4.100 / 56. 4.100 libavfilter 5. 40.101 / 5. 40.101 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 2.101 / 1. 2.101 libpostproc 53. 3.100 / 53. 3.100 Input #0, flv, from 'C:\Users\brad\Desktop\ffmpeg\Originals\1019800-1278575542468.flv': Metadata: canSeekToEnd : false createdby : FMS 3.5 creationdate : Thu Jul 08 03:52:25 2010 Duration: 00:00:56.94, start: 0.000000, bitrate: 360 kb/s Stream #0:0: Video: flv1, yuv420p, 320x240, 1k tbr, 1k tbn, 1k tbc [libx264 @ 02cf7300] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 [libx264 @ 02cf7300] profile High, level 4.2 [libx264 @ 02cf7300] 264 - core 148 r2638 7599210 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.or g/x264.html - options: cabac=1 ref=16 deblock=1:0:0 analyse=0x3:0x133 me=umh subme=10 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=24 chroma_me=1 trellis=2 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=7 lookahead_th reads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=8 b_pyramid=2 b_adapt= 2 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=60 rc=crf mbtree=1 crf=19.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00 Output #0, mp4, to '1019800-1278575542468.mp4': Metadata: canSeekToEnd : false createdby : FMS 3.5 creationdate : Thu Jul 08 03:52:25 2010 encoder : Lavf56.40.101 Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 320x240, q=-1--1, 1k fps, 16k tbn, 1k tbc Metadata: encoder : Lavc56.60.100 libx264 Stream mapping: Stream #0:0 -> #0:0 (flv1 (flv) -> h264 (libx264)) Press [q] to stop, [?] for help frame=57117 fps=199 q=-1.0 Lsize= 5611kB time=00:00:57.11 bitrate= 804.8kbits/s dup=56685 drop=0 video:5184kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 8.229259% [libx264 @ 02cf7300] frame I:230 Avg QP:15.92 size: 8828 [libx264 @ 02cf7300] frame P:6399 Avg QP:17.19 size: 385 [libx264 @ 02cf7300] frame B:50488 Avg QP:27.13 size: 16 [libx264 @ 02cf7300] consecutive B-frames: 0.4% 0.0% 0.0% 0.0% 0.0% 2.3% 0.0% 0.0% 97.2% [libx264 @ 02cf7300] mb I I16..4: 2.9% 92.6% 4.5% [libx264 @ 02cf7300] mb P I16..4: 0.1% 2.0% 0.2% P16..4: 2.4% 1.2% 1.1% 0.1% 0.0% skip:92.9% [libx264 @ 02cf7300] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 2.6% 0.0% 0.0% direct: 0.0% skip:97.3% L0:45.0% L1:5 4.9% BI: 0.0% [libx264 @ 02cf7300] 8x8 transform intra:90.7% inter:76.5% [libx264 @ 02cf7300] direct mvs spatial:75.2% temporal:24.8% [libx264 @ 02cf7300] coded y,uvDC,uvAC intra: 94.4% 96.8% 64.8% inter: 0.3% 0.4% 0.1% [libx264 @ 02cf7300] i16 v,h,dc,p: 16% 25% 18% 41% [libx264 @ 02cf7300] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 28% 30% 4% 3% 3% 4% 4% 5% [libx264 @ 02cf7300] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 22% 9% 11% 8% 7% 10% 8% 7% [libx264 @ 02cf7300] i8c dc,h,v,p: 30% 34% 23% 13% [libx264 @ 02cf7300] Weighted P-Frames: Y:0.1% UV:0.1% [libx264 @ 02cf7300] ref P L0: 74.1% 19.7% 4.5% 0.6% 0.1% 0.2% 0.0% 0.1% 0.0% 0.1% 0.0% 0.2% 0.0% 0.2% 0.0% 0.1% [libx264 @ 02cf7300] ref B L0: 95.5% 1.6% 0.7% 0.5% 0.4% 0.3% 0.3% 0.2% 0.1% 0.1% 0.1% 0.1% 0.1% 0.0% 0.0% [libx264 @ 02cf7300] ref B L1: 84.5% 15.5% [libx264 @ 02cf7300] kb/s:743.46
Original Video Size: 2.44 MB
New Video Size: 5.6 MB