Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
422f0a61
Commit
422f0a61
authored
Nov 10, 2019
by
Marton Balint
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat/mpegtsenc: use standard pids for m2ts
Signed-off-by:
Marton Balint
<
cus@passwd.hu
>
parent
561ba15c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
3 deletions
+57
-3
muxers.texi
doc/muxers.texi
+4
-2
mpegts.h
libavformat/mpegts.h
+10
-0
mpegtsenc.c
libavformat/mpegtsenc.c
+43
-1
No files found.
doc/muxers.texi
View file @
422f0a61
...
@@ -1660,11 +1660,13 @@ Advanced Codec Digital HDTV service.
...
@@ -1660,11 +1660,13 @@ Advanced Codec Digital HDTV service.
@item mpegts_pmt_start_pid @var{integer}
@item mpegts_pmt_start_pid @var{integer}
Set the first PID for PMTs. Default is @code{0x1000}, minimum is @code{0x0020},
Set the first PID for PMTs. Default is @code{0x1000}, minimum is @code{0x0020},
maximum is @code{0x1ffa}.
maximum is @code{0x1ffa}. This option has no effect in m2ts mode where the PMT
PID is fixed @code{0x0100}.
@item mpegts_start_pid @var{integer}
@item mpegts_start_pid @var{integer}
Set the first PID for elementary streams. Default is @code{0x0100}, minimum is
Set the first PID for elementary streams. Default is @code{0x0100}, minimum is
@code{0x0020}, maximum is @code{0x1ffa}.
@code{0x0020}, maximum is @code{0x1ffa}. This option has no effect in m2ts mode
where the elementary stream PIDs are fixed.
@item mpegts_m2ts_mode @var{boolean}
@item mpegts_m2ts_mode @var{boolean}
Enable m2ts mode if set to @code{1}. Default value is @code{-1} which
Enable m2ts mode if set to @code{1}. Default value is @code{-1} which
...
...
libavformat/mpegts.h
View file @
422f0a61
...
@@ -65,6 +65,16 @@
...
@@ -65,6 +65,16 @@
* streams and other data tables */
* streams and other data tables */
#define NULL_PID 0x1FFF
/* Null packet (used for fixed bandwidth padding) */
#define NULL_PID 0x1FFF
/* Null packet (used for fixed bandwidth padding) */
/* m2ts pids */
#define M2TS_PMT_PID 0x0100
#define M2TS_PCR_PID 0x1001
#define M2TS_VIDEO_PID 0x1011
#define M2TS_AUDIO_START_PID 0x1100
#define M2TS_PGSSUB_START_PID 0x1200
#define M2TS_TEXTSUB_PID 0x1800
#define M2TS_SECONDARY_AUDIO_START_PID 0x1A00
#define M2TS_SECONDARY_VIDEO_START_PID 0x1B00
/* table ids */
/* table ids */
#define PAT_TID 0x00
/* Program Association section */
#define PAT_TID 0x00
/* Program Association section */
#define CAT_TID 0x01
/* Conditional Access section */
#define CAT_TID 0x01
/* Conditional Access section */
...
...
libavformat/mpegtsenc.c
View file @
422f0a61
...
@@ -94,6 +94,10 @@ typedef struct MpegTSWrite {
...
@@ -94,6 +94,10 @@ typedef struct MpegTSWrite {
int
pmt_start_pid
;
int
pmt_start_pid
;
int
start_pid
;
int
start_pid
;
int
m2ts_mode
;
int
m2ts_mode
;
int
m2ts_video_pid
;
int
m2ts_audio_pid
;
int
m2ts_pgssub_pid
;
int
m2ts_textsub_pid
;
int
pcr_period_ms
;
int
pcr_period_ms
;
#define MPEGTS_FLAG_REEMIT_PAT_PMT 0x01
#define MPEGTS_FLAG_REEMIT_PAT_PMT 0x01
...
@@ -860,6 +864,14 @@ static int mpegts_init(AVFormatContext *s)
...
@@ -860,6 +864,14 @@ static int mpegts_init(AVFormatContext *s)
}
}
}
}
ts
->
m2ts_video_pid
=
M2TS_VIDEO_PID
;
ts
->
m2ts_audio_pid
=
M2TS_AUDIO_START_PID
;
ts
->
m2ts_pgssub_pid
=
M2TS_PGSSUB_START_PID
;
ts
->
m2ts_textsub_pid
=
M2TS_TEXTSUB_PID
;
if
(
ts
->
m2ts_mode
)
ts
->
pmt_start_pid
=
M2TS_PMT_PID
;
if
(
s
->
max_delay
<
0
)
/* Not set by the caller */
if
(
s
->
max_delay
<
0
)
/* Not set by the caller */
s
->
max_delay
=
0
;
s
->
max_delay
=
0
;
...
@@ -923,7 +935,37 @@ static int mpegts_init(AVFormatContext *s)
...
@@ -923,7 +935,37 @@ static int mpegts_init(AVFormatContext *s)
/* MPEG pid values < 16 are reserved. Applications which set st->id in
/* MPEG pid values < 16 are reserved. Applications which set st->id in
* this range are assigned a calculated pid. */
* this range are assigned a calculated pid. */
if
(
st
->
id
<
16
)
{
if
(
st
->
id
<
16
)
{
if
(
ts
->
m2ts_mode
)
{
switch
(
st
->
codecpar
->
codec_type
)
{
case
AVMEDIA_TYPE_VIDEO
:
ts_st
->
pid
=
ts
->
m2ts_video_pid
++
;
break
;
case
AVMEDIA_TYPE_AUDIO
:
ts_st
->
pid
=
ts
->
m2ts_audio_pid
++
;
break
;
case
AVMEDIA_TYPE_SUBTITLE
:
switch
(
st
->
codecpar
->
codec_id
)
{
case
AV_CODEC_ID_HDMV_PGS_SUBTITLE
:
ts_st
->
pid
=
ts
->
m2ts_pgssub_pid
++
;
break
;
case
AV_CODEC_ID_HDMV_TEXT_SUBTITLE
:
ts_st
->
pid
=
ts
->
m2ts_textsub_pid
++
;
break
;
}
break
;
}
if
(
ts
->
m2ts_video_pid
>
M2TS_VIDEO_PID
+
1
||
ts
->
m2ts_audio_pid
>
M2TS_AUDIO_START_PID
+
32
||
ts
->
m2ts_pgssub_pid
>
M2TS_PGSSUB_START_PID
+
32
||
ts
->
m2ts_textsub_pid
>
M2TS_TEXTSUB_PID
+
1
||
ts_st
->
pid
<
16
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Cannot automatically assign PID for stream %d
\n
"
,
st
->
index
);
ret
=
AVERROR
(
EINVAL
);
goto
fail
;
}
}
else
{
ts_st
->
pid
=
ts
->
start_pid
+
i
;
ts_st
->
pid
=
ts
->
start_pid
+
i
;
}
}
else
{
}
else
{
ts_st
->
pid
=
st
->
id
;
ts_st
->
pid
=
st
->
id
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment