View previous topic :: View next topic |
Author |
Message |
Linubie Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/153658112433bad3820cb0.gif)
Joined: 11 Jun 2004 Posts: 367
|
Posted: Fri May 24, 2024 11:40 am Post subject: batch converting of videos |
|
|
Hi,
I have several mp4 videos with vp09 which can't be played by some friends in my signal group.
So my Idea was to convert them to a different compressor e.g avc1.
to find the vp09 videos I used:
Code: | exiftool *.mp4 | grep vp9
======== 1dd561ec146778d0-vp9.mp4
File Name : 1dd561ec146778d0-vp9.mp4
Compressor Name : Lavc59.37.100 libvpx-vp9
======== 2b79cb6563266a3e-vp9.mp4
File Name : 2b79cb6563266a3e-vp9.mp4
Compressor Name : Lavc59.37.100 libvpx-vp9 |
This is an example the list is much longer.
That gives me a list of the videos that needs to be converted.
So how can I format the output of the used command to convert the files in a batch.
Or are there better and easier ways to solve this?
Short side note I never have done some format converting in a terminal or batch so i am a complete beginner.
Thank you _________________ Mircosoft software is like having sex with a stranger, you always have to be careful not to get infected with something... |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
NichtDerHans Tux's lil' helper
![Tux's lil' helper Tux's lil' helper](/images/ranks/rank_rect_1.gif)
Joined: 27 Jan 2023 Posts: 147
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Ralphred Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
Joined: 31 Dec 2013 Posts: 517
|
Posted: Fri May 24, 2024 1:04 pm Post subject: |
|
|
Do all the vp9 files have vp9 in the filename?
Are they all in the same directory, or do you need to "walk" the subdirectories too? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Linubie Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/153658112433bad3820cb0.gif)
Joined: 11 Jun 2004 Posts: 367
|
Posted: Fri May 24, 2024 1:12 pm Post subject: |
|
|
No all in the same directory with no subdirectories and yes they all have vp9 in the naming scheme but my idea was to look for the vp9 compression is better when files later don't have that naming scheme. _________________ Mircosoft software is like having sex with a stranger, you always have to be careful not to get infected with something... |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Hu Administrator
![Administrator Administrator](/images/ranks/rank-admin.gif)
Joined: 06 Mar 2007 Posts: 21918
|
Posted: Fri May 24, 2024 2:18 pm Post subject: |
|
|
Untested, but this should get you started: Code: | #!/bin/bash
set -eu
convert_vp9_file() {
file_to_convert="$1"
printf 'FIXME: add a proper conversion command for file %q\n' "$file_to_convert"
}
for candidate_filename; do
if exiftool "$candidate_filename" | grep -q 'Compressor Name : Lavc59.37.100 libvpx-vp9'; then
convert_vp9_file "$candidate_filename"
fi
done
| Usage: ./hu-script.sh *.mp4
You will need to replace that printf with a call to ffmpeg or similar. I assume you know how to do the conversion, and you only need help identifying which files to convert.
There are optimizations possible, such as running these in parallel (if you have the CPU power and disk bandwidth to support that).
If you want more help, ask. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
logrusx Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
Joined: 22 Feb 2018 Posts: 1751
|
Posted: Fri May 24, 2024 4:18 pm Post subject: |
|
|
Hu wrote: | Untested, but this should get you started: Code: | #!/bin/bash
set -eu
convert_vp9_file() {
file_to_convert="$1"
printf 'FIXME: add a proper conversion command for file %q\n' "$file_to_convert"
}
for candidate_filename; do
if exiftool "$candidate_filename" | grep -q 'Compressor Name : Lavc59.37.100 libvpx-vp9'; then
convert_vp9_file "$candidate_filename"
fi
done
| Usage: ./hu-script.sh *.mp4
You will need to replace that printf with a call to ffmpeg or similar. I assume you know how to do the conversion, and you only need help identifying which files to convert.
There are optimizations possible, such as running these in parallel (if you have the CPU power and disk bandwidth to support that).
If you want more help, ask. |
Code: | mediainfo --Output="Video;%Format%" "$file_to_convert" |
I'm not sure if Format will do the job, I don't have vp9 videos on my disposal to test, but the ones I have have different headers. It might be CodecID (--Output="Video;%CodecID%") for example.
@Linubie, run mediainfo without parameters on several files to see what's the situation and if it's consistent over files.
Best Regards,
Georgi |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|