[FFmpeg-user] [EXTERNAL] Re: Parse a transport stream and get just 1 program

Shupert, Jim jim.shupert at hearst.com
Tue Oct 12 15:27:15 EEST 2021



-----Original Message-----
From: Leo Butler <leo.butler81 at googlemail.com> 
Sent: Tuesday, October 12, 2021 7:34 AM
To: Shupert, Jim via ffmpeg-user <ffmpeg-user at ffmpeg.org>
Cc: Shupert, Jim <jim.shupert at hearst.com>
Subject: [EXTERNAL] Re: [FFmpeg-user] Parse a transport stream and get just 1 program

"Shupert, Jim via ffmpeg-user" <ffmpeg-user at ffmpeg.org> writes:

> -----Original Message-----
> From: ffmpeg-user <ffmpeg-user-bounces at ffmpeg.org> On Behalf Of Shupert, Jim via ffmpeg-user
> Sent: Sunday, October 10, 2021 5:15 PM
> To: ffmpeg-user at ffmpeg.org
> Cc: Shupert, Jim <jim.shupert at hearst.com>
> Subject: [EXTERNAL] [FFmpeg-user] Parse a transport stream and get just 1 program
>
> Friends,
> I have a file.ts
> It seems to contain 4 programs.
> I can see this by when I play it in VLC I can select what I want by Playback - Program and picking the top of the 4 listed..
> Ffmpeg shows the following
>
> ffmpeg version N-99707-g2b702015d8 Copyright (c) 2000-2020 the FFmpeg developers
>   built with gcc 9.3-win32 (GCC) 20200320
>   configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --enable-shared --disable-static --disable-debug --enable-iconv --enable-zlib --enable-libxml2 --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-opencl --enable-libvmaf --enable-vulkan --enable-libvorbis --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --enable-ffnvcodec --enable-cuda-llvm --enable-libglslang --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librav1e --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --enable-libvidstab --enable-libx264 --e
>  nable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-libs=-lgomp
>   libavutil      56. 60.100 / 56. 60.100
>   libavcodec     58.111.101 / 58.111.101
>   libavformat    58. 62.100 / 58. 62.100
>   libavdevice    58. 11.102 / 58. 11.102
>   libavfilter     7. 88.100 /  7. 88.100
>   libswscale      5.  8.100 /  5.  8.100
>   libswresample   3.  8.100 /  3.  8.100
>   libpostproc    55.  8.100 / 55.  8.100
> [mpeg2video @ 000001a962a12dc0] Invalid frame dimensions 0x0.
>     Last message repeated 3 times
> [mpegts @ 000001a960bfd900] DTS discontinuity in stream 3: packet 3 with DTS 7640699639, packet 4 with DTS 16230637234 [mpeg2video @ 000001a962a12dc0] Invalid frame dimensions 0x0.
>     Last message repeated 2 times
> [mpeg2video @ 000001a960c92480] Invalid frame dimensions 0x0.
> [mpeg2video @ 000001a962a12dc0] Invalid frame dimensions 0x0.
> [mpeg2video @ 000001a960c92480] Invalid frame dimensions 0x0.
> [mpeg2video @ 000001a962a12dc0] Invalid frame dimensions 0x0.
>     Last message repeated 1 times
> [mpeg2video @ 000001a960c92480] Invalid frame dimensions 0x0.
> [mpeg2video @ 000001a962a12dc0] Invalid frame dimensions 0x0.
>     Last message repeated 1 times
> [mpeg2video @ 000001a960c92480] Invalid frame dimensions 0x0.
>    Last message repeated 1 times
> [mpeg2video @ 000001a962a12dc0] Invalid frame dimensions 0x0.
>     Last message repeated 2 times
> [mpeg2video @ 000001a960c92480] Invalid frame dimensions 0x0.
>     Last message repeated 4 times
> [mpeg2video @ 000001a962a12dc0] Invalid frame dimensions 0x0.
> [mpeg2video @ 000001a960c92480] Invalid frame dimensions 0x0.
>     Last message repeated 13 times
> [mpegts @ 000001a960bfd900] PES packet size mismatch [mpegts @ 000001a960bfd900] Packet corrupt (stream = 4, dts = 8489776251).
> [mpegts @ 000001a960bfd900] PES packet size mismatch [mpegts @ 000001a960bfd900] Packet corrupt (stream = 10, dts = 8489790651).
> [mpegts @ 000001a960bfd900] PES packet size mismatch [mpegts @ 000001a960bfd900] Packet corrupt (stream = 6, dts = 8489805840).
> [mpegts @ 000001a960bfd900] PES packet size mismatch [mpegts @ 000001a960bfd900] Packet corrupt (stream = 7, dts = 8489805840).
> [mpegts @ 000001a960bfd900] PES packet size mismatch [mpegts @ 000001a960bfd900] Packet corrupt (stream = 8, dts = 7958876999).
> [mpegts @ 000001a960bfd900] PES packet size mismatch [mpegts @ 000001a960bfd900] Packet corrupt (stream = 9, dts = 7958876999).
> [mpegts @ 000001a960bfd900] stream 1 : no PTS found at end of file, duration not set [mpegts @ 000001a960bfd900] stream 3 : no PTS found at end of file, duration not set Input #0, mpegts, from 'MTP.ts':
>   Duration: 27:29:39.15, start: 84896.562556, bitrate: 692 kb/s
>   Program 1
>     Stream #0:2[0x51]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, top first), 1920x1080 [SAR 1:1 DAR 16:9], Closed Captions, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
>     Side data:
>       cpb: bitrate max/min/avg: 17598000/0/0 buffer size: 7995392 vbv_delay: N/A
>     Stream #0:4[0x54](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 384 kb/s
>     Stream #0:10[0x56](spa): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 192 kb/s
>   Program 2
>     Stream #0:5[0x61]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, top first), 640x480 [SAR 4:3 DAR 16:9], Closed Captions, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
>     Side data:
>       cpb: bitrate max/min/avg: 7810800/0/0 buffer size: 1835008 vbv_delay: N/A
>     Stream #0:6[0x64](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 192 kb/s
>     Stream #0:7[0x67](spa): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 192 kb/s
>   Program 3
>     Stream #0:3[0x71]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, top first), 640x480 [SAR 4:3 DAR 16:9], Closed Captions, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
>     Side data:
>       cpb: bitrate max/min/avg: 7810800/0/0 buffer size: 1835008 vbv_delay: N/A
>     Stream #0:8[0x74](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 192 kb/s
>     Stream #0:9[0x76](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 192 kb/s
>   Program 7
>     Stream #0:0[0xb1]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, progressive), 1280x720 [SAR 1:1 DAR 16:9], Closed Captions, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
>     Side data:
>       cpb: bitrate max/min/avg: 9759200/0/0 buffer size: 7995392 vbv_delay: N/A
>     Stream #0:1[0xb4](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 384 kb/s At least one output file must be specified
>
> My goal is to have a file.ts that contains just the "1st" program The video , audio and captions.
>
> I think that is  would be this part
>
> Program 1
>     Stream #0:2[0x51]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, top first), 1920x1080 [SAR 1:1 DAR 16:9], Closed Captions, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
>     Side data:
>       cpb: bitrate max/min/avg: 17598000/0/0 buffer size: 7995392 vbv_delay: N/A
>     Stream #0:4[0x54](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 384 kb/s
>     Stream #0:10[0x56](spa): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 192 kb/s
>
> And I think I can solve this with mapping Ending with a file.ts with just the 1 video,audio
>
> What would be the  correct means to achive this?
>
> Thanks much!
>
> Jim shupert
>
>
> I was trying map without full success.
> I think this works
> ffmpeg -i MTP.ts -y -c copy -map p:1 mtp_1.mpg
>
> I still wonder if there is a better way?

This should do what you asked for:

ffmpeg -y -i file.ts -c copy -map 0:2 -map 0:4 out.ts

Leo

Thanks
I wonder what do you see that tells that the mapping is map 0:2 -map 0:4
Kind regards


More information about the ffmpeg-user mailing list