使用FFmpeg将FLAC递归转换为MP3,同时在Windows上保留元数据和目录结构 [英] Recursively Converting FLAC to MP3 Using FFmpeg While Maintaining Metadata and Directory Structure on Windows

查看:74
本文介绍了使用FFmpeg将FLAC递归转换为MP3,同时在Windows上保留元数据和目录结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用FFmpeg将音乐库中的所有.flac文件转换为.mp3文件,同时保持原始文件的元数据和目录结构.到目前为止,我已经完成了所有工作,除了维护目录结构.

到目前为止,我有:

  @echo关闭rem将原始目录结构从F:\ Music复制到D:\ Musicxcopy/T%1%2rem将具有.flac扩展名的文件从F:\ Music递归转换为D:\ Music中的.mp3为(* .flac)中的/R%1 %% i做(echo当前正在转换"%%〜nxi"ffmpeg -v安静-i"%% i" -q:a 0 -map_metadata 0 -id3v2_version 3 -write_id3v1 1%2 \ %%〜ni.mp3")回声完成.暂停 

我觉得我的问题来自将FFmpeg输出为%2 \ %%〜ni.mp3" ,但是我无法获得它来维护原始目录结构.我已经将dpni作为输出的选项,但是它不能正确转换.

.bat是从命令行执行的,它是 convert F:\ Music D:\ Music

原始目录中的所有音乐的结构均为F:\ Music \ Artist Name \ Album Name \ Song.flac,我希望它最终以D:\ Music \ Artist Name \ Album Name \ Song.mp3结尾./p>

或者,是否可以将.flac转换为与源文件位于同一目录中的.mp3,然后删除flac?

解决方案

当for/R递归到子目录时,原始%2不包含这些子文件夹名称,因此请尝试:

  ffmpeg -v quiet -i"%%〜fi" -q:a 0 -map_metadata 0 -id3v2_version 3 -write_id3v1 1%〜d2 %%〜pni.mp3" 

I'm trying to use FFmpeg to convert all of the .flac's in my music library to .mp3's while maintaining the metadata and directory structure of the original files. I've got everything working so far except for maintaining the directory structure.

So far I have:

@echo off
rem Copies the original directory structure from F:\Music to D:\Music
xcopy /T %1 %2
rem Recursively converts files with .flac extension from F:\Music to .mp3 in D:\Music
for /R %1 %%i in (*.flac) do (
    echo Currently converting "%%~nxi"
    ffmpeg -v quiet -i "%%i" -q:a 0 -map_metadata 0 -id3v2_version 3 -write_id3v1 1 "%2\%%~ni.mp3"
)
echo Completed.
pause

I feel like my issue is coming from having my FFmpeg output as "%2\%%~ni.mp3" , however I can't get it to maintain the original directory structure. I have played around with dpni as options for the output, but then it does not convert correctly.

The .bat is being executed from the command line as convert F:\Music D:\Music

All music in the original directory has the structure F:\Music\Artist Name\Album Name\Song.flac and I want it to end up as D:\Music\Artist Name\Album Name\Song.mp3.

Alternatively, is there a way to convert the .flac to an .mp3 within the same directory as the source file and then delete the flac?

解决方案

When the for /R recurses into subflders the original %2 doesn't include these subfolder names, so try:

ffmpeg -v quiet -i "%%~fi" -q:a 0 -map_metadata 0 -id3v2_version 3 -write_id3v1 1 "%~d2%%~pni.mp3"

这篇关于使用FFmpeg将FLAC递归转换为MP3,同时在Windows上保留元数据和目录结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