avconv - 根据元数据自动更改方向

时间:2015-07-26 00:43:47

标签: ios ffmpeg avconv

我正在运行一个服务器应用程序,它接受来自iOS应用程序的视频上传。该应用程序将.mov上传到服务器,服务器将其转换为.mp4(这是为了未来的Android兼容性)。问题是.mov格式在元数据中使用旋转标记,该标记与转换效果不佳,并且视频经常以错误的方向结束。我正在使用的命令,

for some reason it's not saving 10 entries to mongodb96
  ✓ should have 10 bookings in database
for some reason it's not saving 10 entries to mongodb97
  ✓ should have 10 bookings in database
for some reason it's not saving 10 entries to mongodb98
  ✓ should have 10 bookings in database
for some reason it's not saving 10 entries to mongodb99
  ✓ should have 10 bookings in database
two bookings should be returned from a GET request
  ✓ should have 10 bookings in database


GET /api/battles 200 2.437 ms - 284
      ✓ a battle should have two bookings
    testing api for battles including GET, UPDATE
      GET two bookings
        - should have two random bookings
        - should have two different bookings
      UPDATE two bookings after battle
        - should have a winner and a loser
        - should 
  102 passing (765ms)
  4 pending
  1 failing

  1) Battles controller tests: for some reason it's not saving 10 entries to mongodb19 should have 10 bookings in database:
     Uncaught AssertionError: expected [  name: 'Name1',
   _id: 55b429c4191a0b6666b04272,
   __v: 0,
   random: [ 0.8592369803227484, 0.0753506247419864 ],
   losses: 0,
   wins: 0,
   rating: 1000 },
  name: 'Name2',
   _id: 55b429c4191a0b6666b04273,
   __v: 0,
   random: [ 0.3049920208286494, 0.6233754165004939 ],
   losses: 0,
   wins: 0,
   rating: 1000 },
  name: 'Name3',
   _id: 55b429c4191a0b6666b04274,
   __v: 0,
   random: [ 0.8182909155730158, 0.8650113325566053 ],
   losses: 0,
   wins: 0,
   rating: 1000 },
  name: 'Name4',
   _id: 55b429c4191a0b6666b04275,
   __v: 0,
   random: [ 0.5385263541247696, 0.8532190786208957 ],
   losses: 0,
   wins: 0,
   rating: 1000 },
  name: 'Name5',
   _id: 55b429c4191a0b6666b04276,
   __v: 0,
   random: [ 0.06912864232435822, 0.6825810072477907 ],
   losses: 0,
   wins: 0,
   rating: 1000 },
  name: 'Name9',
   _id: 55b429c4191a0b6666b0427a,
   __v: 0,
   random: [ 0.26058629737235606, 0.34282937669195235 ],
   losses: 0,
   wins: 0,
   rating: 1000 },
  name: 'Name7',
   _id: 55b429c4191a0b6666b04278,
   __v: 0,
   random: [ 0.9167483656201512, 0.831106147961691 ],
   losses: 0,
   wins: 0,
   rating: 1000 },
  name: 'Name8',
   _id: 55b429c4191a0b6666b04279,
   __v: 0,
   random: [ 0.1588533204048872, 0.6727582819294184 ],
   losses: 0,
   wins: 0,
   rating: 1000 },
  name: 'Name6',
   _id: 55b429c4191a0b6666b04277,
   __v: 0,
   random: [ 0.2860944678541273, 0.1905197137966752 ],
   losses: 0,
   wins: 0,
   rating: 1000 } ] to have property length of 10 (got 9)
      at Promise.<anonymous> (app/tests/battles.server.controller.test.js:51:53)



adam@mastera:/var/www/html/mean$ 

似乎只旋转固定数量。我如何让avconv从.mov中读取旋转标志并相应地旋转视频流?

1 个答案:

答案 0 :(得分:1)

Download or compile最新版本ffmpeg。它会自动旋转您的视频,因此您的命令可能如下所示:

ffmpeg -i input.mov -c:v libx264 -vf scale=-2:480 -t 20 -c:a libvo_aacenc -b:a 192k \
-movflags +faststart output.mp4
  • 使用-noautorotate禁用此行为。
  • 对于scale,您可以使用-2代替trunc(oh*a/2)*2
  • Use -crf instead of -b:v。如果必须定位特定的输出文件大小,则使用-b:v,但需要两次传递;不是一个。默认值为-crf 23
  • libvo_aacenc是一个糟糕的编码器。如果可能,请考虑使用替代AAC encoder
  • 您可能需要-movflags +faststart,因此视频可能会在客户完全下载之前开始播放。
  • 我不确定这些信息是否适用于avconv;我不能使用它。
  • 下次问超级用户;你的问题在这里是offtopic,因为它不是编程相关的。 Stack Overflow不是一般的计算帮助资源。