You are not logged in.

#1 2012-05-19 14:42:58

Gen2ly
Member
From: Sevierville, TN
Registered: 2009-03-06
Posts: 1,529
Website

ffmpeg: unable to pass filename correctly with colon in it

If I try to use the command in the script directly from the command line on a filename with a colon in it, there are no problems; however, if I try to use the script to do it the filename isn't being read correctly.  ffmpeg is throwing at me:

/run/media/todd/PSP/VIDEO/Taylor Wilson: 2012-480p-PSP.mp4: Invalid argument

In the script recently I had to add IFS so that filenames with spaces were handling correctly.  I know that bash can use the ":" as a command (forget which) so I'm figuring it's being interpreted as such.  Is IFS doing this... what do I need to do?  Here's the script:

#!/bin/bash

# To handle spaces in filenames correctly
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")

# Convert, save to PSP video directory
# Xvid version
for v in "$@"; do ffmpeg -i "$v" -b:v 512k -s 320x240 -vcodec libxvid -ab 64k -ar 24000 -strict -2 $vid_dir/${v%.*}-PSP.mp4; done

IFS=$SAVEIFS

Last edited by Gen2ly (2012-05-21 01:59:49)


Setting Up a Scripting Environment | Proud donor to wikipedia - link

Offline

#2 2012-05-19 15:01:39

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: ffmpeg: unable to pass filename correctly with colon in it

I'm guessing that ffmpeg is throwing this error, not the shell. You should simply quote the filename, rather than mess with the IFS. To avoid the ffmpeg error, perhaps you may need to pass the end-of-options marker?

for v; do
    ffmpeg -i "$v" -b:v 512k -s 320x240 -vcodec libxvid -ab 64k -ar 24000 -strict -2 -- "$vid_dir/${v%.*}-PSP.mp4"
done

Offline

#3 2012-05-20 09:29:32

Gen2ly
Member
From: Sevierville, TN
Registered: 2009-03-06
Posts: 1,529
Website

Re: ffmpeg: unable to pass filename correctly with colon in it

Ah, baah, didn't catch that I failed to quote that.  Ughh smile.    Thanks falcon.


Setting Up a Scripting Environment | Proud donor to wikipedia - link

Offline

#4 2012-05-20 14:02:26

Gen2ly
Member
From: Sevierville, TN
Registered: 2009-03-06
Posts: 1,529
Website

Re: ffmpeg: unable to pass filename correctly with colon in it

Ok, just found out that this has to do with ffmpeg parsing colons for uri's.  I learned though that ffmpeg can be passed the file type by using 'file:':

for v in "$@"; do ffmpeg -i file:"$v" -b:v 512k -s 320x240 -vcodec mpeg4 -vtag xvid -ab 64k -ar 24000 -strict -2 "$vid_dir"/"${v%.*}"-PSP.mp4; done

Last edited by Gen2ly (2012-05-21 02:08:50)


Setting Up a Scripting Environment | Proud donor to wikipedia - link

Offline

#5 2012-05-21 02:07:47

Gen2ly
Member
From: Sevierville, TN
Registered: 2009-03-06
Posts: 1,529
Website

Re: ffmpeg: unable to pass filename correctly with colon in it

Ok, I spoke too soon smile.  This has turned out to be a problem with the path.  When I used the above command successfully I was testing it with home "vid_dir=~/" and the path and filename got accepted correctly.  However, when I changed it back to:

vid_dir=/run/media/todd/PSP/VIDEO

I'm getting the:

/run/media/todd/PSP/VIDEO/Sex Determination: More Complicated Than You Thought-PSP.mp4: Invalid argument

Anybody have any thoughts?


Setting Up a Scripting Environment | Proud donor to wikipedia - link

Offline

#6 2012-05-21 04:23:30

frostyfrog
Member
From: Utah, USA
Registered: 2011-03-27
Posts: 42

Re: ffmpeg: unable to pass filename correctly with colon in it

Since the filename ends with PSP.mp4, what if you had this instead?

file:"$vid_dir"/"${v%.*}"-PSP.mp4

Also, the way I would do it personally would be this, but I'm not too sure if this would cause any more errors or not.

for v in "$@"; do 
  ffmpeg -i "file:$v" -b:v 512k -s 320x240 -vcodec mpeg4 -vtag xvid -ab 64k -ar 24000 -strict -2 "file:$vid_dir/${v%.*}-PSP.mp4"; 
done

Last edited by frostyfrog (2012-05-21 04:24:04)


{arch32} {subtlewm}{Acer Aspire One AO532h}
{arch64} {Headless Server}
Grrr! 400 char limit sad

Offline

Board footer

Powered by FluxBB