- 1 year ago
How to modify the title metadata based on the directory name with FFMPEG?
To modify the title metadata of a media file based on the directory name using FFmpeg, you can use the -metadata
option to set the new title value. Here's an example command:
bashffmpeg -i input.mp4 -metadata title="New Title" -c copy output.mp4
In this example, replace input.mp4
with the path to your input media file and output.mp4
with the desired output file name. The -c copy
option is used to copy the video and audio streams without re-encoding, ensuring that the quality remains unchanged.
To set the title based on the directory name dynamically, you can incorporate the directory name using a scripting language or a command substitution mechanism provided by your operating system's shell. Here's an example using Bash on Linux/Mac:
bashdir_name=$(basename "$(dirname "$PWD")")
ffmpeg -i input.mp4 -metadata title="$dir_name" -c copy output.mp4
This command uses basename
and dirname
to extract the name of the parent directory of the current working directory ($PWD
) and assigns it to the dir_name
variable. Then, the title
metadata is set to the value of dir_name
using the -metadata
option.
Please note that the command and syntax may vary depending on your operating system and the shell you are using. Adjust the command accordingly based on your specific requirements and operating system.
Remember to have FFmpeg installed and accessible in your system's PATH to execute the command successfully.