Opened 14 years ago

Closed 13 years ago

Last modified 10 years ago

#995 closed enhancement (fixed)

Selecting a stream from a multi-service mpegts

Reported by: burek Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Hi, it would be nice to have an option to select (extract) only a specific service from within an mpegts multi programs stream. I'm not sure if I named each thing correctly, but here is an example:

mpegts @ 0x1ffd3a0] Estimating duration from bitrate, this may be inaccurate
Input #0, mpegts, from 'udp://@:5000':
  Duration: N/A, start: 34272.976700, bitrate: 41672 kb/s
  Program 52
    Metadata:
      service_name    : PenthouseTV
      service_provider:
    Stream #0:22[0x710], 0, 1/90000: Video: mpeg2video ([2][0][0][0] / 0x0002), 90k tbr, 90k tbn
    Stream #0:23[0x711], 0, 1/90000: Audio: mp3 ([3][0][0][0] / 0x0003), 0 channels, s16
  Program 53
    Metadata:
      service_name    : Juicy
      service_provider:
    Stream #0:8[0x720], 0, 1/90000: Video: mpeg2video ([2][0][0][0] / 0x0002), 90k tbr, 90k tbn
    Stream #0:9[0x721], 0, 1/90000: Audio: mp3 ([3][0][0][0] / 0x0003), 0 channels, s16
  Program 54
    Metadata:
      service_name    : BN BOSNIA
      service_provider:
    Stream #0:10[0x420], 0, 1/90000: Video: mpeg2video ([2][0][0][0] / 0x0002), 90k tbr, 90k tbn
    Stream #0:11[0x421], 0, 1/90000: Audio: mp3 ([3][0][0][0] / 0x0003), 0 channels, s16
  Program 55
    Metadata:
      service_name    : BN Music
      service_provider:
    Stream #0:12[0xfba], 0, 1/90000: Video: mpeg2video ([2][0][0][0] / 0x0002), 90k tbr, 90k tbn
    Stream #0:13[0xfcc], 0, 1/90000: Audio: mp3 ([3][0][0][0] / 0x0003), 0 channels, s16
  Program 56
    Metadata:
      service_name    : Al Maghribiya
      service_provider:
    Stream #0:0[0xfb7], 66, 1/90000: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 480x480 [SAR 4:3 DAR 4:3], 1001/60000, 15000 kb/s, 31.44 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:1[0xfc1], 90, 1/90000: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16, 128 kb/s
  Program 59
    Metadata:
      service_name    : TVK
      service_provider:
    Stream #0:14[0x12c], 0, 1/90000: Video: mpeg2video ([2][0][0][0] / 0x0002), 90k tbr, 90k tbn
    Stream #0:15[0x12d], 0, 1/90000: Audio: mp3 ([3][0][0][0] / 0x0003), 0 channels, s16
  Program 60
    Metadata:
      service_name    : Telesur
      service_provider:
    Stream #0:2[0x13c], 68, 1/90000: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 704x480 [SAR 10:11 DAR 4:3], 1001/60000, 2750 kb/s, 33.53 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:25[0x13d], 90, 1/90000: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16, 112 kb/s
  Program 62
    Metadata:
      service_name    : Canal Algerie
      service_provider:
    Stream #0:16[0x4c4], 90, 1/90000: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16, 128 kb/s
    Stream #0:17[0x4ec], 67, 1/90000: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 544x480 [SAR 20:17 DAR 4:3], 1001/60000, 3150 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
  Program 64
    Metadata:
      service_name    : Al Maaref
      service_provider:
    Stream #0:3[0x12a], 67, 1/90000: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 544x480 [SAR 20:17 DAR 4:3], 1001/60000, 1790 kb/s, 34.79 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:4[0x12b], 90, 1/90000: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16, 112 kb/s
  Program 65
    Metadata:
      service_name    : Syrian Drama
      service_provider:
    Stream #0:18[0x450], 67, 1/90000: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 704x480 [SAR 10:11 DAR 4:3], 1001/60000, 2750 kb/s, 31.42 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:19[0x451], 90, 1/90000: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, mono, s16, 112 kb/s
  Program 72
    Metadata:
      service_name    : Chaine 1
      service_provider:
    Stream #0:20[0x5fd], 95, 1/90000: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16, 256 kb/s
  Program 73
    Metadata:
      service_name    : Radio Internationale
      service_provider:
    Stream #0:24[0x5fe], 95, 1/90000: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16, 256 kb/s
  Program 74
    Metadata:
      service_name    : BN Bosnia Radio
      service_provider:
    Stream #0:21[0x422], 0, 1/90000: Audio: mp3 ([3][0][0][0] / 0x0003), 0 channels, s16
  Program 167
    Metadata:
      service_name    : CNC World English
      service_provider:
    Stream #0:6[0x10f5], 64, 1/90000: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 704x480 [SAR 10:11 DAR 4:3], 1001/60000, 15000 kb/s, 35.06 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:7[0x10f6], 90, 1/90000: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16, 128 kb/s
  Program 458
    Metadata:
      service_name    : Radio BIR
      service_provider:
    Stream #0:5[0x212], 0, 1/90000: Audio: mp3 ([3][0][0][0] / 0x0003), 0 channels, s16
  Program 460
    Metadata:
      service_name    : Radio Glas Drine
      service_provider:
    Stream #0:26[0x452], 0, 1/90000: Audio: mp3 ([3][0][0][0] / 0x0003), 0 channels, s16
