V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
zeayes
V2EX  ›  FFmpeg

[求助] ffmpeg 转码失败

  •  
  •   zeayes · 2014-09-14 10:06:03 +08:00 · 7424 次点击
    这是一个创建于 3813 天前的主题,其中的信息可能已经有所发展或是发生改变。
    日志太长,详细内容:
    ffmpeg -loglevel debug -report -i recordUnity3D.mov -acodec libfaac -b:a 128k -vcodec libx264 -b:v 1200k -r 24 -flags +aic+mv4 -pix_fmt yuv420p -threads 0 -y output.mp4
    ffmpeg started on 2014-09-13 at 23:11:04
    Report written to "ffmpeg-20140913-231104.log"
    ffmpeg version 2.3.2 Copyright (c) 2000-2014 the FFmpeg developers
    built on Aug 14 2014 07:21:22 with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
    configuration: --prefix=/usr/local/Cellar/ffmpeg/2.3.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
    libavutil 52. 92.100 / 52. 92.100
    libavcodec 55. 69.100 / 55. 69.100
    libavformat 55. 48.100 / 55. 48.100
    libavdevice 55. 13.102 / 55. 13.102
    libavfilter 4. 11.100 / 4. 11.100
    libavresample 1. 3. 0 / 1. 3. 0
    libswscale 2. 6.100 / 2. 6.100
    libswresample 0. 19.100 / 0. 19.100
    libpostproc 52. 3.100 / 52. 3.100
    Splitting the commandline.
    Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
    Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
    Reading option '-i' ... matched as input file with argument 'recordUnity3D.mov'.
    Reading option '-acodec' ... matched as option 'acodec' (force audio codec ('copy' to copy stream)) with argument 'libfaac'.
    Reading option '-b:a' ... matched as option 'b' (video bitrate (please use -b:v)) with argument '128k'.
    Reading option '-vcodec' ... matched as option 'vcodec' (force video codec ('copy' to copy stream)) with argument 'libx264'.
    Reading option '-b:v' ... matched as option 'b' (video bitrate (please use -b:v)) with argument '1200k'.
    Reading option '-r' ... matched as option 'r' (set frame rate (Hz value, fraction or abbreviation)) with argument '24'.
    Reading option '-flags' ... matched as AVOption 'flags' with argument '+aic+mv4'.
    Reading option '-pix_fmt' ... matched as option 'pix_fmt' (set pixel format) with argument 'yuv420p'.
    Reading option '-threads' ... matched as AVOption 'threads' with argument '0'.
    Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
    Reading option 'output.mp4' ... matched as output file.
    Finished splitting the commandline.
    Parsing a group of options: global .
    Applying option loglevel (set logging level) with argument debug.
    Applying option report (generate a report) with argument 1.
    Applying option y (overwrite output files) with argument 1.
    Successfully parsed a group of options.
    Parsing a group of options: input file recordUnity3D.mov.
    Successfully parsed a group of options.
    Opening an input file: recordUnity3D.mov.
    [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f9243018800] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
    [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f9243018800] ISO: File Type Major Brand: qt
    rfps: 29.916667 0.006601
    rfps: 29.916667 0.010607
    rfps: 30.000000 0.001906
    rfps: 30.083333 0.009568
    rfps: 59.916667 0.012483
    rfps: 60.000000 0.007623
    rfps: 60.000000 0.017827
    rfps: 29.970030 0.002172
    rfps: 29.970030 0.013362
    rfps: 59.940060 0.008686
    rfps: 59.940060 0.011075
    [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f9243018800] Before avformat_find_stream_info() pos: 3151401 bytes read:56656 seeks:1
    [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f9243018800] All info found
    [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f9243018800] After avformat_find_stream_info() pos: 48962 bytes read:122192 seeks:2 frames:49
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'recordUnity3D.mov':
    Metadata:
    major_brand : qt
    minor_version : 0
    compatible_brands: qt
    creation_time : 2014-09-12 08:16:31
    Duration: 00:00:29.08, start: 0.000998, bitrate: 867 kb/s
    Stream #0:0(und), 1, 1/600: Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1136x640, 1/1200, 805 kb/s, SAR -1:1 DAR -71:40, 29.85 fps, 30 tbr, 600 tbn, 1200 tbc (default)
    Metadata:
    rotate : -0
    creation_time : 2014-09-12 08:16:31
    handler_name : Core Media Data Handler
    encoder : H.264
    Side data:
    displaymatrix: rotation of 0.00 degrees
    Stream #0:1(und), 48, 1/44100: Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 63 kb/s (default)
    Metadata:
    creation_time : 2014-09-12 08:16:31
    handler_name : Core Media Data Handler
    Successfully opened the file.
    Parsing a group of options: output file output.mp4.
    Applying option acodec (force audio codec ('copy' to copy stream)) with argument libfaac.
    Applying option b:a (video bitrate (please use -b:v)) with argument 128k.
    Applying option vcodec (force video codec ('copy' to copy stream)) with argument libx264.
    Applying option b:v (video bitrate (please use -b:v)) with argument 1200k.
    Applying option r (set frame rate (Hz value, fraction or abbreviation)) with argument 24.
    Applying option pix_fmt (set pixel format) with argument yuv420p.
    Successfully parsed a group of options.
    Opening an output file: output.mp4.
    Successfully opened the file.
    detected 8 logical cores
    [graph 0 input from stream 0:0 @ 0x7f92427003a0] Setting 'video_size' to value '1136x640'
    [graph 0 input from stream 0:0 @ 0x7f92427003a0] Setting 'pix_fmt' to value '0'
    [graph 0 input from stream 0:0 @ 0x7f92427003a0] Setting 'time_base' to value '1/600'
    [graph 0 input from stream 0:0 @ 0x7f92427003a0] Setting 'pixel_aspect' to value '-1/1'
    [buffer @ 0x7f92427002a0] Value -1.000000 for parameter 'pixel_aspect' out of range [0 - 1.79769e+308]
    Last message repeated 1 times
    [graph 0 input from stream 0:0 @ 0x7f92427003a0] Setting 'sws_param' to value 'flags=2'
    [graph 0 input from stream 0:0 @ 0x7f92427003a0] Setting 'frame_rate' to value '30/1'
    [buffer @ 0x7f92427002a0] Value -1.000000 for parameter 'pixel_aspect' out of range [0 - 1.79769e+308]
    Last message repeated 1 times
    [buffer @ 0x7f92427002a0] Error setting option pixel_aspect to value -1/1.
    [graph 0 input from stream 0:0 @ 0x7f92427003a0] Error applying options to the filter.
    Error opening filters!
    [AVIOContext @ 0x7f9242602120] Statistics: 0 seeks, 0 writeouts
    [AVIOContext @ 0x7f9242501c20] Statistics: 122192 bytes read, 2 seeks
    ffprobe recordUnity3D(已转换).mov
    ffprobe version 2.3.2 Copyright (c) 2007-2014 the FFmpeg developers
    built on Aug 14 2014 07:21:22 with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
    configuration: --prefix=/usr/local/Cellar/ffmpeg/2.3.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
    libavutil 52. 92.100 / 52. 92.100
    libavcodec 55. 69.100 / 55. 69.100
    libavformat 55. 48.100 / 55. 48.100
    libavdevice 55. 13.102 / 55. 13.102
    libavfilter 4. 11.100 / 4. 11.100
    libavresample 1. 3. 0 / 1. 3. 0
    libswscale 2. 6.100 / 2. 6.100
    libswresample 0. 19.100 / 0. 19.100
    libpostproc 52. 3.100 / 52. 3.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'recordUnity3D(已转换).mov':
    Metadata:
    major_brand : qt
    minor_version : 0
    compatible_brands: qt
    creation_time : 2014-09-12 09:24:23
    encoder : Mac OS X v? (AVF 651.12.1, CM 1273.54, x86_64)
    encoder-eng : Mac OS X v? (AVF 651.12.1, CM 1273.54, x86_64)
    Duration: 00:00:29.08, start: 0.000000, bitrate: 2484 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 1136x640 [SAR 1:1 DAR 71:40], 2419 kb/s, 29.71 fps, 30 tbr, 600 tbn, 1200 tbc (default)
    Metadata:
    creation_time : 2014-09-12 09:24:23
    handler_name : Core Media Data Handler
    encoder : H.264
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 63 kb/s (default)
    Metadata:
    creation_time : 2014-09-12 09:24:23
    handler_name : Core Media Data Handler
    ffprobe recordUnity3D.mov
    ffprobe version 2.3.2 Copyright (c) 2007-2014 the FFmpeg developers
    built on Aug 14 2014 07:21:22 with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
    configuration: --prefix=/usr/local/Cellar/ffmpeg/2.3.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
    libavutil 52. 92.100 / 52. 92.100
    libavcodec 55. 69.100 / 55. 69.100
    libavformat 55. 48.100 / 55. 48.100
    libavdevice 55. 13.102 / 55. 13.102
    libavfilter 4. 11.100 / 4. 11.100
    libavresample 1. 3. 0 / 1. 3. 0
    libswscale 2. 6.100 / 2. 6.100
    libswresample 0. 19.100 / 0. 19.100
    libpostproc 52. 3.100 / 52. 3.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'recordUnity3D.mov':
    Metadata:
    major_brand : qt
    minor_version : 0
    compatible_brands: qt
    creation_time : 2014-09-12 08:16:31
    Duration: 00:00:29.08, start: 0.000998, bitrate: 867 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1136x640, 805 kb/s, SAR -1:1 DAR -71:40, 29.85 fps, 30 tbr, 600 tbn, 1200 tbc (default)
    Metadata:
    rotate : -0
    creation_time : 2014-09-12 08:16:31
    handler_name : Core Media Data Handler
    encoder : H.264
    Side data:
    displaymatrix: rotation of 0.00 degrees
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 63 kb/s (default)
    Metadata:
    creation_time : 2014-09-12 08:16:31
    handler_name : Core Media Data Handler


    原始视频: http://pan.baidu.com/s/1mgIBxgO

    目前情况是这样的:
    1、ffmpeg读取视频就失败了,用ffprobe查看视频信息,其中SAR -1:1 DAR -71:40,应该是这2个值有负数导致读取失败。
    2、用MPLAYER是可以直接播放的,QUICK TIME需要转码才能播放。
    3、MPLAYER播放的视频画面是倒的,QUICK TIME转码后是画面正常的。
    4、尝试过avconv和mencoder,都会转码失败。
    5、QUICK TIME转码后的视频信息中的encoder信息乱码了,用谷歌也没找到。。。

    是不是ffmpeg缺少MPLAYER和QUICK TIME解码视频的某个库?
    PS:MPLAYER是brew安装的,查看起FORMULA,编译选项没看到和视频解码相关的库?
    26 条回复    2014-10-18 01:17:19 +08:00
    icylord
        1
    icylord  
       2014-09-14 11:07:24 +08:00
    如果用 mplayerx 或者 movist 播放正常不
    DylanRing0
        2
    DylanRing0  
       2014-09-14 12:25:01 +08:00
    在Windows上用FFMS导入视频走x264转码OK
    AVS如下:
    LoadPlugin("D:\Program Files (x86)\PressTools\MeGUI_2418_x86\tools\ffms\ffms2.dll")
    FFVideoSource("D:\recordUnity3D.mov", fpsnum=29853, fpsden=1000, threads=1)
    Turn180()
    FlipHorizontal()
    输出视频(已用mmg合并音频):
    https://onedrive.live.com/redir?resid=D4FF896B9B126B5!478&authkey=!AFkla6JCqWJBBK8&ithint=file%2cmkv
    DylanRing0
        3
    DylanRing0  
       2014-09-14 12:28:03 +08:00
    在非Windows平台做这种事,还是开个Wine跑AVS用Windows的那套方法吧
    这里头坑太多,稍有不慎就被坑
    seki
        4
    seki  
       2014-09-14 13:13:14 +08:00 via Android
    谁写的负数的 sar 和 dar………

    用封装工具比如 mkvtoolnix 换成正的再去转码吧……
    zeayes
        5
    zeayes  
    OP
       2014-09-14 16:50:12 +08:00
    @DylanRing0 难道是差什么解码库?
    zeayes
        6
    zeayes  
    OP
       2014-09-14 16:51:03 +08:00
    @icylord QUICK TIME、MPLAYER和VLC都可以播放,就是FFMPEG转码失败。
    zeayes
        7
    zeayes  
    OP
       2014-09-14 16:51:42 +08:00
    @seki FFPROBE读到的负数。。。
    seki
        8
    seki  
       2014-09-14 17:24:36 +08:00
    @zeayes 所以是说一般人不会这么写负数的吧 - -
    你那边有 mediainfo 吗,它是怎么显示信息的?
    zeayes
        9
    zeayes  
    OP
       2014-09-14 20:30:08 +08:00
    @seki 你看下上面最后一个gist文件。
    msg7086
        10
    msg7086  
       2014-09-14 20:54:22 +08:00 via iPhone
    有没有手动指定sar/par的功能?
    seki
        11
    seki  
       2014-09-14 21:25:02 +08:00
    @zeayes 哦,看到了,自己试了一下的确 ffmpeg 无力,但是发现用 x264 (win32 jeeb 编译版)是能顺利视频转码的
    zeayes
        12
    zeayes  
    OP
       2014-09-14 22:02:41 +08:00
    @msg7086 ffmpeg读不了这个视频,设置不了sar/par。
    zeayes
        13
    zeayes  
    OP
       2014-09-14 22:03:21 +08:00
    @seki 我在OSX上编译里面加了x264库的。。。
    seki
        14
    seki  
       2014-09-14 22:09:09 +08:00
    @zeayes 我知道,我只是把我这边的情况告诉你。个人感觉并不是 libx264 不支持负数的 sar 和 dar
    ctexlive
        15
    ctexlive  
       2014-09-15 01:18:06 +08:00
    我觉得可以用mencoder解码,再用ffmpeg播放,或者干脆用mencoder编码。
    ctexlive
        16
    ctexlive  
       2014-09-15 01:18:30 +08:00
    我觉得可以用mencoder解码,再用ffmpeg编码,或者干脆用mencoder解编码。
    ctexlive
        17
    ctexlive  
       2014-09-15 05:58:19 +08:00   ❤️ 1
    ---------------方法
    mencoder -flip -ofps 29.853 -ovc x264 -ffourcc H264 -x264encopts bitrate=800:threads=auto -oac faac -faacopts br=64 -channels 2 -o temp.avi recordUnity3D.mov
    ffmpeg -i temp.avi -acodec copy -vn temp.aac
    ffmpeg -i temp.avi -vcodec copy -an temp.h264
    MP4Box temp.mp4 -add temp.h264 -fps 29.853 -add temp.aac
    ----------------
    zeayes
        18
    zeayes  
    OP
       2014-09-15 13:05:23 +08:00
    @ctexlive 早上在弄,弄好了整理一份文档,非常感谢!
    ctexlive
        19
    ctexlive  
       2014-09-15 14:42:33 +08:00
    -flip 是让你的视频翻转回来.你的视频本身就是倒的
    ctexlive
        20
    ctexlive  
       2014-09-15 14:51:47 +08:00
    mencoder只能导出avi,这个avi只有mplayer才能支持.必须音视频轨道分离后再封装成其他格式(mp4,mkv).
    选择ffmpeg分离是因为速度快且兼容性好. 不建议用mencoder和mplayer分离(有点兼容性问题).
    封装mp4最好用mp4box或者MP4cteater,最标准,兼容性好. (用ffmpeg和mencoder也能封装mp4,不推荐)

    注意为了保证音视频同步,一定要注意必须指定 帧率.(mencoder的 ofps 和 mp4box的 -fps).

    ps. 其实还有一个更方便的gui编码工具,https://handbrake.fr/ 专门制作mp4和mkv的视频. 编码速度相比mencoder稍微慢点点.
    zeayes
        21
    zeayes  
    OP
       2014-09-16 09:26:38 +08:00
    @ctexlive
    @seki
    @seki
    @seki
    @DylanRing0
    @icylord
    同事最后改的稍微修改了一下ffmpeg的源代码,简单地把这个问题处理了。
    ctexlive
        22
    ctexlive  
       2014-09-16 11:10:52 +08:00 via Android
    @zeayes 请问有patch吗?这个应该有用
    Akagi201
        23
    Akagi201  
       2014-10-07 20:04:38 +08:00
    @zeayes 怎么改的?
    zeayes
        24
    zeayes  
    OP
       2014-10-08 19:20:54 +08:00   ❤️ 1
    @Akagi201

    # libavutil/opt.c:188
    if (o->min > num && strcmp(o->name, "pixel_aspect") == 0) {
    num = abs(num);
    }
    keery
        25
    keery  
       2014-10-17 15:31:27 +08:00
    按你的方法可以把视频转换,但是转换后视频是倒着的,需要倒转,请问应该如何实现呢?
    zeayes
        26
    zeayes  
    OP
       2014-10-18 01:17:19 +08:00
    @keery

    -vf vflip
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5637 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 06:21 · PVG 14:21 · LAX 22:21 · JFK 01:21
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.