![]() □ If your answer is YES!, consider becoming a Python freelance developer! It’s the best way of approaching the task of improving your Python skills-even if you are a complete beginner. You build high-value coding skills by working on practical coding projects!ĭo you want to stop learning with toy projects and focus on practical code projects that earn you money and solve real problems for people? After all, what’s the use of learning theory that nobody ever needs? That’s how you polish the skills you really need in practice. To become more successful in coding, solve more real problems for real people. Video = cv2.VideoCapture('my_video.webm')ĭuration = video.get(cv2.CAP_PROP_POS_MSEC) Where to Go From Here?Ĭoders get paid six figures and more because they can solve problems more effectively using machine intelligence and automation. One of the fastest method to retrieve the duration of a video is provided by the opencv module: import cv2 This code is obtained from here and here. Method 3: Using the pymediainfo ModuleĪn alternative to the previous method is provided by the pymediainfo library: from pymediainfo import MediaInfoĬlip_info = MediaInfo.parse('my_video.mov')ĭuration_ms = clip_ However, it is reported that method 1 with ffprobe is 10x faster than the method with moviepy. This code is even more concise-and it retrieves the duration of a given video very quickly using the moviepymodule. You can download ffprobe for Windows, macOS, and Linux here. "default=noprint_wrappers=1:nokey=1", filename], “ffprobe gathers information from multimedia streams and prints it in human- and machine-readable fashion.” import subprocess The external tool ffprobe helps you determine many video statistics such as the length of the video. Within your Python shell, you can run any external command with the module subprocess. The video can have any of the following video formats: How to get its duration in seconds using Python code?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |