[SCRIPT] Batch convert YUV 4:4:4 videos to YUV 4:2:0 in Retropie/Linux
-
@clyde Thank you for this.
Until now, I had to test each video manually in Emulation station and then go back to pc, copy and recode each single one by VCL player and update videos. And I did not know what caused this problem. You really helped me a lot with this, plus I know the reason why those videos did not work. -
@thelostsoul My pleasure. :) Be sure to check out @hiulit's script, too. It has way more options than mine.
-
Update: 1. The script now creates the target folder "converted" if it doesn't exists. 2. Added the information about the
bin
folder to the opening post. -
@clyde Funny, did you hack me? I did this update too first time creating it. :P But thanks anyway.
Just thinking about it, is it possible to integrate this script to ReteroPie sselph scraper? It could be an optional feature to execute it automatically after scraping.
-
@thelostsoul Interesting idea, I'll look into that later when I have more time.
-
@thelostsoul @Clyde There's already a convert function in Sselph Scrapper
-convert_videos
. But the script must be run via the terminal, something like this:/opt/retropie/supplementary/scraper/scraper -convert_videos
See the RetroPie documentation: https://github.com/retropie/retropie-setup/wiki/scraper#parameter-list
P.S. I don't know exactly what it does, it only says "Convert videos for the Raspberry Pi" and Handbrake must be installed.
-
@hiulit It's a script, so we could inspect it for its function. Alas, my Raspberry isn't operational at this time, because my upright cabinet is in its last stages to completion, but currently dismantled.
-
In case anyone in this thread is interested, I released v2.0.0 of RetroPie Convert Videos.
-
Just released yet another version of RetroPie Convert Videos (v2.1.0).
-
As I follow the instructions I get this. /home/pi/444p-to-420p.sh: 3 /home/pi/444p-to-420p.sh: Syntax error: word unexpected (expecting "do")
For a layman like me this is quite the frustration. It expects the word "do" on line 3? Oh. Okay! It's like, the only word on line 3, so I don't know what more you expect, Mr. fussy computer pants. Please help. This is the last thing I have to do to get my retropie image perfect.
-
@Quackwalks Hm … it works on the Linux system on my Laptop (KDE Neon based on Ubuntu 18.04). I can test it on my Retropie system this evening.
What system did you create and/or are you running the script on? What were the exact steps you took to create the file? Could you please post your script into a codeblock here? (Just to check if there were any copying errors.)
edit: Maybe your system saved the wrong line endings. For example, Windows uses CR LF (0d 0a) while Unix-like systems like Linux only use LF (0a). See here how to remove any CR from the file. As a 99% Linux user, I don't have any experience in this, but It may be worth a try.
-
mkdir -p converted # create the folder "converted" if it doesn't exist for f in *-video.mp4 # process all videos do c=$(avprobe $f 2>&1 | grep -c yuv444p) # (-c)ount no. of "444p" if [ "$c" -gt 0 ] # if 444p is present, then # convert into 420p avconv -i $f -y -pix_fmt yuv420p -strict experimental converted/$f fi done
I highlighted the text from your code block then copy and pasted it into notepad++. Saved it with UTF-8 encoding as a .sh file. Used WinSCP to copy it into home/pi. On the raspberry pi 3b+ running retropie 4.4, I quit emulationstation and used the chmod command with no problem. Then entered cd home/pi/RetroPie/roms/fba/media/videos, then sh/home/pi/444p-to-420p.sh, which gives me the syntax error. The converted video folder was created just fine.
The system I tried it for is fba. I used Skraper and the Screen Scraper database to scrape my roms, which left me with .mp4 files that had names identical to the roms (not having -video at the end of the file names). Don't go to any great trouble for me. I realized last night I had backup videos from a previous image. I used XML Scraper V2 back then, so last night used a bulk rename application to rename them without "-video" at the end. The funny thing is that I used this script about a year ago for the videos I had backed up, so it worked for me then. It's a real noodle scratcher for me. -
@Quackwalks said in [SCRIPT] Batch convert YUV 4:4:4 videos to YUV 4:2:0 in Retropie/Linux:
I highlighted the text from your code block then copy and pasted it into notepad++. Saved it with utc-8 encoding as a .sh file. Used WinSCP to copy it into home/pi. On the raspberry pi 3b+ running retropie 4.4, I quit emulationstation and used the chmod command with no problem. Then entered cd home/pi/RetroPie/roms/fba/media/videos, then sh/home/pi/444p-to-420p.sh, which gives me the syntax error. The converted video folder was created just fine.
It's not the character encoding, but the line endings settings of the file - should be Unix (LF) in Notepad++.
-
@mitu Ah, I see now. Thank you to you two for the help. I'll never gloss over line ending settings again.
-
@mitu @Quackwalks Sorry, for the late answer. I was occupied over Easter and in the days after. Thanks @mitu for stepping in.
-
Hello, I wonder if someone could help me with this batch converter as I am having some trouble.
These are the steps I have taken...
-
Copied the text from the code block posted by clyde into Notepad++, I saved it as a Unix script file, with Unix (LF) and UTF-8 encoding, the file appears as 444p-to-420p.sh on my PC desktop.
-
Using WinSCP, I moved the 444p-to-420p.sh file to /home/pi on my Raspberry Pi 3B.
-
From emulationstation, I press F4 on my keyboard to get to the command line.
-
I type in chmod u+x 444p-to-420p.sh and press enter and I get an error message "chmod: changing permissions of '444p-to-420p.sh': Operation not permitted"
I have obviously made a mistake somewhere and would be grateful for any assistance.
-
-
@Gogol Are you using WinScp as the
root
? It's not advisable and it's probably the cause of this error. Before runningchmod
, run:sudo chown pi 444p-to-420p.sh
-
@Gogol If @mitu's tip doesn't help, please show us the output of
ls -l 444p-to-420.sh
to see the owner and permissions of the file. Both "
l
" are small "L" and not ones.As a side note, if you save the file in
/home/pi/bin
you can invoke it from any other directory without writing its full path (/home/pi/444p-to-420p.sh
in your case), i.e. from your videos directory. See my Hint in my opening post.From your current location of the file, these commands will to that:
cd /home/pi # make sure you are in pi's home directory mkdir bin # create the directory "bin" mv 444p-to-420p.sh bin # move the script to bin
-
Hi, sorry for the late reply.
I was not able to get this to work, but I think the problem lies with the .mp4 videos I am trying to convert, I downloaded them from the internet from sites like emumovies and arcadepunks.
They do not display on the preview, so I tried converting one of the video snaps via VLC Media Player and was able to get the video to display in emulation station, however it was extremely glitchy. I have also tried with handbrake but with no success, the video does not display.
Do you know of another way to convert these videos, or possibly the correct settings in VLC or handbrake to get the videos to display without any glitches?
-
@Gogol I converted most problematic videos by completely recoding with Avidemux on my Ubuntu pc. That was before I saw this script. I don't remember the exact settings:
- Video Codec=Mpeg4 AVC (x264)
- change quality setting to something like 26 or so (really don't know anymore)
- Audio Codec=AAC or MP3, not sure
- Output Format=MP4v2 Muxer
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.