I am trying to extract the audio from a video and output it to stdout.
The closest I can get is to download the video to stdout.
youtube-dl -o - <link to video>
Does anyone know how to do this?
Regards,
Austin
Try with option -f
At first list the available formats with -F
youtube-dl -F https://www.youtube.com/watch?v=CSKewNVWD0Y
Then look for the "audio only" formats:
249 webm audio only DASH audio 62k , opus # 50k, 20.17MiB
250 webm audio only DASH audio 91k , opus # 70k, 26.26MiB
171 webm audio only DASH audio 128k , vorbis#128k, 44.89MiB
140 m4a audio only DASH audio 132k , m4a_dash container, mp4a.40.2#128k, 51.17MiB
251 webm audio only DASH audio 198k , opus #160k, 65.09MiB
278 webm 256x144 144p 46k , webm container, vp9, 6fps, video only, 11.36MiB
242 webm 426x240 240p 90k , vp9, 6fps, video only, 19.39MiB
160 mp4 256x144 144p 125k , avc1.4d400c, 6fps, video only, 15.18MiB
243 webm 640x360 360p 173k , vp9, 6fps, video only, 39.52MiB
134 mp4 640x360 360p 214k , avc1.4d4016, 6fps, video only, 47.51MiB
133 mp4 426x240 240p 255k , avc1.4d4015, 6fps, video only, 37.37MiB
17 3gp 176x144 small , mp4v.20.3, mp4a.40.2# 24k
36 3gp 320x180 small , mp4v.20.3, mp4a.40.2
43 webm 640x360 medium , vp8.0, vorbis#128k
18 mp4 640x360 medium , avc1.42001E, mp4a.40.2# 96k (best)
Format code 251 for opus #160 kbps. And finally you can use (optionally recode with ffmpeg):
youtube-dl -f 251 https://www.youtube.com/watch?v=CSKewNVWD0Y -o - | ffmpeg -i - -b:a 160k my_fav_novel.mp3
Related
I am trying to come up with a way where I can play the audio only portion of a live stream using for example VLC player. The stream in question is from ChilledCow, the url which is 24x7 streaming is https://www.youtube.com/watch?v=DWcJFNfaw9c. Using youtube-dl -F, I can see there are no Audio Only streams;
[youtube] DWcJFNfaw9c: Downloading webpage
[youtube] DWcJFNfaw9c: Downloading m3u8 information
[youtube] DWcJFNfaw9c: Downloading MPD manifest
[info] Available formats for DWcJFNfaw9c:
format code extension resolution note
91 mp4 256x144 HLS 197k , avc1.42c00b, 30.0fps, mp4a.40.5# 48k
92 mp4 426x240 HLS 338k , avc1.4d4015, 30.0fps, mp4a.40.5# 48k
93 mp4 640x360 HLS 829k , avc1.4d401e, 30.0fps, mp4a.40.2#128k
94 mp4 854x480 HLS 1380k , avc1.4d401f, 30.0fps, mp4a.40.2#128k
95 mp4 1280x720 HLS 2593k , avc1.4d401f, 30.0fps, mp4a.40.2#256k
96 mp4 1920x1080 HLS 4715k , avc1.640028, 30.0fps, mp4a.40.2#256k (best)
If I then use youtube-dl -g -f 96 command, I am able to retrieve a M3U8 url (now expired);
https://manifest.googlevideo.com/api/manifest/hls_playlist/expire/1586086956/ei/zG-JXobzGP3B1AbawoHgBw/ip/202.153.210.144/id/DWcJFNfaw9c.2/itag/96/source/yt_live_broadcast/requiressl/yes/ratebypass/yes/live/1/goi/160/sgoap/gir%3Dyes%3Bitag%3D140/sgovp/gir%3Dyes%3Bitag%3D137/hls_chunk_host/r1---sn-fpqxc5oq-hxal.googlevideo.com/vprv/1/playlist_type/DVR/initcwndbps/14720/mh/Ms/mm/44/mn/sn-fpqxc5oq-hxal/ms/lva/mv/m/mvi/0/pcm2cms/yes/pl/24/dover/11/keepalive/yes/fexp/23882514/mt/1586065238/disable_polymer/true/sparams/expire,ei,ip,id,itag,source,requiressl,ratebypass,live,goi,sgoap,sgovp,vprv,playlist_type/sig/AJpPlLswRQIgQ4q-AaeGe9RuORutXufPJpq2jV5qvvYSf8L46jrnOpcCIQDLiqxM-r8EVp8EUby0D8gzWblW56-4NjCpasYtABNGxw%3D%3D/lsparams/hls_chunk_host,initcwndbps,mh,mm,mn,ms,mv,mvi,pcm2cms,pl/lsig/ALrAebAwRgIhAPXST2zJ7NWF6SF7iv1JeiJxIQM9wnuYXlgEipQS1nxRAiEAsE9Vlj1mpqE3t72DvI7JXu0ILWajrQsEjqMNzy5spjQ%3D/playlist/index.m3u8
I can open this with VLC and the audio+video streams fine. When I inspect the Codec Details, I can see there are 2 streams; ADTS Audio # 48000 Hz and H.264 Video. Opening up the M3U8 file, I see instructions on how to download the individual ts segments;
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:5
#EXT-X-MEDIA-SEQUENCE:261917
#EXT-X-DISCONTINUITY-SEQUENCE:105
#EXT-X-PROGRAM-DATE-TIME:2020-04-05T01:52:00.024+00:00
#EXTINF:5.0,
https://r1---sn-fpqxc5oq-hxal.googlevideo.com/videoplayback/id/DWcJFNfaw9c.2/itag/96/source/yt_live_broadcast/expire/1586087365/ei/ZXGJXsX2Bc-zvATAg5LQCA/ip/202.153.210.144/requiressl/yes/ratebypass/yes/live/1/goi/160/sgoap/gir%3Dyes%3Bitag%3D140/sgovp/gir%3Dyes%3Bitag%3D137/hls_chunk_host/r1---sn-fpqxc5oq-hxal.googlevideo.com/vprv/1/playlist_type/DVR/initcwndbps/13910/mh/Ms/mm/44/mn/sn-fpqxc5oq-hxal/ms/lva/mv/m/mvi/0/pl/24/keepalive/yes/fexp/23882513/mt/1586065639/disable_polymer/true/sparams/expire,ei,ip,id,itag,source,requiressl,ratebypass,live,goi,sgoap,sgovp,vprv,playlist_type/sig/AJpPlLswRQIhAPZgf7DINxcGTvbH4B_0f-viQhiTpYT1jJuUsvmDCzJaAiB1GcPc2tvTx2wbYDgG5qb5PkSQ7pPS5A5yhlh782GdlQ%3D%3D/lsparams/hls_chunk_host,initcwndbps,mh,mm,mn,ms,mv,mvi,pl/lsig/ALrAebAwRAIgdV-i58zrYviyY4Zin9w6Gu9WVvqv5y99lq4XOsyRH4wCIEohlTMmwYrHgF8YvXWFRWZvYQP7e6NiE7w42YmwUzOM/playlist/index.m3u8/sq/261917/goap/clen%3D81159%3Blmt%3D1585977854061325/govp/clen%3D265668%3Blmt%3D1585977854061323/dur/5.000/file/seg.ts
#EXTINF:5.0,
https://r1---sn-fpqxc5oq-hxal.googlevideo.com/videoplayback/id/DWcJFNfaw9c.2/itag/96/source/yt_live_broadcast/expire/1586087365/ei/ZXGJXsX2Bc-zvATAg5LQCA/ip/202.153.210.144/requiressl/yes/ratebypass/yes/live/1/goi/160/sgoap/gir%3Dyes%3Bitag%3D140/sgovp/gir%3Dyes%3Bitag%3D137/hls_chunk_host/r1---sn-fpqxc5oq-hxal.googlevideo.com/vprv/1/playlist_type/DVR/initcwndbps/13910/mh/Ms/mm/44/mn/sn-fpqxc5oq-hxal/ms/lva/mv/m/mvi/0/pl/24/keepalive/yes/fexp/23882513/mt/1586065639/disable_polymer/true/sparams/expire,ei,ip,id,itag,source,requiressl,ratebypass,live,goi,sgoap,sgovp,vprv,playlist_type/sig/AJpPlLswRQIhAPZgf7DINxcGTvbH4B_0f-viQhiTpYT1jJuUsvmDCzJaAiB1GcPc2tvTx2wbYDgG5qb5PkSQ7pPS5A5yhlh782GdlQ%3D%3D/lsparams/hls_chunk_host,initcwndbps,mh,mm,mn,ms,mv,mvi,pl/lsig/ALrAebAwRAIgdV-i58zrYviyY4Zin9w6Gu9WVvqv5y99lq4XOsyRH4wCIEohlTMmwYrHgF8YvXWFRWZvYQP7e6NiE7w42YmwUzOM/playlist/index.m3u8/sq/261918/goap/clen%3D81404%3Blmt%3D1585977854061335/govp/clen%3D236301%3Blmt%3D1585977854061333/dur/5.000/file/seg.ts
I'm not sure if there is a way to only stream the audio portion, my goal is to have a headless raspberry pi (no video output, audio only) that can play the audio stream.
I came up with a relatively simple solution. I ended up using the command line player mpv with the —no-video option and the YouTube URL. I can confirm the audio only gets decoded.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I have just download youtube-dl so I can download video and audio files from youtube.
I want to download the best audio from the following video: https://www.youtube.com/watch?v=uWusmdmc0to
When I do a search for all formats with youtube-dl I get the following results:
format code extension resolution note
249 webm audio only DASH audio 58k , opus # 50k, 18.99MiB
250 webm audio only DASH audio 75k , opus # 70k, 25.20MiB
140 m4a audio only DASH audio 131k , m4a_dash container, mp4a.40.2#128k, 52.40MiB
251 webm audio only DASH audio 147k , opus #160k, 50.95MiB
171 webm audio only DASH audio 149k , vorbis#128k, 52.64MiB
278 webm 256x144 144p 109k , webm container, vp9, 25fps, video only, 34.62MiB
160 mp4 256x144 144p 117k , avc1.4d400c, 25fps, video only, 37.86MiB
242 webm 426x240 240p 245k , vp9, 25fps, video only, 75.13MiB
133 mp4 426x240 240p 258k , avc1.4d4015, 25fps, video only, 81.39MiB
243 webm 640x360 360p 492k , vp9, 25fps, video only, 142.99MiB
134 mp4 640x360 360p 673k , avc1.4d401e, 25fps, video only, 215.29MiB
244 webm 854x480 480p 828k , vp9, 25fps, video only, 256.58MiB
135 mp4 854x480 480p 1516k , avc1.4d401e, 25fps, video only, 408.56MiB
247 webm 1280x720 720p 1882k , vp9, 25fps, video only, 526.18MiB
136 mp4 1280x720 720p 3012k , avc1.4d401f, 25fps, video only, 803.36MiB
248 webm 1920x1080 1080p 3622k , vp9, 25fps, video only, 938.81MiB
137 mp4 1920x1080 1080p 4724k , avc1.640028, 25fps, video only, 1.44GiB
271 webm 2560x1440 1440p 9253k , vp9, 25fps, video only, 2.86GiB
313 webm 3840x2160 2160p 18685k , vp9, 25fps, video only, 6.33GiB
17 3gp 176x144 small , mp4v.20.3, mp4a.40.2# 24k
36 3gp 320x180 small , mp4v.20.3, mp4a.40.2
43 webm 640x360 medium , vp8.0, vorbis#128k
18 mp4 640x360 medium , avc1.42001E, mp4a.40.2# 96k
22 mp4 1280x720 hd720 , avc1.64001F, mp4a.40.2#192k (best)
What is the best choice to get the best audio file? The first five are audio only. Do I need to pick one here? Or is the last one MP4 HD720 the best option and then convert it to MP3?
Thanks!
If you want mp3, just tell youtube-dl that:
youtube-dl -x --audio-format mp3 https://www.youtube.com/watch?v=uWusmdmc0to
will get you an audio version (-x, short for --extract-audio) in or converted to mp3 (that's the --audio-format option). youtube-dl will automatically pick the best quality and most appropriate format.
Note that the listed qualities are just guesses. In practice, opus is superior to anything else, but vorbis is picked for compatibility (refer to this related answer of mine for more details), so that will be picked.
While you can use -f to select a particular format, this is intended for people who want lower quality because of limited bandwidth or storage space, or for debugging. By default, youtube-dl already downloads the highest quality.
If you want to download audio in opus format - with best possible quality and without any conversion
In most of the cases best quality audio is oryginally provided by youtube in opus format.
You can download it in highest possible quality using this command:
youtube-dl -f "bestaudio/best" -ciw -o "%(title)s.%(ext)s" -v --extract-audio https://www.youtube.com/watch?v=c29tZVZpZGVvUGxheWxpc3RQYXJ0
However opus format might be inconvenient for many reasons.
For example some media players especially in cars and telephones might not support it.
Probably you just want to have audio in mp3 file.
Below there is a solution on how to (using one command) download audio and convert it to probably most popular mp3 format with lossing as little quality as possible.
If you want to download audio and convert it to mp3 or any other lossy format.
To download audio from a single movie:
youtube-dl -f "bestaudio/best" -ciw -o "%(title)s.%(ext)s" -v --extract-audio --audio-quality 0 --audio-format mp3 https://www.youtube.com/watch?v=c29tZVZpZGVvUGxheWxpc3RQYXJ0
To perform this command you need ffmpeg installed (audio and video converter which youtube-dl uses for convertion)
It downloads only audio (without video) and converts it to mp3.
Option --audio-quality 0 is very important there!
Without this option you lose a lot of sound quality during mp3 compression.
--audio-quality 0 tells youtube-dl to save audio file in the best quality (when converting to mp3).
Without this option mp3 audio-quality is set by default to 5 in 0-9 scale where 0 is the best quality and 9 the worst quality. So by default quality is worse.
Youtube streams for nonpremium users with variable bitrate up to 160kbps in opus format. Opus format is newer than mp3 and has better compression than mp3 preserving the same quality. So 160kbps opus = ~256kbps mp3.
When audio-quality is default (5 in 0-9 scale) mp3 bitrate is limited to 160kbps which means that some sound quality is lost during compression. When audio-quality is set to 0 mp3 goes up to 300kbps preserving almost original quality.
Almost original quality because mp3 is a lossy format so something is lost when converting to it. By using --audio-quality 0 option we just make sure that we loose as little as possible during this conversion. So difference between original opus audio file and audio file converted to mp3 is so small that it might be hard to spot by ear.
To download audio from all movies from a channel:
Command is the same, but you should put link to the channel instead of link to a single video:
youtube-dl -f "bestaudio/best" -ciw -o "%(title)s.%(ext)s" -v --extract-audio --audio-quality 0 --audio-format mp3 https://www.youtube.com/c/someChannelName1232143/videos
To download audio from a playlist:
You have to add --yes-playlist option.
You can put a link to a playlist (link with playlist word):
youtube-dl -f "bestaudio/best" -ciw -o "%(title)s.%(ext)s" -v --extract-audio --audio-format mp3 --audio-quality 0 --yes-playlist https://www.youtube.com/playlist?list=c29tZVZpZGVvVVJMUGFy
Or the link to one of the songs from playlist while playing playlist (link with list word):
youtube-dl -f "bestaudio/best" -ciw -o "%(title)s.%(ext)s" -v --extract-audio --audio-format mp3 --audio-quality 0 --yes-playlist "https://www.youtube.com/watch?v=c29tZVZpZGVvUGxheWxpc3RQYXJ0&list=c29tZVZpZGVvTGlzdFBhcnRzc29tZVZpZGVvTGlzdFBhcnRz&index=4"
If you want to download audio and convert it to flac or any other lossless format
In this case you don't have to specify --audio-quality option as it is ignored by youtube-dl during conversion to lossless formats.
To download audio from a single movie:
youtube-dl -f "bestaudio/best" -ciw -o "%(title)s.%(ext)s" -v --extract-audio --audio-format flac https://www.youtube.com/watch?v=c29tZVZpZGVvUGxheWxpc3RQYXJ0
To download audio from all movies from a channel:
youtube-dl -f "bestaudio/best" -ciw -o "%(title)s.%(ext)s" -v --extract-audio --audio-format flac https://www.youtube.com/c/someChannelName1232143/videos
To download audio from a playlist:
youtube-dl -f "bestaudio/best" -ciw -o "%(title)s.%(ext)s" -v --extract-audio --audio-format flac --yes-playlist https://www.youtube.com/playlist?list=c29tZVZpZGVvVVJMUGFy
or
youtube-dl -f "bestaudio/best" -ciw -o "%(title)s.%(ext)s" -v --extract-audio --audio-format flac --yes-playlist "https://www.youtube.com/watch?v=c29tZVZpZGVvUGxheWxpc3RQYXJ0&list=c29tZVZpZGVvTGlzdFBhcnRzc29tZVZpZGVvTGlzdFBhcnRz&index=4"
Command options explanation:
-f "bestaudio/best" <- Choose the best audio format.
As there is only audio format listed only the audio is downloaded.
-c <- (--continue) Force resume of partially downloaded files.
By default, youtube-dl will resume downloads if possible.
As docs state maybe it is default, but I put it to make sure it is set.
-i <- (--ignore-errors) Continue on download errors,
for example to skip unavailable videos in a playlist.
-w <- (--no-overtwrites) Do not overwrite files
(If something was already downloaded
and is present in the directory then continue with the next video)
-o "%(title)s.%(ext)s" <- (--output) Output filename template,
in this case it gives you file named movieTitle.mp3
where movieTitle is the title of the video on youtube.
-v <- (--verbose) Print various debugging information
--extract-audio <- (-x) Convert video files to audio-only files
(requires ffmpeg or avconv and ffprobe or avprobe)
--audio-quality 0 <- Specify ffmpeg/avconv audio quality,
insert a value between 0 (better) and 9 (worse) for VBR or a specific
bitrate like 128K (default 5).
Youtube streams for nonpremium users with variable bitrate up to 160kbps in opus format.
Opus format is newer than mp3 and has better compression than mp3
preserving the same quality. So 160kbps opus = ~ 256kbps mp3.
When audio-quality is default (5 in 0-9 scale) mp3 bitrate
is limited to 160kbps which means that some sound quality is lost during compression.
When audio-quality is set to 0 mp3 goes up to 300kbps preserving original quality.
--audio-format mp3 <- Specify audio format: "best", "aac", "flac", "mp3", "m4a",
"opus", "vorbis", or "wav"; "best" by default; No effect without -x (--extract-audio).
In this case we choose mp3.
Alternatively you could choose for example flac which is loseless codec.
All links that I provided there are fake. I just put some random words encoded by base64 in them. So you have to replace them by your own links to make it work.
Hint:
Youtube-dl gives you opportunity to use your own youtube account to download stuff.
If your account is a premium account you can get
higher 320kbps opus bitrate which is equivalent of ~512kbps mp3.
Using your own account might be possible by setting --username and --pasword
(See Authentication Options in --help)
Note:
All of the above should be relevant for version 2021.12.17 of youtube-dl.
Newer versions might change something, so be aware of that.
Download best audio:
youtube-dl -f bestaudio https://www.youtube.com/watch?v=3_y2jVPmPBw --output "out.%(ext)s"
This should give you the best sound quality:
youtube-dl --extract-audio "https://www.youtube.com/watch?v=uWusmdmc0to"
I'd recommend not to specify any audio format. If you specify an audio format then that probably is different from the original encoding and you will lose sound quality.
I use a bat file in windows, which passes the youtube url through to a preset list of arguments to download the highest quality audio stream and save it as MP3.
batch file contains:
youtube-dl -f bestaudio -x --audio-format mp3 %*
save the batch file in the same dir as youtube-dl (I save it as youtube-mp3.bat) in the same directory have ffmpeg installed
Whenever I want to download audio (Usually for me a youtube DJ Mix) I just pass the (youtube) URL to the batch file. Saves having to remember what arguments to use each time.
youtube-mp3 https://www.youtube.com/?v=xxxxxx
You can try to download audio with desired format by
youtube-dl -f m4a https://www.youtube.com/watch\?v\=ZtrEWtk9kbo
command.
Sometimes ffmpeg is required.
I personally currently use
youtube-dl -f bestaudio --extract-audio --audio-format mp3 --audio-quality 0
which is a nice combination of all the other answers.
I created the alias youtube-dl-music by typing
alias youtube-dl-music='youtube-dl -f bestaudio --extract-audio --audio-format mp3 --audio-quality 0'
Hopefully this helps those in a need for a quick command to copy and paste.
Check whether you have ffmpeg package installed from your side by below methods.
sudo apt install ffmpeg
sudo pip install ffmpeg
After above i got like below:
youtube-dl https://www.youtube.com/watch?v=6Qmnh5C4Pmo
[youtube] 6Qmnh5C4Pmo: Downloading webpage
[download] Destination: Pipenv Crash Course-6Qmnh5C4Pmo.f248.webm
[download] 100% of 33.19MiB in 00:26
[download] Destination: Pipenv Crash Course-6Qmnh5C4Pmo.f251.webm
[download] 100% of 15.15MiB in 00:09
[ffmpeg] Merging formats into "Pipenv Crash Course-6Qmnh5C4Pmo.webm"
Deleting original file Pipenv Crash Course-6Qmnh5C4Pmo.f248.webm (pass -k to keep)
Deleting original file Pipenv Crash Course-6Qmnh5C4Pmo.f251.webm (pass -k to keep)
Although you can get the best audio like this:
$ youtube-dl -f bestaudio https://www.youtube.com/watch?v=7E-cwdnsiow
You can also get the worst video with the best audio like this:
$ youtube-dl -f worstvideo+bestaudio https://www.youtube.com/watch?v=7E-cwdnsiow
Or you can separate the best audio and best video into two separate files like this:
$ youtube-dl -f bestvideo,bestaudio https://www.youtube.com/watch?v=7E-cwdnsiow
Better yet, you can seek out the best video within what you would consider reasonable and combine it with the audio:
$ youtube-dl -f 'bestvideo[height<=480]+bestaudio/best[height<=480]' https://www.youtube.com/watch?v=7E-cwdnsiow
This works for me for sites providing audio in the M4A (MPEG-4 audio) format (e.g. YouTube, Facebook video):
youtube-dl -f "bestaudio[ext=m4a]/best[ext=mp4]" -x "https://..."
Since it doesn't specify --audio-format, youtube-dl won't do any reencoding, thus it doesn't lose audio quality. However, it may happen the video is available in a better quality (with a different ext=...).
I want to convert a MOV from my Casio cam to mp4 using transcode. Why transcode? Because I also want to deshake the video in the same step.
When I use
ffmpeg -i in.MOV out.mp4
it works. When using
transcode -J stabilize -i in.MOV
or
transcode -J transform -i in.MOV -y ffmpeg -F mpeg4 -o out.mp4
I get hundreds of these errors:
[ffmpeg_audio] Error: avcodec_open2 failed
[adpcm_ima_wav # 0x1f7f180] Only 4-bit ADPCM IMA WAV files are supported
This looks to me as if transcode uses ffmpeg internally.
I could use ffmpeg to make it mp4 first and then use transcode to stabilize the video, but then it would be re-encoded twice which I would like to avoid.
This is what mplayer says about my MOV file:
MPlayer2 2.0-701-gd4c5b7f-2ubuntu2 (C) 2000-2012 MPlayer Team
Cannot open file '/home/koem/.mplayer/input.conf': No such file or directory
Failed to open /home/koem/.mplayer/input.conf.
Cannot open file '/etc/mplayer/input.conf': No such file or directory
Failed to open /etc/mplayer/input.conf.
Playing 1-original.MOV.
Detected file format: QuickTime / MOV (libavformat)
[lavf] stream 0: video (h264), -vid 0
[lavf] stream 1: audio (adpcm_ima_wav), -aid 0, -alang eng
Clip info:
major_brand: qt
minor_version: 537921536
compatible_brands: qt caqv
creation_time: 2017-01-02 23:31:38
Load subtitles in .
Failed to open VDPAU backend libvdpau_i965.so: cannot open shared object file: No such file or directory
[vdpau] Error when calling vdp_device_create_x11: 1
[ass] auto-open
Selected video codec: H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 [libavcodec]
Selected audio codec: ADPCM IMA WAV [libavcodec]
AUDIO: 44100 Hz, 2 ch, s16le, 352.8 kbit/25.00% (ratio: 44100->176400)
AO: [pulse] 44100Hz 2ch s16le (2 bytes per sample)
Starting playback...
VIDEO: 1920x1080 29.970 fps 15940.0 kbps (1992.5 kB/s)
VO: [xv] 1920x1080 => 1920x1080 Planar YV12
Colorspace details not fully supported by selected vo.
A: 1.1 V: 1.1 A-V: -0.000 ct: 0.000 0/ 0 16% 8% 1.6% 0 0
Exiting... (Quit)
How can I make it work with transcode without using ffmpeg first?
FFmpeg has a deshake as well as a stabilization filter. Get a new binary if yours doesn't.
To continue with your existing binaries, run
ffmpeg -i in.MOV -vcodec copy out.mp4
This will skip video re-encoding.
i have a system that is recording live stream via Wowza. I get from Wowza a .flv file with the record. The problem is, 5 minutes file is near to 50mb big. But when i look at some TV-Series that you can download from the net, they are 20 minutes, in mp4 and just like 150mb big. Whatever... Look, the stream input is like:
Input #0, flv, from 'rtmp://127.0.0.1/stream/test.stream':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0.0: Video: h264 (Constrained Baseline), yuv420p, 720x404 [PAR 1:1 DAR 180:101], 25 tbr, 1k tbn, 50 tbc
Stream #0.1: Audio: aac, 48000 Hz, stereo, s16
FFmpeg shows me something like this at the "session":
frame= 2721 fps= 27 q=-1.0 Lsize= 17188kB time=111.21 bitrate=1266.1kbits/s
Have you any idea how to use FFmpeg to convert the .FLV file in MP4 in same near to Quality but smaller filesize?
btw. i'm operating in linux ^^
Thanks
This is based on a linux mashine using the latest ffmpeg
using the following code and changing only the -crf value you are able to create various video clip sizes.lower number is higher quality.
The final video is compatible with all modern devices/services like native web players, ios devices , android devices, microsoft devices, ps3, xbox and more.
ffmpeg
-y //overwrite the file if it exists
-i INPUTFILE // replace with the input file
-metadata title=THETITLE // set a nice title, visible on modern devices
-metadata date=THEDATE // set a nice title, visible on modern devices
-c:v libx264 // use the h264 codec
-crf 21 // try different numbers between 18-26
-preset veryslow // placebo,slow,fast,ultrafast==big file
-tune film // tune it a little
-pix_fmt yuv420p // preferred on most modern devices
-profile:v main // preferred on most modern devices
-level 3.1 // preferred on most modern devices
-refs 4 // preferred on most modern devices
-c:a libfdk_aac // use aac
-metadata:s:a language=eng // set a language, visible on modern devices
-b:a 128k // audio bitrate 128k is like mp3 192k
-ar 48000 // 44100 ... whatever
-ac 2 // audiochannels
-movflags +faststart //move the metadata in the front of the video so it loads faster
OUTPUTFILE
If I don't make a mistake, Safari currently need MP4 (H.264/AAC) video encoded for the HTML5 <video> element.
So I tried to convert a video to this format with ffmpeg. However when I enter the shell command ffmpeg -i video.flv video.mp4, the returned error is :
Seems stream 0 codec frame rate
differs from container frame rate:
2000.00 (2000/1) -> 29.92 (359/12) Input #0, flv, from 'video.flv':
Duration: 00:05:01.20, start:
0.000000, bitrate: 66 kb/s
Stream #0.0: Video: h264, yuv420p, 320x240 [PAR 1:1 DAR 4:3], 66 kb/s,
29.92 tbr, 1k tbn, 2k tbc
Stream #0.1: Audio: aac, 22050 Hz, stereo, s16 Output #0, mp4, to
'video.mp4':
Stream #0.0: Video: mpeg4, yuv420p, 320x240 [PAR 1:1 DAR 4:3],
q=2-31, 200 kb/s, 90k tbn, 29.92 tbc
Stream #0.1: Audio: 0x0000, 22050 Hz, stereo, s16, 64 kb/s Stream
mapping: Stream #0.0 -> #0.0
Stream #0.1 -> #0.1 Unsupported codec
for output stream #0.1
An AAC codec is required but I'm quite newbie with ubuntu and I dont really now how to fix this problem. I'm using Ubuntu 9.10 Karmik Koala (for amd64).
Thank you very much. :)
http://handbrake.fr is a nice high level tool with a lot of useful presets for mp4 for iPod, PS3, ... with both GUI and CLI interfaces for Linux, Windows and Mac OS X.
It comes with its own dependencies as a single statically linked fat binary so you have all the x264 / aac codecs included.
$ HandBrakeCLI -Z Universal -i myinputfile.mov -o myoutputfile.mp4
To list all the available presets:
$ HandBrakeCLI -z
Software patents led Debian/Ubuntu to disable the H.264 and AAC encoders in ffmpeg. See /usr/share/doc/ffmpeg/README.Debian.gz.
So go install x264, mplayer/mencoder, and Nero's AAC encoder. (Or, if you want to use all Free software, and don't care so much about audio quality, then sudo aptitude install faac.)
I don't remember if the medibuntu package of mencoder includes x264 vid encoding, since I build my own from git x264 and svn mplayer sources. (x264 is very actively developed, with significant quality and speed improvements frequently added.)
http://git.videolan.org/?p=x264.git;a=summary
x264 is also packaged, but you should check that it's up to date enough to include weightp with recent bugfixes, and even more recent speed improvements...
Or if you're already willing to convert from .flv, instead of going from the high-quality source the flv was made from, then probably whatever recent version of x264 you can find will be fine.
You're trying to convert a (rather rare) .flv file that (already) contains H.264 video and AAC audio.
Formatting your console's output as FFmpeg brings out these details.
Input #0, flv, from 'video.flv':
Duration: 00:05:01.20, start: 0.000000, bitrate: 66 kb/s
Stream #0.0: Video: h264, yuv420p, 320x240 [PAR 1:1 DAR 4:3], 66 kb/s, 29.92 tbr, 1k tbn, 2k tbc
Stream #0.1: Audio: aac, 22050 Hz, stereo, s16
The original flv is converted to an .mp4 file with H.264 video and AAC audio (just like the original .flv):
Output #0, mp4, to 'video.mp4':
Stream #0.0: Video: mpeg4, yuv420p, 320x240 [PAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 90k tbn, 29.92 tbc
Stream #0.1: Audio: 0x0000, 22050 Hz, stereo, s16, 64 kb/s
Because the audio and video data in the .flv are already in the format/codecs you need for the .mp4, you can just copy everything to the new .mp4 container. This process will be massively faster than decoding and reencoding everything:
ffmpeg -i video.flv -vcodec copy -acodec copy video.mp4
or more simply:
ffmpeg -i video.flv -codec copy video.mp4
##The real error you're getting is:##
Unsupported codec for output stream #0.1
Which means FFmpeg can't convert audio (stream #0.1) to AAC.
You can skip the error by:
copying the audio data since it's already AAC encoded (use the copy command above)
or you can solve the error by:
using a FFmpeg build with AAC decode/encode support. FFmpeg currently supports 4 AAC libraries (see FFmpeg and AAC Encoding Guide).
For more details you should also read Converting FLV to MP4 With FFmpeg The Ultimate Guide
You need to recompile ffmpeg (from source) so that it supports x264. If you follow the instructions in this page, then you will be able to peform any kind of conversion you want.
You can also try adding the Motumedia PPA to your apt sources and update your ffmpeg packages.
Had this problem recently with converting nasty WMV into Final Cut Pro X for editing. Flow player can do it but it leaves a water mark, so I fiddled a bit with ffmpeg till I got something going.
First install ffmpeg - I used
brew install ffmpeg
Obviously you need brew installed first, google that bit.
Next I wrote a simple command line script with the following content - you can substitute the $1 for an input / output file or just create a shell script file...
vi convert.sh
Paste.
echo "Pass one"
ffmpeg -y -i "$1" -c:v libx264 -preset medium -b:v 1555k -pass 1 -c:a libfaac -b:a 256k -f mp4 /dev/null &&
echo "Pass two"
ffmpeg -i "$1" -c:v libx264 -preset medium -b:v 1555k -pass 2 -c:a libfaac -b:a 256k "$1.mp4"
Then to convert your video...
sh convert.sh myvideofile.wmv
If all went well you should see a new file called myvideofile.wmv.mp4.
Hope that works for you.
You need to compile ffmpeg with an AAC encoder. You can find one at AudioCoding.
Try This one:: Libav in Linux
Installation: run command
sudo apt-get install libav-tools
Video conversion command::Go to folder contains the video and run in terminal
avconv -i oldvideo.flv -ar 22050 convertedvideo.mp4