ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Using the script below, I have converted the format of 20 videos. Took 119 hours 14 minutes.
Code:
#! /bin/bash
## convert video for use on website.
for filename in *.ogg;
do
if [ -f "$filename" ]
then
outfile=${filename%.*} ## strip off the extension
ffmpeg -i "$filename" "$outfile".webm
fi
done
I still have the 'mp4' format and the 'swf' format to go.
Is there a faster way to do this? Something simular to this?
Overclock your machine, upgrade your cpu & ram. Lol
Maybe since they have been converted already you can use those new files to convert to the next desired formats. Instead of converting them all over to a new format.
Are you just changing the container format? You can add the -acodec copy and -vcodec copy flags to ffmpeg, and it won't recompress the audio and video.
Using the script below, I have converted the format of 20 videos. Took 119 hours 14 minutes.
Code:
#! /bin/bash
## convert video for use on website.
for filename in *.ogg;
do
if [ -f "$filename" ]
then
outfile=${filename%.*} ## strip off the extension
ffmpeg -i "$filename" "$outfile".webm
fi
done
I still have the 'mp4' format and the 'swf' format to go.
Is there a faster way to do this? Something simular to this?
Even a 10% reduction in run time over the 2 formats would mount to a whole day.
Dave
Assuming there are no directory names ending in '.ogg', you could rewrite it as
Code:
for fl in *.ogg; do ffmpeg -i "$fl" -o "${fl%.*}".webm; done
but it would make no appreciable difference in the time
I've never done web videos myself, nor used ffmpeg, but I do a lot of dvd encoding with both mencoder and HandBrake. They both average about 2 hours per dvd for a 2 pass process. Is ffmpeg perhaps being thrown off by your using a music encoding suffix (ogg) for files that actually are videos? As in trying every format that it will handle to determine what your ogg files actually are. What does its log file have to say?
Is ffmpeg perhaps being thrown off by your using a music encoding suffix (ogg) for files that actually are videos? As in trying every format that it will handle to determine what your ogg files actually are. What does its log file have to say?
Ogg is not a music encoding format, it is a container format, like avi is. The actual audio codec is named Vorbis, the video codec is name Theora: http://www.theora.org/faq/#13
Ogg is not a music encoding format, it is a container format, like avi is. The actual audio codec is named Vorbis, the video codec is name Theora: http://www.theora.org/faq/#13
Thank you for that clarification, I've only ever encountered ogg music files before.
Are you just changing the container format? You can add the -acodec copy and -vcodec copy flags to ffmpeg, and it won't recompress the audio and video.
You have ask a question for which I don't have an answer.
I used only the 'ogg' in a tread recently posted. Deeper research has produced this information
HTML Supported.
Code:
Browser MP4 WebM Ogg
___________________________________________________
Internet Explorer 9 YES NO NO
Firefox 4.0 NO YES YES
Google Chrome 6 YES YES YES
Apple Safari 5 YES NO NO
Opera 10.6 NO YES YES
I was trying to get a modified version of this code snippet from W3School to work.
You're encoding for the web? Don't even bother with ogg containers or Theora video. There is no browser whose currently supported version supports theora video in an ogg container, but not vp8 video in a webm container.
Just do one patent-encumbered h264/mp3/mp4 encode and one patent-unencumbered vp8/vorbis/webm encode. Something like this should cover you:
Assuming you have a processor with 2 cores, you could speed it up by transcoding 2 videos in parallel. Off the cuff, it could look like the following:
Code:
cores=2
i=0
for fl in *.ogg
do
ffmpeg -i "$fl" -o "${fl%.*}.webm" >/dev/null 2>&1 &
i=$(($i + 1))
if [ $i -ge $cores ]
then
wait
i=0
fi
done
-Ben
Thank you, I'd just naively assumed multi-core processors used their capabilities automatically. And presumably this technique can be adapted to any number of cores, for any lengthy process that has a series of inputs.
Thank you, I'd just naively assumed multi-core processors used their capabilities automatically. And presumably this technique can be adapted to any number of cores, for any lengthy process that has a series of inputs.
You are welcome. If you are careful, you can use "xargs -P 2" and get a little better performance than my first example.
And thank you for these techniques too. So one can indicate to an app that it should read from standard input until a designated line. But is there a particular reason why you feed the output of find through a pipe to xargs, rather than use find's -exec option?
Thanks to all for the informaton, instructions and patients. I have put the script to running. I will be back after Sunday, Renaissance Festival is starting this weekend and I have things to do to get ready.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.