Recursive (Into subdirectories) ffmpeg generate jpg from video


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Recursive (Into subdirectories) ffmpeg generate jpg from video
# 1  
Old 10-27-2016
Recursive (Into subdirectories) ffmpeg generate jpg from video

My question is how to modify my existing script to generate from videos (mp4,avi,mkv etc...) jpegs via ffmpeg and keep folder name of generated jpg file?

So if i have video in /home/videos/MyParty2009/SOmeDirR/VideoSomeTitle.mp4

and it will generate jpg with name of MyParty2009.jpg so the name is the third slash from path /home/videos/ and name ending with fourth slash, see /home/videos/MyParty2009/SOmeDirR/VideoSomeTitle.mp4

MyParty2009 is just sub-dir not main dir.
In /home/videos/ are all subdirs

Then all jpgs generated hould be saved to /home/jpgs/

Also if the name of jpg already exist in /home/jpgs/ do not run ffmpeg cmd just skip it

Code:
#!/bin/bash

for i in `find /home/videos/ -name "*.mp4" -print0| xargs -0`; do ffmpeg -loglevel panic -y -i "$i" -frames 1 -q:v 5 -vf "select=not(mod(n\,400)),scale=-1:250,tile=3x2" "${i%}.jpg"; echo "$i";done

Thx for help!

Smilie

Last edited by ZerO13; 10-27-2016 at 09:43 AM..
# 2  
Old 10-27-2016
Breaking this up for clarity, you have this:-
Code:
#!/bin/bash

for i in `find /home/videos/ -name "*.mp4" -print0 | xargs -0`
do
   ffmpeg -loglevel panic -y -i "$i" -frames 1 -q:v 5 -vf "select=not(mod(n\,400)),scale=-1:250,tile=3x2" "${i%}.jpg"
   echo "$i"
done

If you want to extract the section of the name you are after, you could do something based on this:-
Code:
#!/bin/bash

for i in `find /home/videos/ -name "*.mp4" -print0 | xargs -0`
do
   ffmpeg -loglevel panic -y -i "$i" -frames 1 -q:v 5 -vf "select=not(mod(n\,400)),scale=-1:250,tile=3x2" "${i%}.jpg"
   echo "$i"
   echo "You are starting with ${i}"
   i="${i#/home/videos/}"
   echo "You have removed the leading /home/videos to leave you with ${i}"
   i="${i%/*}"
   echo "You have removed everything after the next slash to leave you with ${i}"
done


Does that help?


Robin
This User Gave Thanks to rbatte1 For This Post:
# 3  
Old 10-27-2016
Yes, thx so much! Now i find a way to work with that thx again! Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Ffmpeg (avconv) + crtmpserver Linux streaming video, no player to play it

Hello Linux experts, I'm working on live video streaming project, and my job is to create video streaming server using Ubuntu 13.04 Here is what I've done so far: 1. Installed crtmpserver from Ubuntu's repositories. 2. Installed ffmpeg To test the server i use webcam as source of video,... (0 Replies)
Discussion started by: +Yan
0 Replies

2. UNIX for Dummies Questions & Answers

recursive copy into a directory and all its subdirectories...

I want to copy a file from the top directory into all the sub-folders and all of the sub-folders of those sub-folder etc. Does anyone have any idea how to do this? Thanks in advance of any help you can give. (3 Replies)
Discussion started by: EinsteinMcfly
3 Replies

3. UNIX for Advanced & Expert Users

trim 165 MB video clip with ffmpeg (only last 3 minutes)

Hi original video clip > ls -alh reallynotpr0n.flv -rw-r--r-- 1 jonny staff 165M Nov 18 19:57 reallynotpr0n.flvtrying to cut only last 3 minutes of the clip out. > ffmpeg -i reallynotpr0n.flv -vcodec copy -acodec copy -ss 00:52:00 -t 00:03:48 trimmed_video.avi ffmpeg version 0.7.7,... (3 Replies)
Discussion started by: slashdotweenie
3 Replies

4. Shell Programming and Scripting

Rename all ".JPG" files to ".jpg" under all subfolders...

Hi, Dear all: One question ! ^_^ I'm using bash under Ubuntu 9.10. My question is not to rename all ".JPG" files to ".jpg" in a single folder, but to rename all ".JPG" files to ".jpg" in all subfolders. To rename all ".JPG" to ".jpg" in a single folder, for x in *.JPG; do mv "$x"... (7 Replies)
Discussion started by: jiapei100
7 Replies

5. UNIX for Dummies Questions & Answers

Touch all files and subdirectories (recursive touch)

I have a folder with many subdirectories and i need to set the modified date to today for everything in it. Please help, thanks! I tried something i found online, find . -print0 | xargs -r0 touch but I got the error: xargs: illegal option -- r (5 Replies)
Discussion started by: glev2005
5 Replies

6. AIX

recursive archive directories and subdirectories

Hi everyone, Maybe this is simple question for many of you, but I get confused.:confused: How to archive a parent directory which contains some subdirectories and some files? I have searched this forum, there are some commands like tar,etc, I tried but can not be implemented in my system.... (6 Replies)
Discussion started by: wilsonSurya
6 Replies

7. OS X (Apple)

Video grab using ffmpeg?

Does anyone know how to grab video (screen) on Terminal using ffmpeg (not X11). I have written a unix library and I'd like to make a short movie (demo) of it. Tried: I already own SNapz Pro2 but it hangs the system (I have an old Powerbook 15" PPC). I guess my system is too slow for version... (0 Replies)
Discussion started by: sentinel
0 Replies
Login or Register to Ask a Question