[FFmpeg-user] Copying MP4 Stream
Rainer Dorsch
ml at bokomoko.de
Sun Nov 22 12:40:40 EET 2020
Hi,
I am recording an MP4 stream using
ffmpeg -i rtsp:///Streaming/Channels/1 -r 20 -vcodec copy -an -t 3600 name.mp4
The first few seconds are always garbage. I assume because there is no keyframe
in the stream, right when the recording starts. Recoding with -vcodec libx264
does not show the problem, but the CPU it consumes it too high. I cannot tell
if it does not have the problem, because it somehow manages to convince the
codec of the camera to send a keyframe or if it just finds out which frames to
discard.
What is somewhat strange is that the output of
ffprobe -show_frames test-c3.mp4|grep key_frame|pastebinit
shows always keyframes at the beginning:
key_frame=1
key_frame=0
key_frame=1
key_frame=0
key_frame=1
key_frame=0
key_frame=0
key_frame=0
[...]
key_frame=0
key_frame=1
[...]
Here is the full output (w/o the grep):
http://bokomoko.de/~rd/out.log
Assuming that the missing key frame is the problem in the copy mode, can I
rather somehow discard the frames until the first real keyframe arrives in the
mp4 stream (in the copy mode)?
Is there a way to strip of the initial garbage of existing videos?
Would determining the first frame with key_frame=1 with coded_picture_number>10
in
ffprobe -show_frames test-c3.mp4
e.g.
[FRAME]
media_type=video
stream_index=0
key_frame=1
pkt_pts=142848
pkt_pts_time=13.950000
pkt_dts=142848
pkt_dts_time=13.950000
best_effort_timestamp=142848
best_effort_timestamp_time=13.950000
pkt_duration=512
pkt_duration_time=0.050000
pkt_pos=2091273
pkt_size=554015
width=2688
height=1520
pix_fmt=yuvj420p
sample_aspect_ratio=N/A
pict_type=I
coded_picture_number=285
display_picture_number=0
interlaced_frame=0
top_field_first=0
repeat_pict=0
color_range=pc
color_space=bt709
color_primaries=bt709
color_transfer=bt709
chroma_location=left
[/FRAME]
and use in there
coded_picture_number=285
and throw away the first 285 frames (since it starts with
coded_picture_number=0) ?
Many thanks
Rainer
--
Rainer Dorsch
http://bokomoko.de/
More information about the ffmpeg-user
mailing list