Trying to create Transport Stream (mpegts) having multiple programs embedded

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Trying to create Transport Stream (mpegts) having multiple programs embedded

Kilian

FFMPEG:
 
I can not find how to make a transport stream to contain multiple programs. I can make one program having 3 videos and 3 audios but this a standard TS file. I can't figure out how to make input file a separated programs with the TS file. Please advise. Thanks.
 
Attachment: Simple shell script to create TS file from multiple MPEG files.
 
 - Steve
 
============================================================================
Command and output:
 
bin/ffmpeg.exe -i ../video-input/Finding-Nemo-full.mpeg -i ../video-input/Shane.mpeg -i ../video-input/avatar-wide.mpeg -vcodec copy -acodec copy -map 0:v -map 0:6 -vcodec copy -acodec copy -map 1:v -map 1:1 -vcodec copy -acodec copy -map 2:v -map 2:9 -y -t 10 -f mpegts z-output.ts

ffmpeg version N-35509-gfd36cbf-Sherpya, Copyright (c) 2000-2011 the FFmpeg developers
  built on Dec  7 2011 06:17:11 with gcc 4.6.2
  libavutil    51. 30. 0 / 51. 30. 0
  libavcodec   53. 41. 0 / 53. 41. 0
  libavformat  53. 24. 0 / 53. 24. 0
  libavdevice  53.  4. 0 / 53.  4. 0
  libavfilter   2. 51. 0 /  2. 51. 0
  libswscale    2.  1. 0 /  2.  1. 0
  libpostproc  51.  2. 0 / 51.  2. 0
[mpeg @ 01dba180] max_analyze_duration 5000000 reached at 5021478
Seems stream 0 codec frame rate differs from container frame rate: 59.94 (60000/1001) -> 59.94 (60000/1001)
Input #0, mpeg, from '../video-input/Finding-Nemo-full.mpeg':
  Duration: 00:07:28.57, start: 0.280633, bitrate: 74095 kb/s
    Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [SAR 8:9 DAR 4:3], 9800 kb/s, 26.29 fps, 59.94 tbr, 9
0k tbn, 59.94 tbc
    Stream #0:1[0x20]: Subtitle: dvd_subtitle
    Stream #0:2[0x21]: Subtitle: dvd_subtitle
    Stream #0:3[0x22]: Subtitle: dvd_subtitle
    Stream #0:4[0x23]: Subtitle: dvd_subtitle
    Stream #0:5[0x24]: Subtitle: dvd_subtitle
    Stream #0:6[0x80]: Audio: ac3, 48000 Hz, 5.1(side), s16, 448 kb/s
    Stream #0:7[0x81]: Audio: ac3, 48000 Hz, 5.1(side), s16, 384 kb/s
    Stream #0:8[0x82]: Audio: ac3, 48000 Hz, 5.1(side), s16, 384 kb/s
Seems stream 0 codec frame rate differs from container frame rate: 59.94 (60000/1001) -> 59.94 (60000/1001)
Input #1, mpeg, from '../video-input/Shane.mpeg':
  Duration: 00:00:06.66, start: 0.196500, bitrate: -2147483 kb/s
    Stream #1:0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [SAR 8:9 DAR 4:3], 9800 kb/s, 23.98 fps, 59.94 tbr, 9
0k tbn, 59.94 tbc
    Stream #1:1[0x80]: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s
    Stream #1:2[0x81]: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s
    Stream #1:3[0x82]: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s
[mpeg @ 01f01000] max_analyze_duration 5000000 reached at 5004667
Seems stream 0 codec frame rate differs from container frame rate: 59.94 (60000/1001) -> 59.94 (60000/1001)
Input #2, mpeg, from '../video-input/avatar-wide.mpeg':
  Duration: 01:26:31.00, start: 0.199156, bitrate: 12074 kb/s
    Stream #2:0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [SAR 32:27 DAR 16:9], 9800 kb/s, 23.98 fps, 59.94 tbr
, 90k tbn, 59.94 tbc
    Stream #2:1[0x20]: Subtitle: dvd_subtitle
    Stream #2:2[0x21]: Subtitle: dvd_subtitle
    Stream #2:3[0x22]: Subtitle: dvd_subtitle
    Stream #2:4[0x23]: Subtitle: dvd_subtitle
    Stream #2:5[0x24]: Subtitle: dvd_subtitle
    Stream #2:6[0x25]: Subtitle: dvd_subtitle
    Stream #2:7[0x26]: Subtitle: dvd_subtitle
    Stream #2:8[0x27]: Subtitle: dvd_subtitle
    Stream #2:9[0x80]: Audio: ac3, 48000 Hz, 5.1(side), s16, 448 kb/s
    Stream #2:10[0x81]: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s
    Stream #2:11[0x82]: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s
    Stream #2:12[0x83]: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s
[mpegts @ 021fdb00] muxrate VBR, pcr every 2 pkts, sdt every 200, pat/pmt every 40 pkts
Output #0, mpegts, to 'z-output.ts':
  Metadata:
    encoder         : Lavf53.24.0
    Stream #0:0: Video: mpeg2video, yuv420p, 720x480 [SAR 8:9 DAR 4:3], q=2-31, 9800 kb/s, 26.29 fps, 90k tbn, 29.97 tbc
    Stream #0:1: Audio: ac3, 48000 Hz, 5.1(side), 448 kb/s
    Stream #0:2: Video: mpeg2video, yuv420p, 720x480 [SAR 8:9 DAR 4:3], q=2-31, 9800 kb/s, 23.98 fps, 90k tbn, 29.97 tbc
    Stream #0:3: Audio: ac3, 48000 Hz, stereo, 192 kb/s
    Stream #0:4: Video: mpeg2video, yuv420p, 720x480 [SAR 32:27 DAR 16:9], q=2-31, 9800 kb/s, 23.98 fps, 90k tbn, 29.97
tbc
    Stream #0:5: Audio: ac3, 48000 Hz, 5.1(side), 448 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:6 -> #0:1 (copy)
  Stream #1:0 -> #0:2 (copy)
  Stream #1:1 -> #0:3 (copy)
  Stream #2:0 -> #0:4 (copy)
  Stream #2:9 -> #0:5 (copy)
Press [q] to stop, [?] for help
frame=  253 fps=  0 q=-1.0 Lq=-1.0 q=-1.0 size=   26945kB time=00:00:09.99 bitrate=22088.3kbits/s
video:23553kB audio:1330kB global headers:0kB muxing overhead 8.287893%
 
 
============================================================================
ffmpeg version N-35509-gfd36cbf-Sherpya, Copyright (c) 2000-2011 the FFmpeg developers
  built on Dec  7 2011 06:17:11 with gcc 4.6.2
  libavutil    51. 30. 0 / 51. 30. 0
  libavcodec   53. 41. 0 / 53. 41. 0
  libavformat  53. 24. 0 / 53. 24. 0
  libavdevice  53.  4. 0 / 53.  4. 0
  libavfilter   2. 51. 0 /  2. 51. 0
  libswscale    2.  1. 0 /  2.  1. 0
  libpostproc  51.  2. 0 / 51.  2. 0
Seems stream 0 codec frame rate differs from container frame rate: 59.94 (60000/1001) -> 59.94 (60000/1001)
Seems stream 2 codec frame rate differs from container frame rate: 59.94 (60000/1001) -> 59.94 (60000/1001)
Seems stream 4 codec frame rate differs from container frame rate: 59.94 (60000/1001) -> 59.94 (60000/1001)
Input #0, mpegts, from 'z-output.ts':
  Duration: 00:00:09.98, start: 1.400000, bitrate: 22108 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 720x480 [SAR 8:9 DAR 4:3], 9800 kb/s,
 28.72 fps, 59.94 tbr, 90k tbn, 59.94 tbc
    Stream #0:1[0x101]: Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, 5.1(side), s16, 448 kb/s
    Stream #0:2[0x102]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 720x480 [SAR 8:9 DAR 4:3], 9800 kb/s,
 23.89 fps, 59.94 tbr, 90k tbn, 59.94 tbc
    Stream #0:3[0x103]: Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, stereo, s16, 192 kb/s
    Stream #0:4[0x104]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 720x480 [SAR 32:27 DAR 16:9], 9800 kb
/s, 24.06 fps, 59.94 tbr, 90k tbn, 59.94 tbc
    Stream #0:5[0x105]: Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, 5.1(side), s16, 448 kb/s
At least one output file must be specified

 
==============================================================================
==============================================================================
==============================================================================
Example of TS file having multiple programs:
 
$ bin/ffmpeg.exe -i WUSF-11-16-2002-5pm.trp
ffmpeg version N-35509-gfd36cbf-Sherpya, Copyright (c) 2000-2011 the FFmpeg developers
  built on Dec  7 2011 06:17:11 with gcc 4.6.2
  libavutil    51. 30. 0 / 51. 30. 0
  libavcodec   53. 41. 0 / 53. 41. 0
  libavformat  53. 24. 0 / 53. 24. 0
  libavdevice  53.  4. 0 / 53.  4. 0
  libavfilter   2. 51. 0 /  2. 51. 0
  libswscale    2.  1. 0 /  2.  1. 0
  libpostproc  51.  2. 0 / 51.  2. 0
 
Input #0, mpegts, from 'WUSF-11-16-2002-5pm.trp':
  Duration: 00:04:13.46, start: 64449.029144, bitrate: 19353 kb/s
  Program 6
    Stream #0:2[0x61]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 704x480 [SAR 10:11 DAR 4:3], 15000 kb/
