Page 1 of 1

mpeg-ts aspect ratio discovery

PostPosted: Sun May 14, 2017 4:01 pm
by BestBoy
I have an mpeg-ts file recorded by vdr. I am trying to write a script to cut out the ads and encode the show to x264. The trouble is the ads are 16:9 but the show is 4:3 and the encoded file is 16:9, unless I start the encode before the switch.
I thought to get the ratio from the file then explicitly encode it but ffprobe always returns 16:9 even when I try to seek to a 4:3 part with -read_interval.
mplayer detects the switch correctly and changes the aspect ratio of its window. ffplay also detects the switch and displays both ratios correctly but doesn't adjust its window, showing black bars at the sides after the switch. So presumably the file is correct.

My ffprobe output:
Code: Select all
$ ffprobe -read_intervals 300 00001.ts
ffprobe version 3.3 Copyright (c) 2007-2017 the FFmpeg developers
  built with gcc 6.3.0 (Debian 6.3.0-14) 20170415
  configuration: --disable-decoder=amrnb --disable-decoder=libopenjpeg --disable-mips32r2 --disable-mips32r6 --disable-mips64r6 --disable-mipsdsp --disable-mipsdspr2 --disable-mipsfpu --disable-msa --disable-libopencv --disable-podpages --disable-stripping --enable-avfilter --enable-avresample --enable-gcrypt --enable-gnutls --enable-gpl --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libilbc --enable-libkvazaar --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx265 --enable-libxvid --enable-libzvbi --enable-nonfree --enable-opengl --enable-openssl --enable-postproc --enable-pthreads --enable-shared --enable-version3 --incdir=/usr/include/x86_64-linux-gnu --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --toolchain=hardened --enable-frei0r --enable-chromaprint --enable-libx264 --enable-libiec61883 --enable-libdc1394 --enable-vaapi --disable-opencl --enable-libmfx --disable-altivec --shlibdir=/usr/lib/x86_64-linux-gnu
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libavresample   3.  5.  0 /  3.  5.  0
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
  libpostproc    54.  5.100 / 54.  5.100
[mpegts @ 0x560eecb49180] start time for stream 3 is not set in estimate_timings_from_pts
[mpegts @ 0x560eecb49180] PES packet size mismatch
    Last message repeated 1 times
Input #0, mpegts, from '00001.ts':
  Duration: 00:41:58.20, start: 65956.389156, bitrate: 2073 kb/s
  Program 132
    Stream #0:0[0x44d]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, top first), 720x576 [SAR 64:45 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x44e](eng): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 192 kb/s
    Stream #0:2[0x44f](eng): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, mono, s16p, 64 kb/s
    Stream #0:3[0x46b](eng): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)


Am I doing it wrong? Any suggestions for alternative methods? I would like a generic solution as sometimes I will want to crop the video too.