I download videos from YouTube using youtube-dl https://www.youtube.com/....
, but their format is .mp4. My TV doesn't support this format, therefore i need to have (dowload) them in .avi.
Please help me :)
- 11
- 1
- 4
2 Answers
you can run the following command to convert all of your mp4 videos to avi:
for i in `find . -type f -name '*.mp4'`; do avconv -i "$i" -qscale 1 "${i/.mp4/.avi}"; done
For more info on avconv, see the manpages:
man avconv
Alternatively, you can download as a specific format by using the --recode-video FORMAT flag like so (but the only formats supported are : mp4|flv|ogg|webm|mkv):
youtube-dl --recode-video flv
for format .flv, followed by the URL.
Newer versions of youtube-dl may allow recoding to avi:
youtube-dl --recode-video avi
and newer versions of Ubuntu (15.04+) will allow you to prefer ffmpeg over avconv if ffmpeg is installed:
youtube-dl --recode-video avi --prefer-ffmpeg
While mchid's answer may result in a working file on your device, re-encoding an entire video is not what you should do just because your device is picky with standard formats and therefore default to legacy non-standard formats.
Assuming that the optimal format for your device is AVI is awful and stupid. The AVI container can be used with a lot of different formats (like MKV, just older and worse) and despite it's popularity in warezing before podcasting, streaming and video on demand were widely available, it's anything but a standard meant for content distribution.
Here is an excerpt of what avconv did in my test case:
Stream #0:0 -> #0:0 (h264 -> mpeg4)
Stream #0:1 -> #0:1 (aac -> libmp3lame)
What's MPEG4? Mediainfo output:
Video
ID : 0
Format : MPEG-4 Visual
Format profile : Simple@L1
Format settings, BVOP : No
Format settings, QPel : No
Format settings, GMC : No warppoints
Format settings, Matrix : Default (H.263)
Codec ID : FMP4
Duration : 1mn 29s
Bit rate : 3 479 Kbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate : 29.970 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Compression mode : Lossy
Bits/(Pixel*Frame) : 0.056
Stream size : 36.9 MiB (100%)
Writing library : Lavc54.92.100
Notice the switch to the very old H.263 (Simple@L1 – you may want to study what profiles and levels mean in video encoding… or better not). A sane default when no further information is provided, but you shouldn't use H.263 on a modern device unless you're really desperate.
Comparison with original and result both mangled through JPEG, though I uploaded 1080p PNG screenshots (view full size!). And that's just a low detail scene from a video game with almost no motion.

TL;DR:
- Get a device that isn't picky with formats and makes you waste time and energy by re-encoding.
- Use a converter that offers templates for achieving quality with sane encoding settings, like Handbrake.
- Try
-vcodec copyto change the container, but avoid re-encoding video with avconv/ffmpeg.
- 29,597