[libx264 @ 0x21a8ac0] using mv_range_thread = 24
[libx264 @ 0x21a8ac0] using cpu capabilities: MMX2 SSE2Fast FastShuffle SSEMisalign LZCNT
[libx264 @ 0x21a8ac0] profile High, level 3.0
[libx264 @ 0x21a8ac0] 264 - core 120 r2164 da19765 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=9 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[mpeg2video @ 0x2038120] detected 6 logical cores
Output #0, flv, to '/mnt/encoder/test.avi':
  Metadata:
    encoder         : Lavf54.0.100
    Stream #0:0, 0, 1/1000: Audio: mp3 ([2][0][0][0] / 0x0002), 44100 Hz, 0 channels, s16, 128 kb/s
    Stream #0:1, 0, 1/1000: Video: h264 ([7][0][0][0] / 0x0007), yuv420p, 704x480, 1001/30000, q=-1--1, 1k tbn, 29.97 tbc
Stream mapping:
  Stream #0:5 -> #0:0 (mp3 -> libmp3lame)
  Stream #0:6 -> #0:1 (mpeg2video -> libx264)

So, if one wants to extract the "service_name : CNC World English", both audio/video, then the command would look something like:

ffmpeg -f mpegts -i udp://@:5000 -mpegts_select_service_name "CNC World English" -vcodec copy -acodec copy ...

Change History (7)

comment:1 by Carl Eugen Hoyos, 14 years ago

Is this problem only reproducible via network or also if you read a file?

comment:2 by burek, 14 years ago

Did you even read the text above your comment? :)

comment:3 by reimar, 14 years ago

There is nothing in your text that would explain why you used udp:// in your example, so the question whether this is only relevant to udp streams or not is justified.
Answer: no, any TS stream with program ids should work the same, and e.g. the sample from ticket 531 works fine.
However you should provide a smaller sample for people to test.
Also, this should not be some TS specific option, it should work for all containers where FFmpeg supports a concept of a "program" (I think it does for Matroska at least), and maybe an option to select it by number should be implemented first.

comment:4 by Michael Niedermayer, 13 years ago

Resolution: fixed
Status: newclosed

-map 0:p:1318 will for example pick the program, 1318

comment:5 by Michael Niedermayer, 13 years ago

PS: note, iam not sure this was actually implemented after the ticket was opened or if this was already supported before

comment:6 by Roger Pack, 10 years ago

Is there any ability to select by name? For instance "service_name : Canal Algerie" might be nice, though mapping to pid is quite possible

comment:7 by Roger Pack, 10 years ago

To answer my own question, appears not, however by using the "program id" or "PID" you can stll pretty well specify what you want, more here: https://trac.ffmpeg.org/wiki/Map

Note: See TracTickets for help on using tickets.