H
H
Hocok_B_KapMaHe2014-06-25 19:31:10
Video
Hocok_B_KapMaHe, 2014-06-25 19:31:10

How to multiplex h264 video to mpeg-ts without knowing anything about video parameters?

Good day!
I want to write my h264 muxer to mpeg-ts without any external libraries
(only video (h264->mpeg-ts), - no audio).
What is mpeg-ts - I'm slowly understanding (but it's very difficult), some things are incomprehensible:
Is it possible to pack a video into an mpeg-ts container without knowing anything about it?
Well, I want to do this:
the first header comes with PAT, then PMT, then the header with pure h264 payload .. After 40 packets again PAT / PMT, etc.?
But then I ran into an Adaptation Field in which you need to write pts and dts. Where to take them from? Are they heavily dependent on the original video that is currently being packed into this container?
Or is it a purely transport thing that does not depend on the codec and can be generated on the fly, for example, on a streaming server?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
Hocok_B_KapMaHe, 2014-06-25
@Hocok_B_KapMaHe

So, I read here that DTS is only needed if there are B-frames in the video. In this case, I have a video without B-frames, so the issue with DTS has been resolved for now. It remains to put down the TCP.
I played around with ffprobe + ffmpeg, and so:
I encode the file into pure h264 without audio and B-frames:
Now I look at the resulting file through ffprobe:

[FRAME]
media_type=video
key_frame=0
pkt_pts=N/A
pkt_pts_time=N/A
pkt_dts=N/A
pkt_dts_time=N/A
best_effort_timestamp=N/A
best_effort_timestamp_time=N/A
pkt_duration=48000
pkt_duration_time=0.040000
pkt_pos=929
pkt_size=29
width=640
height=360
pix_fmt=yuv420p
sample_aspect_ratio=1:1
pict_type=P
coded_picture_number=2
display_picture_number=0
interlaced_frame=0
top_field_first=0
repeat_pict=0
[/FRAME]

It can be seen that PTS is simply unknown
pkt_pts=N/A
pkt_pts_time=N/A
pkt_dts=N/A
pkt_dts_time=N/A
But with the command:
I get a normal TS file, and with PTS affixed.
Where did he (ffmpeg) get it from? How to put it down?
Based on what? Or is there some kind of standard like "increases by N after N packets"?
PTS: 126000 - first package
PTS: 129600 - seventh package
PTS: 133200 - eighth package
....

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question