Giter VIP home page Giter VIP logo

Comments (25)

chrisbra avatar chrisbra commented on June 19, 2024 1

https://github.com/chrisbra/youtube2audio uses youtube-dl or clive to extract videos from youtube and convert it to mp3 or ogg.

Christian

from youtube-dl.

rg3 avatar rg3 commented on June 19, 2024

Originally by "obeythepenguin":

youtube-dl just downloads the raw video file; there's no conversion. However, there are some front-ends that can do conversion. I'm developing one called youtube2mp3 ( http://youtube2mp3.sourceforge.net/ ), although I don't use a Mac so I don't know how well it works on OS X. There are, of course, plenty of others.

from youtube-dl.

rg3 avatar rg3 commented on June 19, 2024

The internal code in youtube-dl allows for postprocessing, so anybody can implement a postprocessor to extract the audio from the video file using an external tool (like obeythepenguin said, youtube-dl just downloads the raw video file without looking at its internal format). I'd gladly merge that code into the program if someone is willing to maintain that part. I haven't implemented any postprocessing yet because I don't postprocess any video.

I'm leaving the issue open just in case someone wants me to merge it.

from youtube-dl.

rg3 avatar rg3 commented on June 19, 2024

Originally by "rmunn":

In the meantime, one easy way to extract the audio from a downloaded video file is to use Audacity (http://audacity.sourceforge.net/). Open the .mp4 in Audacity and it will automatically extract the audio for you -- then just do File -> Export and save it as an .mp3. (Remember to download the LAME DLL for Audacity so it can save MP3's, of course (see http://audacity.sourceforge.net/help/faq?s=install&item=lame-mp3 for details).

from youtube-dl.

rg3 avatar rg3 commented on June 19, 2024

Originally by anonymous:

ffmpeg.exe -i My_Chemical_Romance_-_Famous_Last_Words.flv famous_last_word.mp3

via http://www.catonmat.net/blog/how-to-extract-audio-tracks-from-youtube-videos/

from youtube-dl.

rg3 avatar rg3 commented on June 19, 2024

Originally by anonymous:

And add -ab parameter to ffmpeg to set the audio bitrate (default is 64k).

ffmpeg -ab 192k -i <input.file> <output.file>

from youtube-dl.

rg3 avatar rg3 commented on June 19, 2024

Originally by anonymous:

Or with mplayer:

$ mplayer -dumpaudio -dumpfile out.mp3

Maybe to add a generic postprocessor that calls external programs like mplayer, ffmpeg or what ever. The command should also accept "variables" similar to the litteral titel formating rules, e.g

$ youtube-dl http://www.youtube.com/watch?v=foobar -i "mplayer -dumpaudio %(filename)s -dumpfile %(title)s.mp3"

Maybe it is just the work of adding some lines to the program ...

Alex

from youtube-dl.

lx5415 avatar lx5415 commented on June 19, 2024

I've written a program (PC) to extract an mp3 from the video file. If anyone is interested email me [email protected]

from youtube-dl.

rg3 avatar rg3 commented on June 19, 2024

The issue tracker is no place for promoting your own software. mplayer can trivially extract the audio from the video file, and it works on many platforms. The issue at hand here is if someone is willing to code a postprocessor that uses it, or other software, to extract the MP3 and integrate it with youtube-dl.

from youtube-dl.

lx5415 avatar lx5415 commented on June 19, 2024

i forgot to mention that it is free and open and it uses youtube_dl. I am in no way trying to sell anything. I am just trying to contribute to the open source community. This may or may not be warranted in this forum. Sorry!

from youtube-dl.

dz0ny avatar dz0ny commented on June 19, 2024

Hi simple implementation can be found at https://github.com/dz0ny/YoutubeDl-Server

from youtube-dl.

ph03 avatar ph03 commented on June 19, 2024

I'd loved to see an option that rg3 suggested that calls a given program with the downloaded file after succesful download. I automatically download some videos every day but want to reencode them at night for my Android phone with optimal settings and this would be very easy using such an option. I think i'll implement it by myself and let you know if it works.

from youtube-dl.

dz0ny avatar dz0ny commented on June 19, 2024

Implement class
class ToFFmpegMP4(youtubedl.PostProcessor):
def run(self, inf):
command = "/usr/bin/ffmpeg -i '%s' -vcodec libx264 -vpre slow -vpre ipod640 -b 2048k -acodec libfaac -ab 96k '%s' && rm '%s' &" % (inf["filepath"] ,VideoPath + "/" + inf["title"] + ".mp4", inf["filepath"])
os.system(command) ## WARNING shell injection
return inf

then add
ffmpeg = ToFFmpegMP4()
fd.add_post_processor(ffmpeg)

again see my project, for more complete example https://github.com/dz0ny/YoutubeDl-Server/blob/master/youtubedl-server.py

from youtube-dl.

rg3 avatar rg3 commented on June 19, 2024

dz0ny,

Why don't you clean that part of the code a little bit, avoid the command injection problem and submit a postprocessor to be integrated with the program, activated by a command line switch?

That way every youtube-dl user would benefit from the postprocessor.

from youtube-dl.

dz0ny avatar dz0ny commented on June 19, 2024

@rg3 would something like this, be sufficient?

Transcoding Options (uses ffmpeg):
-T FILE_TYPE, --transcode_to=FILE_TYPE
                    transcode to specific video or audio format (example:
                    mp3 mp4 mov mkv)
--transcode_extra=ARGS
                    pass additional parameters to ffmpeg (example: -vcodec
                    libx264 -vpre slow -vpre ipod640 -b 2048k -acodec
                    libfaac -ab 96k)

from youtube-dl.

ph03 avatar ph03 commented on June 19, 2024

@dz0ny I would rather also like to be able to call a costum command with the downloaded file like

-i COMMAND, --excecute=COMMAND
excecutes the command given by the string COMMAND by
replacing '%f' with the downloaded file name.

I think this would be more flexible as everyone can call his own commands (e.g., not only for transcoding but to schedule other events on downloaded files, e.g., movement etc). I need it because I would like to be able to do two pass encodings which would not be possible with your single ffmpeg transcode command. But the -T option should still be usefull in many situations.

from youtube-dl.

ph03 avatar ph03 commented on June 19, 2024

B.t.w. yesterday I implemented my transcoder event as a postprocessor sucessfully in youtube-dl. However, I realized that the postprocessors are also called on already existing files due to the success state "True":

self.report_file_already_downloaded(filename)
return True

and for my application it made more sense to mark already downloaded files as not successful to not make the transcoder work on that file again.

from youtube-dl.

dz0ny avatar dz0ny commented on June 19, 2024

Hi just quick thought how about

Post download action:
-C COMMAND, --command=COMMAND
command to run after file has been downloaded
(example: "sh -c cp /tmp/<title>.tmp && rm
" )

or implement command chaining -T mp4 --transcode_extra ... -T mkv --transcode_extra ...

from youtube-dl.

dz0ny avatar dz0ny commented on June 19, 2024

Check https://github.com/dz0ny/youtube-dl

youtube-dl http://www.youtube.com/watch?v=BRHRssf3B6o -T mp4 -C "rm <filepath>"
[youtube] Setting language
[youtube] BRHRssf3B6o: Downloading video webpage
[youtube] BRHRssf3B6o: Downloading video info webpage
[youtube] BRHRssf3B6o: Extracting video information
[download] Destination: BRHRssf3B6o.flv
[download] 100.0% of 966.33k at  103.70k/s ETA 00:00 
[transcode] Started transcoding of BRHRssf3B6o.flv to BRHRssf3B6o.mp4
[transcode] Completed transcoding of BRHRssf3B6o.flv to BRHRssf3B6o.mp4
[PostProcessor] Started command rm BRHRssf3B6o.flv
[PostProcessor] Finnished command rm BRHRssf3B6o.flv

from youtube-dl.

rg3 avatar rg3 commented on June 19, 2024

Custom commands can be a good thing but they can't replace extracting the audio from the video file in the form of a simple option that would call mencoder or ffmpeg to losslessly dump the audio stream to a file, then delete the original video, all by itself.

Dumping the audio stream could have an extra option to choose if you want to preserve the original format, or force it to be in MP3 or AAC, losslessly when possible. For example, I can run the following command in the example above:

$ ffmpeg -i BRHRssf3B6o.flv
...
    Stream # 0.1: Audio: aac, 22050 Hz, mono, s16, 47 kb/s

Knowing it's in AAC lets me run:

$ ffmpeg -i BRHRssf3B6o.flv -vn -acodec copy test.m4a

And get:

$ file test.m4a 
test.m4a: ISO Media, MPEG v4 system, iTunes AAC-LC

Which is the original audio in MPEG v4 container, playable by many portable devices. I think people interested in this bug would like such a feature to do all this work automatically for them.

from youtube-dl.

dz0ny avatar dz0ny commented on June 19, 2024

I think such feature as you describe(everything done automatically) is for people who use GUI applications, those who use CLI tools prefer more options and more control over the process. BUT most transcoders have presents for devices or user-cases, have a look for example Handbrake https://trac.handbrake.fr/wiki/BuiltInPresets.

I would propose something like -T ipad --preserve-original --strip-video, maybe we could use handbrake for this and not ffmpeg? How is support for ffmeg on OSX?

Is Handbrake better choice for this, because is multiplatform and has solid codebase (ffmpeg is in some distributions stripped of proprietary codecs)?

For other user cases "Custom commands" are must for such tool, as youtube-dl is.

from youtube-dl.

ph03 avatar ph03 commented on June 19, 2024

@dz0ny

Your -C COMMAND, --command=COMMAND option works great, thanks, just what I needed. Now I check for an already downloaded file by myself in the called script to not recode an already coded file once again.
Is it possible that this commit could be importet to this original youtoube-dl branch or will they keep diverging?

from youtube-dl.

dz0ny avatar dz0ny commented on June 19, 2024

Just to note -C has following replaceble variables

upload_date "Jan 7 2011"
description "No description available."
format "35"
url "http://v12.lscache6.c.youtube.com/v..."
title "Barron Falls Queensland"
player_url "http://s.ytimg.com/yt/swfbin/watch_as3-vflO2K4B9.swf"
filepath "Tz9ihXnS9s4.flv"
thumbnail "http://i1.ytimg.com/vi/Tz9ihXnS9s4/default.jpg"
ext "flv"
stitle "Barron_Falls_Queensland"
uploader "newrealm06"
id "Tz9ihXnS9s4"

from youtube-dl.

rg3 avatar rg3 commented on June 19, 2024

Those wanting so much "control over the process" can script something outside youtube-dl.

from youtube-dl.

rg3 avatar rg3 commented on June 19, 2024

Add an audio extracting PostProcessor using ffmpeg (closed by 3072fab)

from youtube-dl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.