ffmpeg: videos before and after conversion aren't the same length

天涯浪子 提交于 2019-12-20 03:53:05

问题


I have a set of .mov videos which require conversion to .mp4 format. I'm using ffmpeg and running this command:

ffmpeg -i Banking.mov -vsync -async -sameq -ac 1 -ab 64k -ar 44100 Banking.mp4

There is a slight difference between input and output video in time length (00:03:35.407 and 00:03:35.582). And here's the catch - I'm storing time cue set at precise times in a file which is used by a program to point at specific scenes. The 0.1 second difference causes it to point at wrong scenes, therefore making the cue set useless. Is there any possibility to preserve exactly the same time in different format?

   FFmpeg version CVS, Copyright (c) 2000-2004 Fabrice BellardMac OSX universal build for ffmpegX
  configuration:  --enable-memalign-hack --enable-mp3lame --enable-gpl --disable-vhook --disable-ffplay --disable-ffserver --enable-a52 --enable-xvid --enable-faac --enable-faad --enable-amr_nb --enable-amr_wb --enable-pthreads --enable-x264 
  libavutil version: 49.0.0
  libavcodec version: 51.9.0
  libavformat version: 50.4.0
  built on Apr 15 2006 04:58:19, gcc: 4.0.1 (Apple Computer, Inc. build 5250)
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5597b8]negative ctts, ignoring
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Banking.mov':
  Duration: 00:03:35.6, start: 0.000000, bitrate: 1400 kb/s
  Stream #0.0(eng): Audio: pcm_s16be, 24000 Hz, stereo, 768 kb/s
  Stream #0.1(eng), 29.97 fps(r): Video: h264, yuv420p, 720x480
Output #0, mp4, to 'Banking.mp4':
  Stream #0.0, 29.97 fps(c): Video: mpeg4, yuv420p, 720x480, q=2-31, 200 kb/s
  Stream #0.1: Audio: aac, 44100 Hz, mono, 64 kb/s
Stream mapping:
  Stream #0.1 -> #0.0
  Stream #0.0 -> #0.1
Press [q] to stop encoding
frame= 6461 q=0.0 Lsize=   53181kB time=215.3 bitrate=2023.3kbits/s    
video:51437kB audio:1618kB global headers:0kB muxing overhead 0.237816%

回答1:


Judging from your FFmpeg output, it's seeing the input file as 3:35.6 minutes long:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Banking.mov': Duration: 00:03:35.6

So the difference in timing appears to be how FFmpeg sees your file, not anything directly relating to its transcoding of it. How are you measuring the duration to get 00:03:35.407?

That said, some observations:

  • Since your overall goal is just conversion of the container format, why not simply copy the video and audio data exactly:

    ffmpeg -i Banking.mov -codec copy Banking.mp4
    

    That should preserve everything nicely.

  • According to the documentation, -vsync and -async each take a parameter, so not having any probably isn't helping anything. (Though your version of FFmpeg is somewhat older, so perhaps that is proper usage for that version; I don't see any errors in the output.)

  • On that note, is there a reason you're using a six year-old build of FFmpeg? You'll definitely get better support, and likely better results with a more recent version.



来源:https://stackoverflow.com/questions/11455128/ffmpeg-videos-before-and-after-conversion-arent-the-same-length

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!