76 lines
2.4 KiB
Markdown
76 lines
2.4 KiB
Markdown
|
Neat comparison commands
|
||
|
------------------------
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
this command will take a input video and transcode it for every crf value in a range
|
||
|
|
||
|
crfleveltest.sh
|
||
|
```
|
||
|
#!/bin/bash
|
||
|
|
||
|
for i in {0..63}
|
||
|
do
|
||
|
echo da real time bro $i >> timetime
|
||
|
date >> timetime
|
||
|
ffmpeg -i originalencoding.mkv -c:a copy -c:v libsvtav1 -preset 8 -crf $i svtav1/crftest/svtav1_$i.mkv
|
||
|
#echo \n >> timetime
|
||
|
done
|
||
|
```
|
||
|
this will take a specific frame out off all the videos in a folder which is useful for comparing the crf values on a specific frame
|
||
|
frameextractor.sh
|
||
|
```
|
||
|
#!/bin/bash
|
||
|
|
||
|
output_directory="png"
|
||
|
|
||
|
for video in *mkv; do
|
||
|
filename=$(basename -- "$video")
|
||
|
filename_no_ext="${filename%.*}"
|
||
|
ffmpeg -ss 00:00:10 -i "$video" -vframes 1 "$output_directory/$filename_no_ext.png"
|
||
|
done
|
||
|
```
|
||
|
this will take all the file names of the pngs and put them into subtitles so you cam see what video (crf value typically) the current frame was from
|
||
|
subtitles.py
|
||
|
```
|
||
|
import os
|
||
|
|
||
|
# Assuming files are in the current directory.
|
||
|
# Modify this path to the location of your PNG files if needed.
|
||
|
files = sorted([f for f in os.listdir('.') if f.endswith('.png')])
|
||
|
|
||
|
# Start time for each subtitle in seconds
|
||
|
start_time = 0.0
|
||
|
|
||
|
# The duration each subtitle is displayed for in seconds
|
||
|
duration = 0.1
|
||
|
|
||
|
with open('subtitles.srt', 'w') as f:
|
||
|
for i, filename in enumerate(files, start=1):
|
||
|
# Format start and end times
|
||
|
start_h = int(start_time // 3600)
|
||
|
start_m = int((start_time % 3600) // 60)
|
||
|
start_s = int(start_time % 60)
|
||
|
start_ms = int(round((start_time % 1) * 1000))
|
||
|
start = "{:02d}:{:02d}:{:02d},{:03d}".format(start_h, start_m, start_s, start_ms)
|
||
|
|
||
|
end_time = start_time + duration
|
||
|
end_h = int(end_time // 3600)
|
||
|
end_m = int((end_time % 3600) // 60)
|
||
|
end_s = int(end_time % 60)
|
||
|
end_ms = int(round((end_time % 1) * 1000))
|
||
|
end = "{:02d}:{:02d}:{:02d},{:03d}".format(end_h, end_m, end_s, end_ms)
|
||
|
|
||
|
# Write subtitle entry
|
||
|
f.write(f"{i}\n{start} --> {end}\n{filename}\n\n")
|
||
|
|
||
|
# Update start time for next subtitle
|
||
|
start_time += duration
|
||
|
```
|
||
|
this will combine all the pngs and subtitles to a video to be watched just make sure the framerates match between this command and rhe ones specified in the subtitle command
|
||
|
pngcombiner
|
||
|
```
|
||
|
ffmpeg -framerate 10 -i svtav1_%02d.png -i subtitles.srt -c:v libx264 -crf 10 output.mkv
|
||
|
```
|