[FFmpeg-user] Output PTS is different from the source

Wesley Wen delbin.wen at gmail.com
Thu Dec 18 16:43:22 CET 2014


Hi,

I'm transcoding one MPEG2-TS file to MP4, but I noticed the start PTSs of
video and audio of the generated MP4 file are different from the source.
The first video frame starts at 0, while the first audio PTS is negative. I
would expect the PTS of source and output should be identical.

The source video is interlaced MPEG-2 FYI.

Here is the command to do transcoding.
>>ffmpeg -i file.ts -c:v libx264 output.mp4
ffmpeg version 2.5 Copyright (c) 2000-2014 the FFmpeg developers
  built on Dec 15 2014 18:01:06 with Apple LLVM version 6.0
(clang-600.0.56) (based on LLVM 3.5svn)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/2.5 --enable-shared
--enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables
--enable-avresample --cc=clang --host-cflags= --host-ldflags=
--enable-libx264 --enable-libmp3lame --enable-libxvid --enable-libtheora
--enable-libvo-aacenc --enable-libfdk-aac --enable-libx265 --enable-nonfree
--enable-vda
  libavutil      54. 15.100 / 54. 15.100
  libavcodec     56. 13.100 / 56. 13.100
  libavformat    56. 15.102 / 56. 15.102
  libavdevice    56.  3.100 / 56.  3.100
  libavfilter     5.  2.103 /  5.  2.103
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mpegts, from 'file.ts':
  Duration: 00:00:49.68, start: 0.207867, bitrate: 31307 kb/s
  Program 16
    Stream #0:0[0xff]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002),
yuv420p(tv), 1440x1080 [SAR 4:3 DAR 16:9], 30000 kb/s, 29.97 fps, 29.97
tbr, 90k tbn, 59.94 tbc
    Stream #0:1[0x100]: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz,
stereo, s16p, 384 kb/s
[libx264 @ 0x7fc43900f000] using SAR=4/3
[libx264 @ 0x7fc43900f000] using cpu capabilities: MMX2 SSE2Fast SSSE3
SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[libx264 @ 0x7fc43900f000] profile High, level 4.0
[libx264 @ 0x7fc43900f000] 264 - core 142 r2455 021c0dc - H.264/MPEG-4 AVC
codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options:
cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1
psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1
cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6
lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0
bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1
b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25
scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0
qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'output.mp4':
  Metadata:
    encoder         : Lavf56.15.102
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p,
1440x1080 [SAR 4:3 DAR 16:9], q=-1--1, 29.97 fps, 30k tbn, 29.97 tbc
    Metadata:
      encoder         : Lavc56.13.100 libx264
    Stream #0:1: Audio: aac (libfdk_aac) ([64][0][0][0] / 0x0040), 48000
