Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
batch converting of videos
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
Linubie
Guru
Guru


Joined: 11 Jun 2004
Posts: 367

PostPosted: Fri May 24, 2024 11:40 am    Post subject: batch converting of videos Reply with quote

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
View user's profile Send private message
NichtDerHans
Tux's lil' helper
Tux's lil' helper


Joined: 27 Jan 2023
Posts: 147

PostPosted: Fri May 24, 2024 11:46 am    Post subject: Reply with quote

ffmpeg <3

https://shotstack.io/learn/how-to-use-ffmpeg/

Use "mediainfo" instead of "exiftool" to get infos.
Back to top
View user's profile Send private message
Ralphred
Guru
Guru


Joined: 31 Dec 2013
Posts: 517

PostPosted: Fri May 24, 2024 1:04 pm    Post subject: Reply with quote

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
View user's profile Send private message
Linubie
Guru
Guru


Joined: 11 Jun 2004
Posts: 367

PostPosted: Fri May 24, 2024 1:12 pm    Post subject: Reply with quote

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
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 21918

PostPosted: Fri May 24, 2024 2:18 pm    Post subject: Reply with quote

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
View user's profile Send private message
logrusx
Veteran
Veteran


Joined: 22 Feb 2018
Posts: 1751

PostPosted: Fri May 24, 2024 4:18 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum