0

I'm trying to convert a .ts file to an .mp4. I'm using the following ffmpeg command:

ffmpeg -i all.ts -c copy all.mp4

This results in a noticeable loss in the fluidity of the video, which looks much more fluid in the original .ts format when viewed in VLC.

Output of ffmpeg:

Input #0, mpegts, from 'all.ts':
  Duration: 00:00:25.00, start: 235.000000, bitrate: 804 kb/s
  Program 16727
    Stream #0:0[0x22]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 124 kb/s
    Stream #0:1[0x21]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(progressive), 960x540 [SAR 1:1 DAR 16:9], 25 fps, 25 t
br, 90k tbn, 50 tbc
File 'all.mp4' already exists. Overwrite ? [y/N] y
Output #0, mp4, to 'all.mp4':
  Metadata:
    encoder         : Lavf58.29.100
    Stream #0:0: Video: h264 (Main) (avc1 / 0x31637661), yuv420p(progressive), 960x540 [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 25 tbr,
 90k tbn, 90k tbc
    Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 124 kb/s
Stream mapping:
  Stream #0:1 -> #0:0 (copy)
  Stream #0:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mpegts @ 0x7fabfe802a00] Invalid timestamps stream=1, pts=21153600, dts=21160800, size=1936
[mpegts @ 0x7fabfe802a00] Invalid timestamps stream=1, pts=21160800, dts=21164400, size=2827
[mp4 @ 0x7fabff005000] Invalid DTS: 10800 PTS: 3600 in output stream 0:0, replacing by guess
[mp4 @ 0x7fabff005000] Invalid DTS: 14400 PTS: 10800 in output stream 0:0, replacing by guess
...
frame=  625 fps=0.0 q=-1.0 Lsize=    2330kB time=00:00:24.98 bitrate= 764.0kbits/s speed= 614x
video:1908kB audio:398kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.070788%

There's lots of Invalid timestamps and Invalid DTS errors, but I'm not sure they're related to the problem.

I've uploaded a small sample to demonstrate the error: here is the original TS file, and here the not-so-fluid MP4 result.

Any idea of how to fix this? I have noticed that the problem does not occur if I re-encode the video track with h264, but I'd really like to just remux as the original TS looks just fine.

Thanks!

2

There's lots of Invalid timestamps and Invalid DTS errors, but I'm not sure they're related to the problem.

They are, frames in video streams with B-frames are not encoded or stored in presentation order, so the presentation timestamps have to be correctly offset for fluid playback. In this TS sample, you have presentation timestamps earlier than decoding timestamps, which are invalid, and ffmpeg defaults to assigning the DTS as the new PTS.

Instead, use existing PTS as the reference.

ffmpeg -fflags +igndts -i all.ts -c copy all.mp4
| improve this answer | |
  • Sorry to butt in, but is there a way to ignore/hide the [mpegts @ [...]] Invalid timestamps [...] messages as well? That way, while downloading a HLS videostream, I'll only get to see the desired [https @ [...]] Opening 'https://[...].ts' for reading. – Reino Oct 24 at 16:26
  • No, warnings and errors have more priority than informational messages. – Gyan Oct 24 at 16:58

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.