Hz, stereo, s16, 139 kb/s
    Metadata:
      encoder         : Lavc56.13.100 libfdk_aac
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg2video (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (mp2 (native) -> aac (libfdk_aac))
Press [q] to stop, [?] for help
frame= 1490 fps= 20 q=-1.0 Lsize=   26090kB time=00:00:49.68
bitrate=4301.6kbits/s dup=1 drop=0
video:25191kB audio:848kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 0.198627%
[libx264 @ 0x7fc43900f000] frame I:41    Avg QP:21.26  size: 64244
[libx264 @ 0x7fc43900f000] frame P:820   Avg QP:24.40  size: 22802
[libx264 @ 0x7fc43900f000] frame B:629   Avg QP:25.85  size:  7095
[libx264 @ 0x7fc43900f000] consecutive B-frames: 31.6% 32.2% 12.3% 23.9%
[libx264 @ 0x7fc43900f000] mb I  I16..4: 31.2% 61.3%  7.5%
[libx264 @ 0x7fc43900f000] mb P  I16..4:  5.8% 10.5%  1.8%  P16..4: 36.2%
 6.5%  4.7%  0.0%  0.0%    skip:34.5%
[libx264 @ 0x7fc43900f000] mb B  I16..4:  0.6%  0.8%  0.1%  B16..8: 32.0%
 2.1%  0.5%  direct: 2.0%  skip:62.0%  L0:42.9% L1:54.4% BI: 2.7%
[libx264 @ 0x7fc43900f000] 8x8 transform intra:58.4% inter:87.3%
[libx264 @ 0x7fc43900f000] coded y,uvDC,uvAC intra: 43.6% 61.0% 19.6%
inter: 11.8% 21.7% 1.8%
[libx264 @ 0x7fc43900f000] i16 v,h,dc,p: 28% 38%  7% 26%
[libx264 @ 0x7fc43900f000] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 18% 32%  3%
 3%  4%  3%  5%  4%
[libx264 @ 0x7fc43900f000] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 11% 67%  8%  3%
 2%  2%  2%  3%  2%
[libx264 @ 0x7fc43900f000] i8c dc,h,v,p: 47% 27% 20%  5%
[libx264 @ 0x7fc43900f000] Weighted P-Frames: Y:4.6% UV:1.8%
[libx264 @ 0x7fc43900f000] ref P L0: 58.6% 12.2% 18.8% 10.1%  0.3%
[libx264 @ 0x7fc43900f000] ref B L0: 80.5% 12.8%  6.7%
[libx264 @ 0x7fc43900f000] ref B L1: 96.4%  3.6%
[libx264 @ 0x7fc43900f000] kb/s:4150.65

I used ffprobe to source.
ffprobe -show_streams file.ts
ffprobe version 2.5 Copyright (c) 2007-2014 the FFmpeg developers
  built on Dec 15 2014 18:01:06 with Apple LLVM version 6.0
(clang-600.0.56) (based on LLVM 3.5svn)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/2.5 --enable-shared
--enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables
--enable-avresample --cc=clang --host-cflags= --host-ldflags=
--enable-libx264 --enable-libmp3lame --enable-libxvid --enable-libtheora
--enable-libvo-aacenc --enable-libfdk-aac --enable-libx265 --enable-nonfree
--enable-vda
  libavutil      54. 15.100 / 54. 15.100
  libavcodec     56. 13.100 / 56. 13.100
  libavformat    56. 15.102 / 56. 15.102
  libavdevice    56.  3.100 / 56.  3.100
  libavfilter     5.  2.103 /  5.  2.103
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mpegts, from 'file.ts':
  Duration: 00:00:49.68, start: 0.207867, bitrate: 31307 kb/s
  Program 16
    Stream #0:0[0xff]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002),
yuv420p(tv), 1440x1080 [SAR 4:3 DAR 16:9], 30000 kb/s, 29.97 fps, 29.97
tbr, 90k tbn, 59.94 tbc
    Stream #0:1[0x100]: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz,
stereo, s16p, 384 kb/s
[STREAM]
index=0
codec_name=mpeg2video
codec_long_name=MPEG-2 video
profile=Main
codec_type=video
codec_time_base=1001/60000
codec_tag_string=[2][0][0][0]
codec_tag=0x0002
width=1440
height=1080
has_b_frames=1
sample_aspect_ratio=4:3
display_aspect_ratio=16:9
pix_fmt=yuv420p
level=6
color_range=tv
color_space=unknown
color_transfer=unknown
color_primaries=unknown
chroma_location=left
timecode=00:00:00:00
id=0xff
r_frame_rate=30000/1001
avg_frame_rate=30000/1001
time_base=1/90000
start_pts=26634
start_time=0.295933
duration_ts=N/A
duration=N/A
bit_rate=30000000
max_bit_rate=30000000
bits_per_raw_sample=N/A
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
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
[/STREAM]
[STREAM]
index=1
codec_name=mp2
codec_long_name=MP2 (MPEG audio layer 2)
profile=unknown
codec_type=audio
codec_time_base=1/48000
codec_tag_string=[3][0][0][0]
codec_tag=0x0003
sample_fmt=s16p
sample_rate=48000
channels=2
channel_layout=stereo
bits_per_sample=0
id=0x100
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/90000
start_pts=18708
start_time=0.207867
duration_ts=4471200
duration=49.680000
bit_rate=384000
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
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
[/STREAM]

And then used ffprobe again to check output. You can see the start_pts of
video is 0, and start_pts of audio is negative.
ffprobe -show_streams output.mp4
ffprobe version 2.5 Copyright (c) 2007-2014 the FFmpeg developers
  built on Dec 15 2014 18:01:06 with Apple LLVM version 6.0
(clang-600.0.56) (based on LLVM 3.5svn)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/2.5 --enable-shared
--enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables
--enable-avresample --cc=clang --host-cflags= --host-ldflags=
--enable-libx264 --enable-libmp3lame --enable-libxvid --enable-libtheora
--enable-libvo-aacenc --enable-libfdk-aac --enable-libx265 --enable-nonfree
--enable-vda
  libavutil      54. 15.100 / 54. 15.100
  libavcodec     56. 13.100 / 56. 13.100
  libavformat    56. 15.102 / 56. 15.102
  libavdevice    56.  3.100 / 56.  3.100
  libavfilter     5.  2.103 /  5.  2.103
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf56.15.102
  Duration: 00:00:49.72, start: 0.042667, bitrate: 4298 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
1440x1080 [SAR 4:3 DAR 16:9], 4150 kb/s, 29.97 fps, 29.97 tbr, 30k tbn,
59.94 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz,
stereo, fltp, 139 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
[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=1440
height=1080
has_b_frames=2
sample_aspect_ratio=4:3
display_aspect_ratio=16:9
pix_fmt=yuv420p
level=40
color_range=N/A
color_space=unknown
color_transfer=unknown
color_primaries=unknown
chroma_location=left
timecode=N/A
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=1491490
duration=49.716333
bit_rate=4150763
max_bit_rate=N/A
bits_per_raw_sample=8
nb_frames=1490
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/48000
codec_tag_string=mp4a
codec_tag=0x6134706d
sample_fmt=fltp
sample_rate=48000
channels=2
channel_layout=stereo
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/48000
start_pts=-2048
start_time=-0.042667
duration_ts=2386688
duration=49.722667
bit_rate=139651
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=2331
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]

Thanks,
Wesley


More information about the ffmpeg-user mailing list