r/ffmpeg • u/ilikeyorushika • 3d ago
need help on batch transcode.
so i need to transcode these to 720P 60FPS with my amd gpu. i saved the command to do so ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i NORM0003.MP4 -c:v h264_vaapi -vf scale_vaapi=w=1920:h=1080 -b:v 10M -r 30 norm03_30fps_1080.mp4 .
i wanted to try batch transcode following this script, from this link. what do i need to change, or how i incorporate the command i got above?.
#!/bin/bash
# Specify the input and output formats
input_format="mp4"
output_format="mkv"
# Loop through all files with the input format
for file in *.$input_format; do
# Extract the base name without the extension
base_name=$(basename "$file" .$input_format)
# Construct the output file name
output_file="${base_name}.${output_format}"
# Use ffmpeg to convert the file
echo "Converting file: $file"
ffmpeg -loglevel quiet -i "$file" "$output_file"
echo "Converted $file to $output_file"
done
2
Upvotes
7
u/erroneousbosh 3d ago
Simpler than that.
for i in *.MP4; do ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i $i -c:v h264_vaapi -vf scale_vaapi=w=1920:h=1080 -b:v 10M -r 30 yourprefixhere_$i; doneYou could also make a new directory
mkdir transcodedand then say... -r 30 transcoded/$i; doneat the end.1
u/bluesyowl 3d ago
why not cpu?
3
u/Sopel97 3d ago
that's going to look abhorrent
just use x264 slow, it's probably gonna be faster at this resolution anyway
btw. your command does 1080p30
2
u/SimpleTeacher5046 3d ago
I just ask chatgpt for a bash script for a for loop.
If I'm frisky I ask for parallel transcoding and it usually works
1
u/LocalNightDrummer 3d ago
Honestly ask any decent LLM it's gonna give you a better answer than anyone is willing to give here. Not being mean or anything, but you could objectively do the research with a very good result thus way, don't hesitate to ask an LLM for this kind or boring automation scripts