<p>As per a comment here, removing the -r flag ought to do this properly. You have another -r flag for the input, also. Remove both of them, and it should properly copy the stream as it is into a new container; you may need to remove that -an (disable audio) switch, too. I'm not sure on that:</p>

<pre><code>ffmpeg -y -i full-ts.ts -c:v copy full.mp4
</code></pre>

<p>If that fails, also per a comment here, you could try a different output container format.</p>

CC BY-SA 3.0
2016-06-28T05:15:59.853Z
2016-06-28T05:15:59.853Z
r_alex_hall
<p>I have large MPEG-TS file that I am converting to MP4 using the below command.  If I seek to the same time in the video in both the MP4 and the TS file,  the MP4 will be a few frames behind the TS file.  This get progressively worse the further into the video I seek. </p>

<pre><code>c:\&gt;ffmpeg -y -r 30 -i full-ts.ts -c:v copy -r 30 -an full.mp4
ffmpeg version N-69040-gb23a866 Copyright (c) 2000-2015 the FFmpeg developers
  built on Jan 12 2015 22:02:37 with gcc 4.9.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinge
r --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-
libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
  libavutil      54. 16.100 / 54. 16.100
  libavcodec     56. 20.100 / 56. 20.100
  libavformat    56. 18.101 / 56. 18.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5.  7.100 /  5.  7.100
  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 'full-ts.ts':
  Duration: 00:11:25.75, start: 1.424000, bitrate: 3407 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 90k tbn, 60 tbc
    Stream #0:1[0x101]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 125 kb/s
Output #0, mp4, to 'full.mp4':
  Metadata:
    encoder         : Lavf56.18.101
    Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 30 fps, 30 tbr, 15360 tbn, 30 tbc
Stream mapping:
  Stream #0:0 -&gt; #0:0 (copy)
Press [q] to stop, [?] for help
frame=20419 fps=0.0 q=-1.0 Lsize=  251660kB time=00:11:25.59 bitrate=3007.0kbits/s
video:251446kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.084929%
</code></pre>

<p>I'm confused why the TBN is so large in the output stream.  I've tried -copyts,  -copytb, all the -vsynch options,  but I cannot get seek times to match up on the MP4.   Also,  the MP4 shows a frame rate of 29.78,  whereas the TS file is solid 30/1 using ffprobe.  </p>

<pre><code>ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=avg_frame_rate full.mp4
streams_stream_0_avg_frame_rate="5227264/175529"

ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=avg_frame_rate full-ts.ts
programs_program_0_streams_stream_0_avg_frame_rate="30/1"
streams_stream_0_avg_frame_rate="30/1" 
</code></pre>

<p>Any idea how I can get the seeking on the both containers to show the same frame?  Please help!</p>

CC BY-SA 3.0
2015-04-03T23:34:20.397Z
What happens if you remove the input `-r 30`? What is the reason for that anyway? Also, you enable [stream copy](http://ffmpeg.org/ffmpeg.html#Stream-copy) mode with `-c:v copy` which means the output `-r 30` is ignored.
llogan
CC BY-SA 3.0
2015-04-05T02:54:23.437Z
@LordNeckbeard - it changes a few things in the output,  but I still have the seeking issue.  See log @ https://gist.github.com/andypryor/3b1f123b4c8d6ed3975c   ,  Thank for explaining the -r 30 is not needed,  I misunderstood its use,  thought I could force mp4 frame rate.
Andy
CC BY-SA 3.0
2015-04-12T02:30:38.587Z
As I understand it, mp4 doesn't store a framerate anywhere, just times between individual frames.  So ffprobe looks at the frame times of the first few frames, and assumes the rest of the video is the same.  I don't have any ideas to actually solve your problem, though.  Except maybe try something other than ffmpeg, like MP4Box.  Or even mkvmerge to a .mkv, to see if that works any differently.  (and maybe try ffmpeg muxing to something other than mp4.  ffmpeg's mp4 muxer might not be perfect.)
Peter Cordes
CC BY-SA 3.0
2015-09-15T04:19:01.553Z
The standard video frame rate is 29.97, if you convert to 30fps you will eventually see drift: http://filmdoctor.net/2010/06/drop-frame-vs-non-drop-frame/
screaming drills
CC BY-SA 3.0
2016-04-07T00:08:05.980Z
tbn of the output stream is too small 15k. it should be 90k. Seems like discarding of the audio stream is the source of the problem.
Dimitri Podborski
CC BY-SA 3.0
2016-06-28T07:06:47.970Z
@incBrain the `tbn` is not a problem. The `tbn` for TS is a fixed `90k` irrespective of video stream framerate and FFmpeg generates a tbn of `tbr x 512` for MOV/MP4 formats where `tbr` is the codec frame rate. Audio doesn't factor in here, since `tbn` refers to the video timescale.
Gyan
CC BY-SA 3.0
2016-06-28T08:13:57.273Z
@Mulvya tnx for the info. Do you know why they chose `tbr x 512`? Why 512?
Dimitri Podborski
<ffmpeg><mp4><h.264>
Copying h.264 video from TS into MP4 changes frame rate and time
Andy
# Copying h.264 video from TS into MP4 changes frame rate and time

(Asked by: username_0 on 2015-04-01)

I have large MPEG-TS file that I am converting to MP4 using the below command.  If I seek to the same time in the video in both the MP4 and the TS file,  the MP4 will be a few frames behind the TS file.  This get progressively worse the further into the video I seek. 
c:\>ffmpeg -y -r 30 -i full-ts.ts -c:v copy -r 30 -an full.mp4
ffmpeg version N-69040-gb23a866 Copyright (c) 2000-2015 the FFmpeg developers
  built on Jan 12 2015 22:02:37 with gcc 4.9.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinge
r --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-
libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
  libavutil      54. 16.100 / 54. 16.100
  libavcodec     56. 20.100 / 56. 20.100
  libavformat    56. 18.101 / 56. 18.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5.  7.100 /  5.  7.100
  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 'full-ts.ts':
  Duration: 00:11:25.75, start: 1.424000, bitrate: 3407 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 90k tbn, 60 tbc
    Stream #0:1[0x101]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 125 kb/s
Output #0, mp4, to 'full.mp4':
  Metadata:
    encoder         : Lavf56.18.101
    Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 30 fps, 30 tbr, 15360 tbn, 30 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame=20419 fps=0.0 q=-1.0 Lsize=  251660kB time=00:11:25.59 bitrate=3007.0kbits/s
video:251446kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.084929%

I'm confused why the TBN is so large in the output stream.  I've tried -copyts,  -copytb, all the -vsynch options,  but I cannot get seek times to match up on the MP4.   Also,  the MP4 shows a frame rate of 29.78,  whereas the TS file is solid 30/1 using ffprobe.  
ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=avg_frame_rate full.mp4
streams_stream_0_avg_frame_rate="5227264/175529"

ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=avg_frame_rate full-ts.ts
programs_program_0_streams_stream_0_avg_frame_rate="30/1"
streams_stream_0_avg_frame_rate="30/1" 

Any idea how I can get the seeking on the both containers to show the same frame?  Please help!

**Tags:** ffmpeg, mp4, h.264

> **Comments:**
> **username_1**: What happens if you remove the input `-r 30`? What is the reason for that anyway? Also, you enable [stream copy](http://ffmpeg.org/ffmpeg.html#Stream-copy) mode with `-c:v copy` which means the output `-r 30` is ignored.  
> **username_0**: @LordNeckbeard - it changes a few things in the output,  but I still have the seeking issue.  See log @ https://gist.github.com/andypryor/3b1f123b4c8d6ed3975c   ,  Thank for explaining the -r 30 is not needed,  I misunderstood its use,  thought I could force mp4 frame rate.  
> **username_2**: As I understand it, mp4 doesn't store a framerate anywhere, just times between individual frames.  So ffprobe looks at the frame times of the first few frames, and assumes the rest of the video is the same.  I don't have any ideas to actually solve your problem, though.  Except maybe try something other than ffmpeg, like MP4Box.  Or even mkvmerge to a .mkv, to see if that works any differently.  (and maybe try ffmpeg muxing to something other than mp4.  ffmpeg's mp4 muxer might not be perfect.)  
> **username_3**: The standard video frame rate is 29.97, if you convert to 30fps you will eventually see drift: http://filmdoctor.net/2010/06/drop-frame-vs-non-drop-frame/  
> **username_4**: tbn of the output stream is too small 15k. it should be 90k. Seems like discarding of the audio stream is the source of the problem.  
> **username_5**: @incBrain the `tbn` is not a problem. The `tbn` for TS is a fixed `90k` irrespective of video stream framerate and FFmpeg generates a tbn of `tbr x 512` for MOV/MP4 formats where `tbr` is the codec frame rate. Audio doesn't factor in here, since `tbn` refers to the video timescale.  
> **username_4**: @Mulvya tnx for the info. Do you know why they chose `tbr x 512`? Why 512?  

---

## 1 answers

### Answer by username_6 on 2016-06-28. Score: 3 | Accepted answer

As per a comment here, removing the -r flag ought to do this properly. You have another -r flag for the input, also. Remove both of them, and it should properly copy the stream as it is into a new container; you may need to remove that -an (disable audio) switch, too. I'm not sure on that:
ffmpeg -y -i full-ts.ts -c:v copy full.mp4

If that fails, also per a comment here, you could try a different output container format.


---

