0

I need to separate my mp4 files into p30 and p60 and would like to use command line tools to do this. I know that there is an option to check the details of a media file and I need to do this as a batch. Any ideas?

1

You can use ffprobe for get video frame rate.

Install: apt install ffmpeg

Usage for 1 file:

ffprobe -v error -select_streams \
v -of default=noprint_wrappers=1:nokey=1 \
-show_entries stream=r_frame_rate <your-filename>.mp4

Get filenames and framerates in batch for all videos in current dir (divided by \t):

for videofile in *.mp4; do
 echo -n "$videofile\t"
 ffprobe -v error -select_streams v \
 -of default=noprint_wrappers=1:nokey=1 \
 -show_entries stream=r_frame_rate $videofile

Get filenames and framerates in batch for all videos in current dir and subdirs using find:

find -name '*.mp4' -printf '%p\t' \
-exec ffprobe -v error -select_streams \
v -of default=noprint_wrappers=1:nokey=1  \
-show_entries stream=r_frame_rate {} \;
  • The second option is to be used in a skript.sh file? Also, would it make sense to remove the `` to be able to copy and paste it directly? – Ben Aug 3 at 11:58
  • When using the third option I get Missing argument for -exec. – Ben Aug 3 at 12:01
  • 'to be able to copy and paste it directly': Do you want move files to another dir based on framerate? – Yasen Aug 3 at 13:45
  • No, I mean to be able to copy and paste your code directly into command line. With the *\* it seems not possible. (I recognised that the sign I was referring to was not displayed in my first comment.) Please also check my second comment regarding the error. Thanks! – Ben Aug 3 at 15:09
  • Try this code. Single line without wraps. find -name '*.mp4' -printf '%p\t' -exec ffprobe -v error -select_streams v -of default=noprint_wrappers=1:nokey=1 -show_entries stream=r_frame_rate {} \; – Yasen Aug 3 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.