ffmpeg正在生成不同步的音频/视频文件 [英] ffmpeg is generating an out-of-sync audio/video file

查看:76
本文介绍了ffmpeg正在生成不同步的音频/视频文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 a264 flv 视频转换为 mp4 ,但是结果视频的音频/视频不同步.音频似乎还可以,但视频似乎很慢,因此与音频不同步.

I am trying to convert a flv video to mp4 using a264, but the result video has a out of sync audio/video. The audio seems ok but the video seems slow and therefore out of sync with the audio.

这是我正在运行的命令:

Here is the command I am running:

/opt/local/bin/ffmpeg -i complaint.flv -f mp4 -vcodec libx264 -acodec aac -copyts -strict experimental -fpre /opt/local/share/ffmpeg/libx264-lossless_slow.ffpreset -ab 44k -threads 0 -crf 23 complaint.mp4

输出:

Desktop  /opt/local/bin/ffmpeg -i complaint.flv -f mp4 -vcodec libx264 -acodec aac -copyts -strict experimental -fpre /opt/local/share/ffmpeg/libx264-lossless_slow.ffpreset -ab 44k -threads 0 -crf 23 complaint.mp4
ffmpeg version 0.7.8, Copyright (c) 2000-2011 the FFmpeg developers
  built on Jan 12 2012 21:12:26 with gcc 4.2.1 (Apple Inc. build 5666) (dot 3)
  configuration: --prefix=/opt/local --enable-gpl --enable-postproc --enable-swscale --enable-avfilter --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libdirac --enable-libschroedinger --enable-libopenjpeg --enable-libxvid --enable-libx264 --enable-libvpx --enable-libspeex --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/gcc-4.2 --arch=x86_64 --enable-yasm
  libavutil    50. 43. 0 / 50. 43. 0
  libavcodec   52.123. 0 / 52.123. 0
  libavformat  52.111. 0 / 52.111. 0
  libavdevice  52.  5. 0 / 52.  5. 0
  libavfilter   1. 80. 0 /  1. 80. 0
  libswscale    0. 14. 1 /  0. 14. 1
  libpostproc  51.  2. 0 / 51.  2. 0
[flv @ 0x7fe57a04ac00] Estimating duration from bitrate, this may be inaccurate
Input #0, flv, from 'complaint.flv':
  Metadata:
    duration        : 7
    creationdate    : Thu Jan 12 23:47:24
    description     : Recorded using VideoRecording example.
  Duration: 00:00:06.61, start: 0.000000, bitrate: N/A
    Stream #0.0: Video: flv, yuv420p, 288x288, 1k tbr, 1k tbn, 1k tbc
    Stream #0.1: Audio: nellymoser, 11025 Hz, mono, s16
File 'complaint.mp4' already exists. Overwrite ? [y/N] y
[buffer @ 0x7fe579c32cc0] w:288 h:288 pixfmt:yuv420p tb:1/1000000 sar:0/1 sws_param:
[libx264 @ 0x7fe57a044600] using cpu capabilities: none!
[libx264 @ 0x7fe57a044600] profile High, level 4.2
[libx264 @ 0x7fe57a044600] 264 - core 118 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=1 ref=2 deblock=1:0:0 analyse=0x3:0x33 me=umh subme=6 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.41 aq=1:1.00
Output #0, mp4, to 'complaint.mp4':
  Metadata:
    duration        : 7
    creationdate    : Thu Jan 12 23:47:24
    description     : Recorded using VideoRecording example.
    encoder         : Lavf52.111.0
    Stream #0.0: Video: libx264, yuv420p, 288x288, q=0-69, 200 kb/s, 1k tbn, 1k tbc
    Stream #0.1: Audio: aac, 11025 Hz, mono, s16, 44 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #0.1 -> #0.1
Press [q] to stop, [?] for help
frame= 6557 fps=106 q=-1.0 Lsize=     685kB time=00:00:03.62 bitrate=1549.1kbits/s dup=6367 drop=0    
video:615kB audio:17kB global headers:0kB muxing overhead 8.361360%
frame I:27    Avg QP:19.98  size:  8242
[libx264 @ 0x7fe57a044600] frame P:6530  Avg QP:30.71  size:    62
[libx264 @ 0x7fe57a044600] mb I  I16..4: 11.1% 79.3%  9.6%
[libx264 @ 0x7fe57a044600] mb P  I16..4:  0.1%  0.2%  0.0%  P16..4:  1.2%  0.2%  0.3%  0.0%  0.0%    skip:98.0%
[libx264 @ 0x7fe57a044600] 8x8 transform intra:77.8% inter:64.9%
[libx264 @ 0x7fe57a044600] coded y,uvDC,uvAC intra: 75.3% 81.3% 33.3% inter: 0.5% 0.7% 0.1%
[libx264 @ 0x7fe57a044600] i16 v,h,dc,p: 78%  9% 10%  3%
[libx264 @ 0x7fe57a044600] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 35% 11% 32%  3%  4%  5%  2%  5%  4%
[libx264 @ 0x7fe57a044600] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 56%  7%  9%  3%  4%  7%  3%  7%  3%
[libx264 @ 0x7fe57a044600] i8c dc,h,v,p: 45% 15% 34%  6%
[libx264 @ 0x7fe57a044600] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x7fe57a044600] ref P L0: 80.5%  9.5% 10.0%
[libx264 @ 0x7fe57a044600] kb/s:767.20

我是否缺少某些东西来确保视频和音频完美对齐?

Is there something I'm missing to make sure the video and audio line up perfectly?

推荐答案

对于那些可能会尝试这样做的人,我最好立即在h264中录制闪存,而不是使用yuv420p进行音频编解码.那就像一个魅力.添加标志 -async 1 也有帮助.

For those who may be trying this, I was better of recording flash in h264 right away, instead of using yuv420p for audio codec. That worked like a charm. Adding the flag -async 1 also helped.

更新:从ffmpeg文档( http://ffmpeg.org/ffmpeg.html ):

Update: Check out this bit from the ffmpeg documentation (http://ffmpeg.org/ffmpeg.html):

-异步:音频同步方法.拉伸/压缩"音频流以匹配时间戳,该参数是每秒更改音频的最大样本数.-async 1是一种特殊情况,其中仅对音频流的开始进行校正,而无需进行任何后续的校正.该选项已被弃用.请改用aresample音频过滤器.

-async: Audio sync method. "Stretches/squeezes" the audio stream to match the timestamps, the parameter is the maximum samples per second by which the audio is changed. -async 1 is a special case where only the start of the audio stream is corrected without any later correction. This option has been deprecated. Use the aresample audio filter instead.

您可以在此处阅读有关aresample过滤器的信息: http://ffmpeg.org/trac/ffmpeg/wiki/FilteringGuide

You can read about the aresample filter here: http://ffmpeg.org/trac/ffmpeg/wiki/FilteringGuide

这篇关于ffmpeg正在生成不同步的音频/视频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