[FFmpeg-user] Possible feature additions for concatenating video files

dg1727 at hushmail.com dg1727 at hushmail.com
Thu Jan 5 22:41:35 CET 2012


On Wed, 04 Jan 2012 18:45:59 -0500 Carl Eugen Hoyos 
<cehoyos at ag.or.at> wrote:
><dg1727 <at> hushmail.com> writes:
>
>> A.  An option in FFmpeg to assume that the input file is 
>> correct (audio and video have the same duration) except that 
>> only the video-FPS field is wrong.  This option would change 
>> only the video-FPS field to make the computed video duration 
>> match the audio duration. 
>> Preferably, this option could be given to the "ffmpeg" command 
>> in the FLV-to-MP4 step listed above.
>
>If I understand that correctly, FFmpeg miscalculates (or 
>misdetects) the video (or audio) duration in one of your 
>samples, and the result of your initial
>ffmpeg -i input -acodec copy -vcodec copy call results in an out-
>of-sync file. If that is correct, please provide a sample.

I'm not sure that FFmpeg is misdetecting anything.  I assume that 
the input *.mp4 file has a mistaken video-FPS number stored in it.  
I assume that "MP4Box -info" is _correctly_ multiplying the number 
of video frames by this mistaken video-FPS number and thus arriving 
at an _incorrect_ video duration; and that the same FPS is used in 
the concatenation, causing the video duration to be the same wrong 
value calculated by "MP4Box -info".  

Any sync problem doesn't appear until I try to concatenate the 
files.  

I have thought some more about my attempted concatenation.  Let me 
repeat the calculations I am doing:  

  (Number of video frames) / (video duration) = FPS that seems to 
be stored in the *.mp4 

  (Number of video frames) / (audio duration) = what seems to be 
the correct FPS 

I ran "MP4Box -info" on all 10 of my files and found that the 
"correct" FPS vary a little bit.  For the first 9 files, if the 
"correct" FPS is truncated to 3 decimal places, it is 24.978 in all 
cases.  Truncated to 5 decimal places, it ranges from 24.97812 to 
24.97889.  The "correct" FPS for the 10th file is 24.9479.  (It 
looks like the last file has a few extra audio samples, and the 
correct FPS is probably 24.978.  If this file were forced to 24.978 
FPS, a fraction of a second of audio would extend past the video; 
this would be fine.)  If the frame rates were adjusted 
automatically according to my suggestion A above, then they would 
come out different (24.97812, 24.97889, 24.9479, etc.)  Since the 
resulting video files would have different frame rates, existing 
tools might not be able to concatenate them [4][5].  

[4] 
http://sourceforge.net/projects/gpac/forums/forum/287547/topic/48337
22 
[5] 
http://sourceforge.net/projects/gpac/forums/forum/287547/topic/48775
38 

For now, I am fine with determining the frame rate by hand instead 
of having FFmpeg calculate it as in my suggestion A (so far, I 
don't often need to do this video splicing).  It doesn't matter if 
the same frame rate as in the first 9 files is put into the last 
file; a discrepancy in the last file won't put anything out of 
sync.  

So I would like to force all 10 files to 24.978 FPS.  

Now I am having trouble finding the right command line to do this.  

My ffmpeg startup banner is:  

ffmpeg version 0.9.0.git, Copyright (c) 2000-2012 the FFmpeg 
developers
  built on Jan  1 2012 14:20:29 with gcc 4.5.2
  configuration: 
  libavutil      51. 33.100 / 51. 33.100
  libavcodec     53. 49.101 / 53. 49.101
  libavformat    53. 29.100 / 53. 29.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 57.101 /  2. 57.101
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0.  5.100 /  0.  5.100

(
I have a suggestion C.  Is it possible to have the version listed 
as something like 0.9.0.gitmaster20120101_140000.001 to be more 
precise?  
)

Taking bits and pieces out of the ffmpeg manpage, I made the 
following 2 attempts:  

ffmpeg -i 1.flv -vcodec copy -acodec copy -r 24.978 1.mp4

Result:  The output file had the same statistics as without the -r 
option.  

ffmpeg -i 1.flv -c:v libx264 -sameq -acodec copy -r 24.978 1a.flv

Result:  Unknown encoder 'libx264'

Then I ran 
ffmpeg -codecs | grep 264
which showed:  
 D V D  h264            H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10

Since the capabilities flags at the beginning (D V D) don't contain 
an E, the "h264" codec in my FFmpeg install is not capable of 
encoding.  

Do I need to download or compile my FFmpeg in a different way to 
gain access to H.264 encoding?  My package manager shows that I 
have 3 versions of libx264 installed.  

I prefer a way to modify the FPS during a stream-copy, to eliminate 
the chance of quality loss.  

What command line should I use to alter only the FPS field of the 
input FLV file, hopefully in the same command as changing the 
container from FLV to MP4?  

I also look forward to comment on my suggestion B:  

B.  A feature (maybe in ffprobe?) which reports the total number of
I-frames, P-frames, and B-frames in a given video stream (any
format, not just H.264).  This way, if the file has no B-frames, I
can happily use tools on it that warn me that B-frames may cause
problems.  

Thanks again for help.  



More information about the ffmpeg-user mailing list