for audioFile in *wav; do avconv -i "$audioFile" -af aformat=s16:44100 "${audioFile%.*}.flac"; done
This encodes to 16 bits at 44100 hertz.
Flag | Usage |
---|---|
-af filterGraph | Apply filterGraph to the input audio stream A filterGraph is a process made of several piped filters. One of the available filterGraphs is aformat |
-f format | Force input or output file format. The format is normally autodetected for input files and guessed from file extension for output files, so this option is not needed in most cases. To list supported file formats (containers) : avconv -formats
|
-i inputFile | input file. It is possible to have several input files :
avconv -i file1 -i file2
and to refer to individual streams with -map x:y
|
-map fileId:streamId | -map x:y refers to :
|
-ss position |
|
-t duration | Stop writing the output after its duration reaches duration. duration may be a number in seconds, or in hh:mm:ss[.xxx] form.
|
-threads n | Use n threads for processing. Or auto : ??? (showed the maximum CPU usage when tried ) Or 0 : ??? |
-y | Overwrite output files without asking (actually auto-answers "yes" to Overwrite (y/n) ? prompt.) |
Flag | Usage |
---|---|
-aspect ratio | Set the video display aspect ratio
|
-c codec -codec codec |
Generic specification : -codec[:optional_stream_specifier] codec input|output|stream Select a decoder (when used before an input file) or an encoder (when used before an output file) for one or more streams. codec is the name of a decoder/encoder or the special value copy (output only) to indicate that the stream is not to be re-encoded (often seen as : -c copy ).
|
-acodec codec -codec:a codec |
Specify the audio codec. -c:a copy means that the input audio will be copied as is, without any transcoding. |
-b:stream value | Set the bitrate of the (optional parameter) stream stream (a for audio, v for video) to value bits/s (value can use the k suffix) |
-crf quality | Select the quality for constant quality mode. It goes from 0 (lossless) upwards logarithmically. You'll probably want a value between 19 and 25 in most cases. |
-deinterlace | deinterlace the video stream |
-preset type | Configuration preset. This does some automatic settings based on the general type of the image (?). Sets the speed of the encoding, either "slow", "medium", or "fast". Slow should get you smaller file sizes with an obvious tradeoff. |
-r:stream value | Set the frame rate of the specified video stream stream to value frames/s |
-s:stream WxH | Declare the size (width*height) of the input stream, OR set frame size to WxH |
-vcodec codec -codec:v codec |
Specify the video codec. |
-vf filter | Apply the filter filter to the input video |
This command returns a failure exit code as avconv expects an "output file" parameter (I found no better solution so far ). For this reason ("failure" exit code + output message sent to stderr rather than stdout), you have to redirect everything to stdout before processing it :
avconv -i inputFile -ss startTime -t duration -codec copy outputFile
hh:mm:ss[.xxx]
format.The command above may work pretty well. But, depending on the input file itself (I got this with a .avi file), it may end in a huge series of :
Re-encoding the audio track (here in mp3 format) fixed it :
During the tests to find the right start time (-ss value), save time by not processing the input until the end :
TESTING : outputDir='./output'; mkdir -p "$outputDir"; for input in *avi; do echo "$input"; avconv -y -i "$input" -ss 15.5 -t 15 -c:v copy -c:a mp3 "$outputDir/$input"; done REAL : outputDir='./output'; mkdir -p "$outputDir"; for input in *avi; do echo "$input"; avconv -i "$input" -ss 15.5 -c:v copy -c:a mp3 "$outputDir/$input"; done
Stream #0.0(eng): Video: h264 (High), yuv420p, 1920x1080, PAR 1:1 DAR 16:9, 23.98 fps, 1k tbn, 47.95 tbc (default) Stream #0.1(eng): Audio: ac3, 48000 Hz, 5.1, fltp, 448 kb/s my TV plays this audio track Stream #0.2(fre): Audio: ac3, 48000 Hz, 5.1, fltp, 448 kb/s I want this one played Stream #0.3(fre): Subtitle: srt Stream #0.4(eng): Subtitle: srt
avconv -i input.mkv -map 0:0 -map 0:2 -map 0:1 -c copy output.mkv
This specifies the tracks of output.mkv to be :Stream #0.0(eng): Video: h264 (High), yuv420p, 1920x1080, PAR 1:1 DAR 16:9, 23.98 fps, 1k tbn, 47.95 tbc (default) Stream #0.1(fre): Audio: ac3, 48000 Hz, 5.1, fltp, 448 kb/s Stream #0.2(eng): Audio: ac3, 48000 Hz, 5.1, fltp, 448 kb/sWe've not picked the subtitles tracks !
This method should be preferred whenever possible since it only extracts the audio data with no reconversion :
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 389 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc (default) Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
encoder 'aac' is experimental and might produce bad results. Add '-strict experimental' if you want to use it.
https://stackoverflow.com/questions/3937387/rotating-videos-with-ffmpeg/9570992#9570992 ffmpeg -i in.mov -vf "transpose=1" out.mov For the transpose parameter you can pass: 0 = 90Counterclockwise and Vertical Flip (default) 1 = 90Clockwise 2 = 90Counterclockwise 3 = 90Clockwise and Vertical Flip https://ffmpeg.org/ffmpeg-filters.html#transpose-1
avconv -i inputFile -vf scale=iw*0.25:-1 -codec:a copy outputFile
-codec:a copy allows to stream copy the audio without re-encoding.