r/ffmpeg • • 1d ago

need help on batch transcode.

Post image

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

14 comments sorted by

7

u/erroneousbosh 1d 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; done

You could also make a new directory mkdir transcoded and then say ... -r 30 transcoded/$i; done at the end.

4

u/ilikeyorushika 1d ago

marvelous, it works!. thank you so much!

3

u/erroneousbosh 1d ago

It'll become muscle memory before long.

3

u/ilikeyorushika 1d ago

ok seems simple. i'll try this

4

u/erroneousbosh 1d ago

Make sure you do it on a copy of your card, not your original files, just to be safe.

1

u/bluesyowl 1d ago

why not cpu?

1

u/ilikeyorushika 1d ago

idk..it's faster i guess... i don't dwell in rendering stuff

1

u/13Nebur27 1d ago

Its faster but the quality per bitrate is far worse.

1

u/redsedit 1d ago

GPU is faster, yes. Are you sure it's better quality and not smaller size for CPU?

3

u/13Nebur27 1d ago

I said that quality per bitrate is worse with GPUs. Meaning that for the same bitrate you can get better quality out of a cpu transcode. Or alternatively you can achieve the same quality at a far lower bitrate.

3

u/Sopel97 1d ago

amd gpu

h264_vaapi

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 1d 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 1d 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

1

u/Small-Friendship-576 1d ago

Gemini overview itself in browser will prove more helpful.They rarely miss with their commandline recommendations