Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

While converting a H264/TS to a RAW/AVI with

ffmpeg -i in.ts -vcodec rawvideo -pix_fmt yuv420p out.avi

I found that the output AVI file had less frame than expected. It may come from PTS error in the TS, but if I convert it first to MP4 using the -vcodec copy option, I don't lost frame while performing MP4 to RAW/AVI.

Is there a solution to ignore the PTS to convert directly from TS?

Original H264/TS info:

$ ffmpeg -i input.ts
ffmpeg version N-53782-g2976e2a Copyright (c) 2000-2013 the FFmpeg developers
  built on Jun  3 2013 03:49:16 with gcc 4.7.3 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libblu
ray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-lib
vpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
  libavutil      52. 34.100 / 52. 34.100
  libavcodec     55. 14.100 / 55. 14.100
  libavformat    55.  8.102 / 55.  8.102
  libavdevice    55.  2.100 / 55.  2.100
  libavfilter     3. 74.101 /  3. 74.101
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
[mpegts @ 000000000248b440] max_analyze_duration 5000000 reached at 5000000 microseconds
Input #0, mpegts, from 'input.ts':
  Duration: 00:00:00.04, start: 1.400000, bitrate: N/A
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p, 320x240, 24 fps, 24 tbr, 90k tbn, 48 tbc

FFMPEG report a duration of 4seconds at 24fps, but with a TS analyzer i found 9598 frames and I saw the PTS/DTS error.

If we convert directly to AVI:

$ ffmpeg -i input.ts -vcodec rawvideo -pix_fmt yuv420p output.avi
ffmpeg version N-53782-g2976e2a Copyright (c) 2000-2013 the FFmpeg developers
  built on Jun  3 2013 03:49:16 with gcc 4.7.3 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libblu
ray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-lib
vpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
  libavutil      52. 34.100 / 52. 34.100
  libavcodec     55. 14.100 / 55. 14.100
  libavformat    55.  8.102 / 55.  8.102
  libavdevice    55.  2.100 / 55.  2.100
  libavfilter     3. 74.101 /  3. 74.101
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
[mpegts @ 00000000025dbc80] max_analyze_duration 5000000 reached at 5000000 microseconds
Input #0, mpegts, from 'input.ts':
  Duration: 00:00:00.04, start: 1.400000, bitrate: N/A
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p, 320x240, 24 fps, 24 tbr, 90k tbn, 48 tbc
Output #0, avi, to 'output.avi':
  Metadata:
    ISFT            : Lavf55.8.102
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 320x240, q=2-31, 200 kb/s, 24 tbn, 24 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> rawvideo)
Press [q] to stop, [?] for help
frame= 3393 fps=1521 q=0.0 Lsize=  381798kB time=00:02:21.37 bitrate=22123.3kbits/s dup=0 drop=6207
video:381712kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.022287%

The output show frame= 3393 Now i convert it first to MP4 (-vcode copy) and to AVI

$ ffmpeg -i input.ts -vcodec copy output.mp4
ffmpeg version N-53782-g2976e2a Copyright (c) 2000-2013 the FFmpeg developers
  built on Jun  3 2013 03:49:16 with gcc 4.7.3 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libblu
ray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-lib
vpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
  libavutil      52. 34.100 / 52. 34.100
  libavcodec     55. 14.100 / 55. 14.100
  libavformat    55.  8.102 / 55.  8.102
  libavdevice    55.  2.100 / 55.  2.100
  libavfilter     3. 74.101 /  3. 74.101
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
[mpegts @ 000000000248bb40] max_analyze_duration 5000000 reached at 5000000 microseconds
Input #0, mpegts, from 'input.ts':
  Duration: 00:00:00.04, start: 1.400000, bitrate: N/A
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p, 320x240, 24 fps, 24 tbr, 90k tbn, 48 tbc
Output #0, mp4, to 'output.mp4':
  Metadata:
    encoder         : Lavf55.8.102
    Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 320x240, q=2-31, 24 fps, 90k tbn, 90k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame= 9600 fps=0.0 q=-1.0 Lsize=  105953kB time=00:06:39.95 bitrate=2170.1kbits/s
video:105838kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.108838%

We saw frame= 9600copied into the MP4 and below the MP4 to AVI with the correct number of transcode frame. I search the command I use with the original TS file to prevent the frame skip, because using an intermediate conversion as MP4 consume storage & time !

$ ffmpeg -i output.mp4 -vcodec rawvideo -pix_fmt yuv420p output.avi
ffmpeg version N-53782-g2976e2a Copyright (c) 2000-2013 the FFmpeg developers
  built on Jun  3 2013 03:49:16 with gcc 4.7.3 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libblu
ray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-lib
vpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
  libavutil      52. 34.100 / 52. 34.100
  libavcodec     55. 14.100 / 55. 14.100
  libavformat    55.  8.102 / 55.  8.102
  libavdevice    55.  2.100 / 55.  2.100
  libavfilter     3. 74.101 /  3. 74.101
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf55.8.102
  Duration: 00:06:40.00, start: 0.000000, bitrate: 2169 kb/s
    Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 320x240, 2167 kb/s, 24 fps, 24 tbr, 90k tbn, 48 tbc
    Metadata:
      handler_name    : VideoHandler
File 'output.avi' already exists. Overwrite ? [y/N] y
Output #0, avi, to 'output.avi':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    ISFT            : Lavf55.8.102
    Stream #0:0(und): Video: rawvideo (I420 / 0x30323449), yuv420p, 320x240, q=2-31, 200 kb/s, 24 tbn, 24 tbc
    Metadata:
      handler_name    : VideoHandler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> rawvideo)
Press [q] to stop, [?] for help
frame= 9600 fps=4491 q=0.0 Lsize= 1080301kB time=00:06:40.00 bitrate=22124.6kbits/s
video:1080000kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.027894%
share|improve this question
    
Just for reference, can you please include your full output? –  slhck Aug 14 '13 at 6:59
    
@slhck, I added all details to clarify the question. –  alexbuisson Aug 14 '13 at 14:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.