get video fps using FFProbe

天涯浪子 提交于 2019-12-22 08:12:23

问题


I am new in ffprobe my aim is get video fps and store into java program. my code store xml files but i want store directly like int fps=30;

ffprobe -v quiet -print_format xml -show_format -show_streams "/video/small/small.avi" > "/video/small/test.xml"

this is my code.


回答1:


This will print the video FPS:

ffprobe -v error -select_streams v -of default=noprint_wrappers=1:nokey=1 -show_entries stream=r_frame_rate file.mp4



回答2:


I found calculate fps in another method that is..

String query = "ffmpeg -i foo.avi 2>&1 | sed -n 's/.*, \\(.*\\) fp.*/\\1/p' > fps.txt";
    String[] command = {"gnome-terminal", "-x", "/bin/sh", "-c", query};
    Process process = Runtime.getRuntime().exec(command);
    process.waitFor();
    Thread.sleep(2000);
    try {
        BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("fps.txt")));
        output = br.readLine();
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }

Anyway thanks friends.



来源:https://stackoverflow.com/questions/27792934/get-video-fps-using-ffprobe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!