I convert videos using FFMPEG. My goal is to convert them to the MP4 container format (MPEG-4 Part 14) with AAC-encoded audio stream and MPEG-4 part 10-encoded video stream.
I use the following line to convert the videos:
ffmpeg -y -i "{inputFile}" "{outputFile}"
The converted video looks fine, however the duration of streams in the converted file and the input file doesn't always match.
I've made some experiments and the difference in the duration is undoubtedly there, however, it is not that much - anyway I'm testing with small videos. Here are my results:
| InputFile | InputAudio | InputVideo | OutputAudio | OutputVideo |
|------------|------------|------------|-------------|--------------|
| h.avi | 3s 631ms | 3s 567ms | 3s 668ms | 3s 567ms |
| h.flv | 3s 631ms | 3s 558ms | 3s 668ms | 3s 567ms |
| h.mov | 3s 532ms | 3s 533ms | 3s 682ms | 3s 534ms |
| h.mp4 | 3s 605ms | 3s 534ms | 3s 682ms | 3s 567ms |
| h.mpg | 3s 605ms | 3s 533ms | 3s 563ms | 3s 534ms |
| h.wmv | 3s 620ms | 3s 633ms | 3s 659ms | 3s 567ms |
Since I would build a software on the top of FFMPEG, I would be happier if I could at least understand the reason of this difference. Is it because of some unnecessary transcoding?
In this case, can I turn this transcoding off to prevent FFMPEG to resample my input video file?
If I cannot turn it off, how can I be sure (besides testing) that this difference is not proportional to the size of the video?
If I convert for example a 10-hour video, a difference of multiple seconds or even minutes is not suitable for me.