Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function copy_metadata
- {
- if [ $# -eq 2 ]
- then
- has_video=$(ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1 -pretty "$1")
- has_audio=$(ffprobe -v error -select_streams a -show_entries stream=codec_name -of default=noprint_wrappers=1 -pretty "$1")
- if [[ $has_video = *"codec_name"* ]] && [[ $has_audio = *"codec_name"* ]]
- then
- setting="-map_metadata:s:v 0:s:v -map_metadata:s:a 0:s:a"
- elif [[ $has_video = *"codec_name"* ]] && [[ -z "$has_audio" ]]
- then
- setting="-map_metadata:s:v 0:s:v"
- elif [[ -z "$has_video" ]] && [[ $has_audio = *"codec_name"* ]]
- then
- setting="-map_metadata:s:a 0:s:a"
- fi
- outname="${2%.*}"
- outname_ext="${2##*.}"
- ffmpeg -i "$1" -i "$2" -map 1 -c copy -map_metadata 0 ${setting} "${outname}"_new.$outname_ext
- else
- echo "\nTwo input files needed, first the one with the metadata that will be copied from and second the one without metadata that media streams will be copied from\n"
- fi
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement