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?
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 '19 at 11:58 -
-
'to be able to copy and paste it directly': Do you want move files to another dir based on framerate? – Yasen Aug 3 '19 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 '19 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 '19 at 18:00