linux - Bash script to convert imgs in subfolders to video (using ffmpeg and Ubuntu) -


i'm trying convert files in folders given

 allfolders.txt > head foldernames.txt 0001  0002  0003  0004  0005  ... 

to video using ffmpeg

ffmpeg version 2.2.3 copyright (c) 2000-2014 ffmpeg developers  built on apr 20 2015 13:38:52 gcc 4.8 (ubuntu 4.8.2-19ubuntu1) configuration: --prefix=/home/myusername/usr/local --enable-nonfree --enable-gpl --enable-pic --enable-shared --enable-libx264 --disable-vaapi 

according answers here on stackoverflow wrote following bash script:

#!/bin/bash while read p;     cd "$p"     ffmpeg -f concat -i "allimgnames.txt" -framerate 30 -c:v libx264 -profile:v high -crf 20 -pix_fmt yuv420p output.mp4     cd - done < foldernames.txt 

where allimgnames.txt text file containing image names.

the strange thing works few videos rest of filelist fails saying allimgnames.txt: no such file or directory, not true. checked paths several times. can execute ffmpeg ... command above manually without problems. don't know i'm doing wrong. file / folder names normal (no special characters). maybe don't understand enough bash or ffmpeg.

add logic in script ensure files/folders exist before gets executed. debug issues along way.

if folder paths not relative, help

while read p;     [ -d "$p" ] && cd "$p" || echo "folder $p not found"     [ -f "allimgnames.txt" ] && ffmpeg -f concat -i "allimgnames.txt" -framerate 30 -c:v libx264 -profile:v high -crf 20 -pix_fmt yuv420p output.mp4 || echo "$p/allimgnames.txt not found"     [ -d "$p" ] && cd - done < foldernames.txt 

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -