A few months back, before I even got here, @Scruffy_Nerfherder@exploding-heads.com had a post in DMT that linked to a youtube video titled Your Darkest Secrets Revealed in your Reverse Speech | CIA is Listening. I found this the other day and thought it was kind of interesting. So I decided to see if I could figure out how to download, cut, and reverse common video clips in Linux using completely FOSS tools. This is what I came up with. If you have a better way, lmk. I know there are probably more professional tools out there but I’m a moron when it comes to video editing so had to be something I could bumble through and still get ok results with.
Tools used:
- yt-dlp for downloading vidoes (repology versions)
- mkvtoolnix-gui for cutting out clips (repology versions)
sox
for reversing (repology versions)ffmpeg
for breaking apart streams and putting them back together (repology versions)
I did this on Fedora 38 but should work on any distro as long as you can find the same tools. You probably don’t need the same exact versions but here are the versions I had installed for reference.
# dnf5 list --installed ffmpeg sox mkvtoolnix* yt-dlp
Installed packages
ffmpeg.x86_64 6.0-11.fc38 rpmfusion-free-updates
mkvtoolnix.x86_64 77.0-1.fc38 <unknown>
mkvtoolnix-gui.x86_64 77.0-1.fc38 <unknown>
sox.x86_64 14.4.2.0-36.fc38 fedora
yt-dlp.noarch 2023.07.06-1.fc38 <unknown>
I think all of these should be in central repos for most distros, including Mint/Debian/Ubuntu, but if anyone wants to confirm or suggest alternate tools, be my guest.
Steps:
1. Download video (replace url - should work for yotube/invidius/odysee/twitter/reddit/lot of other sites). I just used the video from another old post I was looking at about tranq:
yt-dlp -i -f bestvideo+bestaudio/best -S res:480 -o '%(uploader)s_%(upload_date)s_%(title)s.%(ext)s' \
--progress --windows-filenames --trim-filenames 98 --restrict-filenames --merge-output-format mkv \
https://www.youtube.com/watch?v=xQlnIK-Ull4
2. Then open mkv file in mkvtoolnix-gui
3. Go to output tab. On the left side, there is a Splitting section. Go there and change the dropdown from “Do not split” to “By parts based on timestamps”.
4. Find the start and stop timestamps in the video.
5. Go back to the Splitting section section and enter the timestamps you found. According to the hover tooltip, it takes a “comma-separated list of timestamp ranges”. So if you have a 5 min video and just want 1 clip of 1m35 to 2m05s, you’d enter 00:01:35-00:02:05
. If for the same 5 min video, you wanted 2 clips, with the previous one plus a second one at 3m45s to 4m08s, then you’d enter 00:01:35-00:02:05,00:03:45-00:04:08
6. At the bottom of the screen, change the output name to whatever you want to call the clips, e.g. /some/path/clip.mkv
then hit the “Start Multiplexing” button. It will create clip-001.mkv
, clip-002.mkv
, and so on based on the split settings you used.
For mine, I wanted the clip of Biden talking, so I used 00:02:15-00:02:32
and named the file antigun-dipshit.mkv
.
7. Make sure it got the segment(s) you wanted. This spliting method isn’t exact so you might have to fiddle with the times a bit. The reason it isn’t precise is cuz it works off of keyframes or something like that, but still it is pretty easy to use and it’s really fast most of the time. I ain’t a video expert so if you guys know a more precise way of cutting videos, please let me know but this should still do the job for most people, most of the time.
8. Once you segments file is good, go ahead and close out of mkvtoolnix-gui.
9. then Based on this, we gotta use ffmpeg to break apart the video streams, sox to reverse them, then ffmpeg again to put them back together. Since the post was a bit dated, I had to play around with the last two commands but based on this, I was able to get it to run by replacing -vpre
with -preset
.
ffmpeg -i antigun-dipshit.mkv -an -qscale 1 %06d.jpg
ffmpeg -i antigun-dipshit.mkv -vn -ac 2 audio.wav
sox -V audio.wav backwards.wav reverse
cat $(ls -t *jpg) | ffmpeg -f image2pipe -vcodec mjpeg \
-r 25 -i - -i backwards.wav -vcodec libx264 -preset slow \
-crf 20 -threads 0 -acodec flac reversed.mkv
10. They had one more command using mencoder
(which is apparently part of mplayer
) but I didn’t end up needing that and not really sure what it does. Some people on stackexchanged also reported issues with the sox command and said that the following worked better for them:
cat $(ls *jpg |sort -n) | ffmpeg -f image2pipe -vcodec mjpeg \
-r 25 -i - -i backwards.wav -vcodec libx264 -preset slow \
-crf 20 -threads 0 -acodec flac reversed.mkv
But both seemed to be about the same for me.
What I learned:
Either my hearing sucks or Joe’s subconcious mumbles as much as he does when concious. But I guess I’m slightly better than incompetent at video editing now.
What I thought I heard:
mumble mumble accountants mumble I watch CNN mumble mumble
reversed clip:
https://files.catbox.moe/bomiam.mkv
original (not reversed) video:
Newsmax - July 9 - Zombie drug ‘tranq’ on the rise in American cities | Sunday Agenda
That was awesome!