kingwingfly / fav

Back up your favorite bilibili resources with CLI.
https://crates.io/crates/fav_core
MIT License
85 stars 1 forks source link

[New Feature] Commands to support mp4 to mp3 conversion #63

Closed acking-you closed 5 months ago

acking-you commented 5 months ago

Is your feature request related to a problem? Please describe. No

Describe the solution you'd like I have a lot of live music videos in my bilibili fav that I would like to be able to convert to audio format to make it easier for me to listen to it in other music programs.

Describe alternatives you've considered I think ffmpeg already provides this capability, so implementing it shouldn't be very difficult. What we might be uncertain about now is which command Fav needs to add to support it

Additional context No

kingwingfly commented 5 months ago

Actually, fav download video and audio separately and merge them with ffmpeg. You may think add fav pull --audio naturally.

However, current implementation is through SaveLocal trait, which only supports one kind of resource.

https://github.com/kingwingfly/fav/blob/729e9fc6b30fd9559032ac4cb407de26385f301e/fav_utils/src/bili/local.rs#L26-L27

In this case, it only supports videos.

Although it's easy to add a download_audio method, it seems not graceful, and fav daemon, which is the command I used most, cannot know whether I only want audio or not, maybe leading fav to do wrong thing.

Then I think the best way may be following the Unix Philosophy:

for file in *.mp4; do ffmpeg -i "$file" -vn -c:a copy "${file%.mp4}.m4a"; done

Because audios from bilibili are aac-encoded, so just copy as m4a is OK.

acking-you commented 5 months ago

Actually, fav download video and audio separately and merge them with ffmpeg. You may think add fav pull --audio naturally.

However, current implementation is through SaveLocal trait, which only supports one kind of resource.

https://github.com/kingwingfly/fav/blob/729e9fc6b30fd9559032ac4cb407de26385f301e/fav_utils/src/bili/local.rs#L26-L27

In this case, it only supports videos.

Although it's easy to add a download_audio method, it seems not graceful, and fav daemon, which is the command I used most, cannot know whether I only want audio or not, maybe leading fav to do wrong thing.

Then I think the best way may be following the Unix Philosophy:

for file in *.mp4; do ffmpeg -i "$file" -vn -c:a copy "${file%.mp4}.m4a"; done

Because audios from bilibili are aac-encoded, so just copy as m4a is OK.

Very well, I will try to use a shell script to replace this process. Meanwhile, your answer has made me very interested in this downloading process.