How to get aspect ratio from video file ? ( 16:9 or 4:3 for example ) ?
Install the tool mediainfo. Run it with mediainfo -f --Output=XML <file> to examine it.
PS: In my case (openSUSE, mediainfo 0.7.34, the option --Output was ignored).
You can use ffmpeg to do that:
my ($aspect) = `ffmpeg -i filename.mov 2>&1` =~ /DAR\s*(\d+:\d+)/;
Or ffprobe:
my ($aspect) = `ffprobe -i filename.mov -show_streams 2>&1`
=~ /display_aspect_ratio=(.+)/;
Related
this is a beginner's question but i can't figure out the answer after looking into it for several days:
I want ffmpeg to extract the audio portion of a video and save it in an .ogg container. If i run the following command in terminal it works as expected:
ffmpeg -i example.webm -vn -acodec copy example.ogg
For convenience, i want to do this in a script. However, if i pass a variable to ffmpeg it apparently just considers the first word and produces the error "No such file or directory".
I noticed that my terminal escapes spaces by a \ so i included this in my script. This doesn't solve the problem though.
Can someone please explain to me, why ffmpeg doesn't consider the whole variable that is passed to it in a script while working correctly when getting passed the same content in the terminal?
This is my script that passes the filename with spaces escaped by \ to ffmpeg:
#!/bin/bash
titelschr=$(echo $# | sed "s/ /\\\ /g")
titelohne=$(echo $titelschr | cut -d. -f 1)
titelogg=$(echo -e ${titelohne}.ogg)
ffmpeg -i $titelschr -vn -acodec copy $titelogg
Thank you very much in advance!
You need to quote variable expansions, try this :
#!/usr/bin/env bash
titelschr=$1
titelogg="${titelschr%.*}.ogg"
ffmpeg -i "$titelschr" -vn -acodec copy "$titelogg"
call with :
bash test.sh "Some video file.mp4"
This way, you don't need to escape spaces.
I have multiple wav files with the duration of 2.2 - 2.8 seconds.
I want to modify (stretch/squeeze) them, such that all of them will be with the exact duration of 2.5 seconds.
I mean slightly stretch the actual data and not just add leading/trailing zeros.
Is it possible?
Thanks
Yes, you can use https://github.com/waywardgeek/sonic like this:
sonic -s 3.2 book.wav book_fast.wav
I haven't found a simple solution with ffmpeg, but you can use RubberBand:
rubberband --duration d input.wav output.wav
(thanks to https://superuser.com/a/1132229/807246)
Example:
$ duration=2.5; for file in *.wav; do rubberband -D $duration $file out_${file}; done;
$ sox --info -D file.wav
2.390875
$ sox --info -D out_file.wav
2.500000
I've looked everywhere to try to combine a bunch of FLAC files with differing sample rates into 1 file. What I've tried so far is:
ffmpeg concat with a wildcard:
ffmpeg -f concat -i <( for f in *.flac; do echo "file '$(pwd)/$f'"; done ) -safe 0 output.flac
I get for every filename, (even if I change pwd to './' for relative):
ffmpeg unsafe filename
Regardless of the file's filename.
I've tried sox:
sox *.flac output.flac
Which leads to:
sox FAIL sox: Input files must have the same sample-rate
I've even tried combining the two:
#!/usr/bin/env bash
set -eu
for i in *.flac *.ogg *.mp3
do
ffmpeg -i "$i" "$i.wav"
done
sox *.wav combined.wav
Same error as above.
Anyone have any tips? I'm sure that in some Windows program you can drag in 5 differing sound files and combine them with ease. Is there not a simple way to do this on linux cmdline?
safe 0 is a private option for the concat demuxer, so it has to appear before the input i.e. -f concat -safe 0 -i ...
Trying to record my desktop and also audio with RHEL6.
I'm using the command below, but the quality of the video output is not good.
It is very blurry and I can bearly make out text on screen.
The audio is good so no issues there.
Does anyone know how the make the video quality any better?
ffmpeg -f alsa -ac 2 -i hw:0,0 -f x11grab -s $(xwininfo -root | grep 'geometry' | awk '{print $2;}') -r 25 -i :0.0 -sameq -f mpeg -ar 48000 -s wvga -y sample.avi
I believe the -sameq option means 'same quantizer' not 'same quality' and is depreciated, see here.
Try -q 1 instead.
q being quality 1-32 (1 being highest)
Is there a command line program for linux (ubuntu) which can generate a large image containing say 6 caps from a given video (e.g. WMV) laid out storyboard style (I know on Windows media player classic can do this)? I need this for part of a script I am writing.
I pulled the answer from this site: http://blog.prashanthellina.com/2008/03/29/creating-video-thumbnails-using-ffmpeg/
ffmpeg -itsoffset -4 -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 test.jpg
Where -4 is the number of seconds into the file to grab the screenshot, 320x240 is the screenshot size, and test.jpg is the output file.
Hope this helps.
Use SlickSlice
./slickslice.sh -x video.avi -s 5x3 -e
I've used MPlayer to save frames as images and ImageMagick to combine them:
mplayer -nosound -sstep 15 -vo png video.mkv
montage *.png -tile 3x3 -geometry 300x+0+0 screencaps.png
vcsi can do this. It is a command-line tool written in Python. Example:
vcsi video.mkv -o output.jpg