python – convert video ffmpeg to specific format
I have video file
Duration: 00:19:36.69, start: 48891.159489, bitrate: 7234 kb/s
Stream #0:0[0x1e0]: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 3840×2160, 20 fps, 20.08 tbr, 90k tbn, 40 tbc
I converted video in python by iterate frame by frame:
vid_cap = cv2.VideoCapture(video_path)
fps = vid_cap.get(cv2.CAP_PROP_FPS)
w = int(vid_cap.get(cv2.CAP_PROP_FRAME_WIDTH))
h = int(vid_cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
vid_writer = cv2.VideoWriter(vid_full_path, cv2.VideoWriter_fourcc(*'mp4v'), fps, (w, h))
vid_cap = cv2.VideoCapture(video_path)
flag, im0 = vid_cap.read()
while flag:
vid_writer.write(im0)
flag, im0 = vid_cap.read()
vid_writer.release()
the output details file :
Duration: 00:19:38.85, start: 0.000000, bitrate: 43718 kb/s
Stream #0:0(und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 3840×2160 [SAR 1:1 DAR 16:9], 43717 kb/s, 20
fps, 20 tbr, 10240 tbn, 20 tbc (default)
Metadata:
handler_name : VideoHandler
I try use ffmpeg to convert the video to mp4 by still I don’t get the same video file.
there is any option to create this specific converted video by ffmpeg, without loop?
Read more here: Source link