I wanted to share an .mp4 file on my webserver but Firefox didn’t play it. It turned out Firefox prefers the .webm and .ogv formats, while Chrome can play .mp4.
Convert mp4 then:
.mp4 to .webm
ffmpeg -i input.mp4 -vcodec libvpx -acodec libvorbis -b:v 600k -cpu-used 4 -threads 8 output.webm
To change the quality, play with the “600k” value (bitrate).
.mp4 to .ogv
ffmpeg -i final.mp4 -vcodec libtheora -acodec libvorbis -b:v 600k -cpu-used 4 -threads 8 final.ogv
Here the difference is the codec (libtheora instead of libvpx).
Maybe I missed something, but the .webm file seemed to me to have better quality than .ogv. So I think it’s enough to support two formats only: .mp4 for Chrome and .webm for Firefox. By the way, in my test the input file (.mp4) had the best quality and smallest filesize, but again, I may miss something.
And here is an HTML5 code that can play your video:
<video controls preload="metadata" width="1024" height="768" poster="images/front.jpg"> <source src="video.mp4" type="video/mp4"> <source src="video.webm" type="video/webm"> <p>Please use a modern browser to view this video.</p> </video>
I have a stylesheet made with LibreOffice Calc / Excel. The extension of the file is
.xlsx. How to convert it to
.csv? From the command line, of course.
libreoffice --headless --convert-to csv file.ods
Convert an Excel file:
libreoffice --headless --convert-to csv file.xlsx
Tip from here.
If you use
--convert-to html, then you get an HTML output.
You know the URL of a webpage and you want to take a screenshot of it. For instance you want a thumbnail about the webpage.
It can be done very nicely with PhantomJS.
What is PhantomJS?
How to install PhantomJS?
Follow the instructions here. Under Ubuntu I compiled it from source to get the latest version. Note that it takes a lot of time (about 30 minutes). Under Manjaro I could install it via
yaourt and it took 1 minute (and got the newest version). The good news is that installation is not a problem.
How to take a screenshot?
If you download the source, you get a lot of example scripts. One of them is called
rasterize.js, and this is exactly what we need.
$ phantomjs rasterize.js Usage: rasterize.js URL filename [paperwidth*paperheight|paperformat] [zoom] paper (pdf output) examples: "5in*7.5in", "10cm*20cm", "A4", "Letter" image (png/jpg output) examples: "1920px" entire page, window width 1920px "800px*600px" window, clipped to 800x600
phantomjs rasterize.js http://raphaeljs.com/polar-clock.html clock.png
phantomjs rasterize.js https://www.reddit.com/ red.png
It produced an image with dimension 600×3304. It’s too narrow, let’s fix that.
phantomjs rasterize.js https://www.reddit.com/ red.png 1024px
Its dimension is 1024×2432. Looks much better.
The previous image was too high. Let’s take a photo of that part that would be visible on our screen. For this we need to clip a window.
phantomjs rasterize.js https://www.reddit.com/ red.png "1024px*768px"
Great. Now scale it down to get a thumbnail.
Scaling down an image to thumbnail size
$ phantomjs rasterize.js https://www.reddit.com/ screenshot.png "1024px*768px" $ convert -resize 250 screenshot.png thumb.jpg
convert comes from the ImageMagick package. Here we resize the image to width 250px. Convert will keep the image ratio, i.e. it figures out the height value.
ffmpeg -i input.wmv -c:v libx264 -crf 23 -profile:v high -r 30 -c:a libfaac -q:a 100 -ar 48000 output.mp4
More info here.
You want to resize an image to a given width but you want to keep the width/height ratio of the image.
convert -resize 200 big.jpg small.jpg
Here the new width will be 200 pixels.
pandoc input.txt -o output.pdf
By the way, pandoc can convert from / to lots of file formats.