s, 39.41 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:3[0x64](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, s16, 192 kb/s
    Stream #0:4[0x65](spa): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, mono, s16, 64 kb/s (visual impaired)
  Program 5
    Stream #0:0[0x51]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 704x480 [SAR 10:11 DAR 4:3], 15000 kb/
s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:1[0x54](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, s16, 192 kb/s
  Program 4
    Stream #0:9[0x41]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 704x480 [SAR 10:11 DAR 4:3], 15000 kb/
s, 36.51 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:6[0x44](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, s16, 192 kb/s
    Stream #0:8[0x45](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, mono, s16, 96 kb/s
  Program 3
    Stream #0:7[0x31]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 704x480 [SAR 10:11 DAR 4:3], 15000 kb/
s, 35.96 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:5[0x34](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, s16, 192 kb/s
  No Program
    Stream #0:10[0x55]: Audio: ac3, 48000 Hz, mono, s16, 96 kb/s
    Stream #0:11[0x35]: Audio: ac3, 48000 Hz, mono, s16, 96 kb/s    
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

0-make-transport-stream.sh (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Trying to create Transport Stream (mpegts) having multiple programs embedded

Andrey Utkin
2012/4/6 S Kilian <[hidden email]>:
>
> FFMPEG:
>
> I can not find how to make a transport stream to contain multiple programs. I can make one program having 3 videos and 3 audios but this a standard TS file. I can't figure out how to make input file a separated programs with the TS file. Please advise. Thanks.

In AVFormatContext there's AVProgram* array for that.
But it looks mpegts muxer does not use it, it is used only in demuxer.
So IMO you can't do it with ffmpeg (both utility and API) currently.

--
Andrey Utkin
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Trying to create Transport Stream (mpegts) having multiple programs embedded

Henk D. Schoneveld
In reply to this post by Kilian
This part:
  Stream #1:0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [SAR 8:9 DAR 4:3], 9800 kb/s, 23.98 fps, 59.94 tbr, 9
0k tbn, 59.94 tbc

Says it afaik. Your video-streams have different frame-rates and can't be in the same ts afaik.

On Apr 6, 2012, at 6:01 AM, S Kilian <[hidden email]> wrote:

>   Stream #1:0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [SAR 8:9 DAR 4:3], 9800 kb/s, 23.98 fps, 59.94 tbr, 9
> 0k tbn, 59.94 tbc
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Trying to create Transport Stream (mpegts) having multiple programs embedded

Kilian

 
Henk,
 
Oh thanks. I was to focused on the getting the service id to index. Change my -vcodec from "copy" to "mpeg2video -r 30000/1001" so the frame rates would be proper.
 
I wonder how difficult it would be to index the service ID when it encounters a new video stream.

 - Steve
 
 
Command:
bin/ffmpeg.exe -i ../video-input/Finding-Nemo-full.mpeg -i ../video-input/Shane.mpeg -i ../video-input/avatar-wide.mpeg \
-vcodec mpeg2video -r 30000/1001 -acodec copy -map 0:v -map 0:6 \
-vcodec mpeg2video -r 30000/1001 -acodec copy -map 1:v -map 1:1 \
-vcodec mpeg2video -r 30000/1001 -acodec copy -map 2:v -map 2:9 \
-y -t 12 -mpegts_service_id 3 -muxrate 19392636 -f mpegts z-output.ts
 
 
Result:
bin/ffmpeg.exe -i z-output.ts
Input #0, mpegts, from 'z-output.ts':
  Duration: 00:00:11.97, start: 1.400000, bitrate: 19379 kb/s
  Program 3
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 720x480 [SAR 8:9 DAR 4:3], 104857 kb/
s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:1[0x101]: Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, 5.1(side), s16, 448 kb/s
 
<<< this is where Program 4 should be >>>

    Stream #0:2[0x102]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 720x480 [SAR 8:9 DAR 4:3], 104857 kb/
s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:3[0x103]: Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, stereo, s16, 192 kb/s
 
<<< this is where Program 5 should be >>>

    Stream #0:4[0x104]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 720x480 [SAR 32:27 DAR 16:9], 104857
kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:5[0x105]: Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, 5.1(side), s16, 448 kb/s
 


>
> This part:
> Stream #1:0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [SAR 8:9 DAR 4:3], 9800 kb/s, 23.98 fps, 59.94 tbr, 9
> 0k tbn, 59.94 tbc
>
> Says it afaik. Your video-streams have different frame-rates and can't be in the same ts afaik.
>
> On Apr 6, 2012, at 6:01 AM, S Kilian <[hidden email]> wrote:
>
> > Stream #1:0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [SAR 8:9 DAR 4:3], 9800 kb/s, 23.98 fps, 59.94 tbr, 9
> > 0k tbn, 59.94 tbc
>    
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user