2

I have files named like alice.png, bob.png, charlie.png (there are hundreds of them) and I would like to make video from those. What I try is

 avconv -i alice.png -i bob.png -i charlie.png -r 25 -b:v 12M -y out.mp4

but I am only getting the first image blipping in the movie, the rest is ignored.

There is buch of tutorials how to use -i %03d.png and similar wildcards, but is there a way to do without them, passing those files on the command line? mencoder had the option mf://alice.png,bob.png,charlie.png so I am looking for something similar.

Writing filenames to an external file would be OK as well.

eudoxos
  • 18,545
  • 10
  • 61
  • 110
  • You will end up overflowing the command line eventually (see http://stackoverflow.com/q/19354870/393701), so you might want to reconsider your requirements. – SirDarius Jan 28 '15 at 09:30
  • @SirDarius: I know, you're right. List in external file allowed now. – eudoxos Jan 28 '15 at 09:57
  • Your question is off topic here, but on topic for Super User. I voted to migrate it there, so please don't re-post. Anyway, are you using avconv or ffmpeg? – slhck Jan 28 '15 at 11:16
  • I am fine with moving to SU, how is that done? I would like to support both ffmpeg and avconv, if the syntax is the same, but if not, avconv is preferred (is seems to be more widely available in distros). – eudoxos Jan 30 '15 at 20:47
  • this situation is changing though, ffmpeg is making its way back into distros, see http://lwn.net/Articles/607591/ for more information. – SirDarius Feb 03 '15 at 09:42
  • Thanks, but please, could you migrate the question or answer it? – eudoxos Feb 03 '15 at 16:05

1 Answers1

0

In order to do this, you need to first generate hardlinks and then to remove them afterwards. There is no way to do what you want without such approach.

Do the following:

  1. Create a temporary directory.
  2. Run ln -t DIR file1 file2 file3 ...
  3. Change to that directory and run the sequential-rename script (see below)
  4. Change back out of it, and use normal %00d trick to convert those links.
  5. Remove the temporary directory.

sequential-rename

#!/bin/sh
# Sequential rename - rename screen shot images sequentially
#http://www.askdavetaylor.com/sequentially_rename_files_linux_mac_script.html

SAVEIFS=$IFS
IFS=$(echo -en "\n\b")

if [ $# -ne 1 ] ; then
  echo "Usage: $(basename $0) replacement-pattern-"
  exit 1
fi

pattern="$1"
count="1"

for filename in $(ls * | sort)
do
  if [ $count -eq 1000 ]; then
    eval "rename \"s/^$pattern(\\\\d\\\\d\\\\d)\\\\.jpeg/${pattern}0\\\\1.jpeg/g\" $pattern???.jpeg"
  fi
  if [ $count -eq 100 ]; then
    eval "rename \"s/^$pattern(\\\\d\\\\d)\\\\.jpeg/${pattern}0\\\\1.jpeg/g\" $pattern??.jpeg"
  fi
  if [ $count -eq 10 ]; then
    eval "rename \"s/^$pattern(\\\\d)\\\\.jpeg/${pattern}0\\\\1.jpeg/g\" $pattern?.jpeg"
  fi
  newname="${pattern}${count}.jpeg"
  echo "renaming \"$filename\" to $newname"
  mv "$filename" "$newname"
  count=$(( $count + 1 ))
done

IFS=$SAVEIFS

exit 0
v010dya
  • 5,296
  • 7
  • 28
  • 48
  • In the end I ended up with symlinks in a dedicated temp directory, that works as well. – eudoxos Apr 25 '15 at 10:24
  • @eudoxos Yes, symlinks will work too, but they will be just slightly slower, and there's no reason for that slowdown. – v010dya Apr 25 '15 at 11:07
  • Hardlinks don't work accross filesystems, nothing is perfect. The speed penalty is theoretical. – eudoxos Apr 25 '15 at 12:22
  • @eudoxos Ok, if for whatever reason you *must* go across different filesystems, then i guess it makes sense. I can't think of any Use Case for that, unless you were afraid to run into "filename too long" problem or something. – v010dya Apr 25 '15 at 12:25
  • The use case: have code that works wherever the user runs that, and have the temp in usual locations (like /tmp). – eudoxos Apr 25 '15 at 13:35