You are not logged in.
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
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
Ah, baah, didn't catch that I failed to quote that. Ughh . Thanks falcon.
Setting Up a Scripting Environment | Proud donor to wikipedia - link
Offline
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
Ok, I spoke too soon . 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
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
Offline