avconv以横向旋转输出每个视频,无论元数据或转置如何

时间:2017-01-26 15:42:12

标签: ubuntu video avconv

我正在尝试将.mov文件转换为.mp4,以便可以在任何设备上播放。我正在使用uconntu 14.04和avconv v0.20-6:9.20-0ubuntu0.14.04.1(建于2016年12月7日,gcc 4,8)。

如果我只是尝试:

avconv -i input.mov output.mp4

它转换为mp4很好,但如果视频是肖像,它会自动旋转到横向。如果视频是横向的,则不会旋转。我也尝试用我的Android设备拍摄的mp4视频,同样的事情发生了。这是MOV文件的原始元数据(获取元数据的命令是第一行):

avconv -i IMG_0022.MOV
avconv version 9.20-6:9.20-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers
  built on Dec  7 2016 21:22:31 with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1d5e240] Could not find codec parameters (Data: mebx / 0x7862656D, 0 kb/s)
    Last message repeated 1 times
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'IMG_0022.MOV':
  Metadata:
    major_brand     : qt
    minor_version   : 0
    compatible_brands: qt
    creation_time   : 2017-01-25 22:58:59
  Duration: 00:00:03.18, start: 0.000000, bitrate: 10705 kb/s
    Stream #0.0(und): Video: h264 (Baseline), yuv420p, 1280x720, 10823 kb/s, 24.01 fps, 24 tbr, 600 tbn
    Metadata:
      creation_time   : 2017-01-25 22:58:59
    Stream #0.1(und): Audio: aac, 44100 Hz, mono, fltp, 61 kb/s
    Metadata:
      creation_time   : 2017-01-25 22:58:59
    Stream #0.2(und): Data: mebx / 0x7862656D, 0 kb/s
    Metadata:
      creation_time   : 2017-01-25 22:58:59
    Stream #0.3(und): Data: mebx / 0x7862656D, 0 kb/s
    Metadata:
      creation_time   : 2017-01-25 22:58:59
At least one output file must be specified

我跑的时候

avconv -i IMG_0022.mov -strict -2 out.mp4

这就是我得到的:

avconv -i IMG_0022.MOV -strict -2 out.mp4
avconv version 9.20-6:9.20-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers
  built on Dec  7 2016 21:22:31 with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1fdab00] Could not find codec parameters (Data: mebx / 0x7862656D, 0 kb/s)
    Last message repeated 1 times
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'IMG_0022.MOV':
  Metadata:
    major_brand     : qt
    minor_version   : 0
    compatible_brands: qt
    creation_time   : 2017-01-25 22:58:59
  Duration: 00:00:03.18, start: 0.000000, bitrate: 10705 kb/s
    Stream #0.0(und): Video: h264 (Baseline), yuv420p, 1280x720, 10823 kb/s, 24.01 fps, 24 tbr, 600 tbn
    Metadata:
      creation_time   : 2017-01-25 22:58:59
    Stream #0.1(und): Audio: aac, 44100 Hz, mono, fltp, 61 kb/s
    Metadata:
      creation_time   : 2017-01-25 22:58:59
    Stream #0.2(und): Data: mebx / 0x7862656D, 0 kb/s
    Metadata:
      creation_time   : 2017-01-25 22:58:59
    Stream #0.3(und): Data: mebx / 0x7862656D, 0 kb/s
    Metadata:
      creation_time   : 2017-01-25 22:58:59
File 'out.mp4' already exists. Overwrite ? [y/N] y
[libx264 @ 0x1ff9360] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[libx264 @ 0x1ff9360] profile High, level 3.1
[libx264 @ 0x1ff9360] 264 - core 142 r2389 956c8d8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - 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=24 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.25 aq=1:1.00
Output #0, mp4, to 'out.mp4':
  Metadata:
    major_brand     : qt
    minor_version   : 0
    compatible_brands: qt
    creation_time   : 2017-01-25 22:58:59
    encoder         : Lavf54.20.4
    Stream #0.0(und): Video: libx264, yuv420p, 1280x720, q=-1--1, 22500 tbn, 24.01 tbc
    Metadata:
      creation_time   : 2017-01-25 22:58:59
    Stream #0.1(und): Audio: aac, 44100 Hz, mono, fltp, 200 kb/s
    Metadata:
      creation_time   : 2017-01-25 22:58:59
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> libx264)
  Stream #0:1 -> #0:1 (aac -> aac)
Press ctrl-c to stop encoding
frame=   75 fps= 29 q=32765.0 Lsize=    1673kB time=3.04 bitrate=4507.2kbits/s
video:595kB audio:74kB global headers:0kB muxing overhead 149.985988%
[libx264 @ 0x1ff9360] frame I:1     Avg QP:27.41  size: 47219
[libx264 @ 0x1ff9360] frame P:43    Avg QP:25.60  size: 28610
[libx264 @ 0x1ff9360] frame B:31    Avg QP:27.26  size: 11417
[libx264 @ 0x1ff9360] consecutive B-frames: 21.3% 66.7% 12.0%  0.0%
[libx264 @ 0x1ff9360] mb I  I16..4:  1.5% 76.0% 22.5%
[libx264 @ 0x1ff9360] mb P  I16..4:  2.5% 13.7%  5.9%  P16..4: 50.4% 15.5%  7.5%  0.0%  0.0%    skip: 4.4%
[libx264 @ 0x1ff9360] mb B  I16..4:  0.5%  2.1%  1.0%  B16..8: 52.8%  4.8%  0.8%  direct: 6.6%  skip:31.4%  L0:44.6% L1:51.8% BI: 3.6%
[libx264 @ 0x1ff9360] 8x8 transform intra:62.9% inter:58.8%
[libx264 @ 0x1ff9360] coded y,uvDC,uvAC intra: 79.0% 89.8% 36.9% inter: 33.5% 55.1% 1.6%
[libx264 @ 0x1ff9360] i16 v,h,dc,p:  7% 11% 32% 50%
[libx264 @ 0x1ff9360] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu:  8%  9% 17%  3% 20% 25% 10%  3%  4%
[libx264 @ 0x1ff9360] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 12% 12% 22%  4% 18% 19%  6%  3%  3%
[libx264 @ 0x1ff9360] i8c dc,h,v,p: 59% 18% 15%  8%
[libx264 @ 0x1ff9360] Weighted P-Frames: Y:27.9% UV:16.3%
[libx264 @ 0x1ff9360] ref P L0: 67.4% 15.9% 12.2%  3.9%  0.6%
[libx264 @ 0x1ff9360] ref B L0: 92.0%  7.4%  0.5%
[libx264 @ 0x1ff9360] ref B L1: 99.2%  0.8%
[libx264 @ 0x1ff9360] kb/s:4178.51

我知道在转换过程中有一条警告信息,但我仍然可以获得有效的mp4,所以我不知道这是不是问题。 我尝试过使用transpose = 1但它根本不会影响输出: avconv -i input.mov -vf transpose = 1 out.mp4

1 个答案:

答案 0 :(得分:0)

我进行了一些实验,最后找到了一个有效的组合:

avconv -i input.mov -vf "transpose=1" -codec:v libx264 -strict experimental out.mp4

我认为我有-strict -2而不是-strict实验,但是从文档我可以告诉2映射到什么或为什么会导致它忽略转置。我之前尝试过指定编解码器并且它不起作用,但也许是我之前使用的编解码器规范中使用的特定组合或参数导致它被忽略。