YUV 到 mp4 转换
我正在使用命令:
ffmpeg -i MovieTest.yuv -vcodec libx264 -b 1200kb -b_strategy 1 -coder 1 -qmin 10 -qmax 51 -sc_threshold 40 -flags +loop -cmp +chroma -me_range 16 -me_method hex -subq 5 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4 -directpred 1 -flags2 +fastpskip -dts_delta_threshold 1 -acodec libfaac -ab 128kb output.mp4
用于 yuv 到 mp4 的转换。 这里 MovieTest.yuv 是我的输入文件,output.mp4 是我的输出文件。 我使用 h.264 编解码器(libx264)进行转换。
它可以正确转换我的大部分 yuv 文件。 但有时,转换会失败并在终端上出现错误:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'MovieTest.yuv':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
Duration: 00:00:06.45, start: 0.000000, bitrate: 109786 kb/s
Stream #0.0(und): Video: rawvideo, uyvy422, 640x480, 109675 kb/s, 22.31 fps, 27.25 tbr, 30k tbn, 30k tbc
Stream #0.1(und): Audio: aac, stereo, s16, 106 kb/s
[libx264 @ 0x12180da00]using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.1 Cache64
[libx264 @ 0x12180da00]profile High, level 3.0
[libx264 @ 0x12180da00]264 - core 98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2010 - http://www.videolan.org/x264.html - options: cabac=1 ref=6 deblock=1:0:0 analyse=0x3:0x133 me=umh 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=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 constrained_intra=0 bframes=0 weightp=0 keyint=12 keyint_min=7 scenecut=40 intra_refresh=0 rc_lookahead=12 rc=abr mbtree=1 bitrate=120 ratetol=33.3 qcomp=0.60 qpmin=10 qpmax=51 qpstep=4 ip_ratio=1.41 aq=1:1.00
[libfaac @ 0x12180e000]libfaac doesn't support this output format!
Output #0, mp4, to 'output.mp4':
Stream #0.0(und): Video: libx264, yuv420p, 640x480, q=10-51, 120 kb/s, 90k tbn, 27.25 tbc
Stream #0.1(und): Audio: libfaac, stereo, s16, 128 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Error while opening encoder for output stream #0.1 - maybe incorrect parameters such as bit_rate, rate, width or height
如果有人知道出了什么问题,请帮忙。
I am using the command:
ffmpeg -i MovieTest.yuv -vcodec libx264 -b 1200kb -b_strategy 1 -coder 1 -qmin 10 -qmax 51 -sc_threshold 40 -flags +loop -cmp +chroma -me_range 16 -me_method hex -subq 5 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4 -directpred 1 -flags2 +fastpskip -dts_delta_threshold 1 -acodec libfaac -ab 128kb output.mp4
for yuv to mp4 conversion.
Here MovieTest.yuv is my input file and output.mp4 is my output file.
And I am using h.264 codec (libx264) for conversion.
It converts my most of the yuv files properly.
But sometimes, the conversion fails with the error on terminal:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'MovieTest.yuv':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
Duration: 00:00:06.45, start: 0.000000, bitrate: 109786 kb/s
Stream #0.0(und): Video: rawvideo, uyvy422, 640x480, 109675 kb/s, 22.31 fps, 27.25 tbr, 30k tbn, 30k tbc
Stream #0.1(und): Audio: aac, stereo, s16, 106 kb/s
[libx264 @ 0x12180da00]using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.1 Cache64
[libx264 @ 0x12180da00]profile High, level 3.0
[libx264 @ 0x12180da00]264 - core 98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2010 - http://www.videolan.org/x264.html - options: cabac=1 ref=6 deblock=1:0:0 analyse=0x3:0x133 me=umh 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=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 constrained_intra=0 bframes=0 weightp=0 keyint=12 keyint_min=7 scenecut=40 intra_refresh=0 rc_lookahead=12 rc=abr mbtree=1 bitrate=120 ratetol=33.3 qcomp=0.60 qpmin=10 qpmax=51 qpstep=4 ip_ratio=1.41 aq=1:1.00
[libfaac @ 0x12180e000]libfaac doesn't support this output format!
Output #0, mp4, to 'output.mp4':
Stream #0.0(und): Video: libx264, yuv420p, 640x480, q=10-51, 120 kb/s, 90k tbn, 27.25 tbc
Stream #0.1(und): Audio: libfaac, stereo, s16, 128 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Error while opening encoder for output stream #0.1 - maybe incorrect parameters such as bit_rate, rate, width or height
If anybody has any idea, that what is going wrong, plz help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这是因为您的输出比特率(128kb)高于输入比特率(106 kb)。
我刚刚做了一个快速测试,当我将输出高于输入时,我的输出会失败,并出现与您相同的错误 - 当我再次降低它时,它会成功。
这可以解释为什么它只对某些输入失败。
如果您以某种方式编写脚本,则必须使用“ffmpeg -i”或类似 MediaInfo 首先分析您的输入源并进行相应调整。
I think it's because your output bit rate (128kb) is higher than your input bit rate (106 kb).
I've just done a quick test and when I put my output higher than my input mine fails with the same errors as yours - it succeeds when I lower it again.
This may explain why it only fails for some inputs.
If you're scripting this in some way you'll have to use either 'ffmpeg -i' or something like MediaInfo to analyse your input source first and adjust accordingly.