2

Issue:

The videos I want to join without re-encoding have a constant framerate of 29.97 and the same encoding settings, however ffmpeg concat changes the final output's framerate mode to variable. I need it to stay at a constant framerate.

MediaInfo before concat:

Frame rate mode             : Constant
Frame rate                  : 29.970 fps

MediaInfo after concat:

Frame rate mode             : Variable
Frame rate                  : 29.970 fps
Minimum frame rate          : 25.489 fps
Maximum frame rate          : 29.970 fps

Original video encoding method:

ffmpeg -i whatever.mp4 -c:v libx264 -preset veryfast -pix_fmt yuv420p -crf 18 -r ntsc -an 1.mp4

Concat:

ffmpeg -f concat -i files.txt -c:v copy -movflags +faststart -an output.mp4 -y

files.txt (same file for testing)

file '1.mp4'
file '1.mp4'

Result:

ffmpeg version 2.8.4 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 5.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --e
onv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-lib
nable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libo
inger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --e
--enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --en
b
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 048d34e0] Auto-inserting h264_mp4toannexb bitstream filter
Input #0, concat, from 'files.txt':
  Duration: N/A, start: 0.000000, bitrate: 601 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1600x900, 473 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 127 kb/s
    Metadata:
      handler_name    : SoundHandler
[mp4 @ 0565d420] Codec for stream 0 does not use global headers but container format requires global headers
Output #0, mp4, to 'output.mp4':
  Metadata:
    encoder         : Lavf56.40.101
    Stream #0:0(und): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1600x900, q=2-31, 473 kb/s, 29.97 fps, 29.97 tbr, 30k tb
    Metadata:
      handler_name    : VideoHandler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mov,mp4,m4a,3gp,3g2,mj2 @ 048d34e0] Auto-inserting h264_mp4toannexb bitstream filter
[mp4 @ 0565d420] Starting second pass: moving the moov atom to the beginning of the file
frame=20668 fps=14443 q=-1.0 Lsize=   40102kB time=00:11:29.57 bitrate= 476.4kbits/s
video:39861kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.605159%

ffprobe 1.mp4

[STREAM]
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=High
codec_type=video
codec_time_base=1001/60000
codec_tag_string=avc1
codec_tag=0x31637661
width=1600
height=900
coded_width=1600
coded_height=900
has_b_frames=2
sample_aspect_ratio=0:1
display_aspect_ratio=0:1
pix_fmt=yuv420p
level=40
color_range=N/A
color_space=unknown
color_transfer=unknown
color_primaries=unknown
chroma_location=left
timecode=N/A
refs=1
is_avc=true
nal_length_size=4
id=N/A
r_frame_rate=30000/1001
avg_frame_rate=30000/1001
time_base=1/30000
start_pts=0
start_time=0.000000
duration_ts=10344334
duration=344.811133
bit_rate=473469
max_bit_rate=N/A
bits_per_raw_sample=8
nb_frames=10334
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=1
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
TAG:language=und
TAG:handler_name=VideoHandler
[/STREAM]
[STREAM]
index=1
codec_name=aac
codec_long_name=AAC (Advanced Audio Coding)
profile=LC
codec_type=audio
codec_time_base=1/44100
codec_tag_string=mp4a
codec_tag=0x6134706d
sample_fmt=fltp
sample_rate=44100
channels=1
channel_layout=mono
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/44100
start_pts=0
start_time=0.000000
duration_ts=15206400
duration=344.816327
bit_rate=127983
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=14848
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=1
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
TAG:language=und
TAG:handler_name=SoundHandler
[/STREAM]
[FORMAT]
filename=1.mp4
nb_streams=2
nb_programs=0
format_name=mov,mp4,m4a,3gp,3g2,mj2
format_long_name=QuickTime / MOV
start_time=0.000000
duration=344.817000
size=26298036
bit_rate=610133
probe_score=100
TAG:major_brand=isom
TAG:minor_version=512
TAG:compatible_brands=isomiso2avc1mp41
TAG:encoder=Lavf57.37.101
[/FORMAT]

ffprobe output.mp4

[STREAM]
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=High
codec_type=video
codec_time_base=143727/8615000
codec_tag_string=avc1
codec_tag=0x31637661
width=1600
height=900
coded_width=1600
coded_height=900
has_b_frames=2
sample_aspect_ratio=0:1
display_aspect_ratio=0:1
pix_fmt=yuv420p
level=40
color_range=N/A
color_space=unknown
color_transfer=unknown
color_primaries=unknown
chroma_location=left
timecode=N/A
refs=1
is_avc=true
nal_length_size=4
id=N/A
r_frame_rate=30000/1001
avg_frame_rate=4307500/143727
time_base=1/30000
start_pts=0
start_time=0.000000
duration_ts=20696688
duration=689.889600
bit_rate=478696
max_bit_rate=N/A
bits_per_raw_sample=8
nb_frames=20676
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=1
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
TAG:language=und
TAG:handler_name=VideoHandler
[/STREAM]
[FORMAT]
filename=output.mp4
nb_streams=1
nb_programs=0
format_name=mov,mp4,m4a,3gp,3g2,mj2
format_long_name=QuickTime / MOV
start_time=0.000000
duration=689.890000
size=41527343
bit_rate=481553
probe_score=100
TAG:major_brand=isom
TAG:minor_version=512
TAG:compatible_brands=isomiso2avc1mp41
TAG:encoder=Lavf56.40.101
[/FORMAT]
  • Works fine here with recent nightly build. Post the full ffprobe for whatever, 1 and output. – Gyan Jun 6 '16 at 5:08
  • added ffprobe output. whatever.mp4 is the same as 1.mp4. using the latest windows binary – Bart Jun 6 '16 at 6:45
0

I had the same problem, and I finally found a workaround.

If you use concat protocol everything is ok, the error is only related to concat demuxer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.