
Splicing in The Big O’s original intro with FFmpeg
I have an updated version of these commands in a new bog post.
I have been rewatching The Big O with my partner from bluray rips and as nice as it is to watch it in so much higher quality than when I saw it as a kid but the bluray release lacks the original iconic intro, which is presumably related to the fact that it’s basically Flash by Queen over the visuals of the intro for Ultraseven.
I know enough FFmpeg to be a danger to myself so I decided to spend far too much time banging my head against my keyboard until I managed to splice the original intro into all the episodes. There was a good bit of trial and error and fixing things and adjusting commands but I decided to document a cleaned up version of the steps mostly as a reference material for myself if I decide to do something like this in the future but if it helps anyone else then that’s cool.
What I have below is definitely not the best way to do this. I ended up reprocessing the same videos multiple times which is inherently going to result in a loss in quality and I lost information like subtitles and the Japanese audio track by converting from Matroška files to plain MPEG-4s but I wasn’t using those anyway.
1. Prepare the intro
I used yt-dlp to download the intro from Youtube as it wasn’t included in the bluray files and then blew it up to the same resolution as the bluray rips, 1424×1080.
yt-dlp 'https://www.youtube.com/watch?v=s7_Od9CmTu0'
ffmpeg -i The\ Big\ O\ Opening⧸Intro\ Theme\ \[720p\]\ \[s7_Od9CmTu0\].webm -vf "scale=1424:1080,setsar=1:1" intro.mp4
2. Preparing files
I copied all the episodes that had the intro I wanted to replace into a folder. Episodes one and two of the first series and episodes one, eight and thirteen of the second series have special intros so no processing needed to be done on them. For step 4 it turned out that spaces in the filenames broke the command and I couldn’t figure out how to properly escape them so while preparing the files also remove any spaces or other characters that might cause problems from the filenames.
3. Strip the existing intro
I loaded episodes up in Kdenlive just to check the exact length of the existing intro on the episodes and found it to be 1′12″ and so wrote a command to iterate over all the files and write out an MP4 version with the English audio track (the second audio track in the file, but mapped as 1 in the command as FFmpeg indexes from 0) with that much time cut from the start.
I use a Fish shell rather than Bash. If you use Bash or a different shell you will need to adjust the commands.
for v in *.mkv
set b (basename "$v" ".mkv")
ffmpeg -i "$v" -ss 00:01:12.01 -map 0:v -map 0:a:1 "$b-nointro.mp4"
end
There were a couple of episodes where it turned out that there was still one frame of the old intro left at the start so those had to be reprocessed with the start time set to 00:01:12.02
.
4. Splice in the original intro
I moved the downloaded intro file into the same folder as the episodes and spliced it into the files. This broke when there were spaces in the filenames and I wasn’t able to escape it properly so I ended up just stripping spaces out and renaming the files back with KRename afterwards.
for v in *-nointro.mp4
set b (basename "$v" "-nointro.mp4")
ffmpeg -i intro.mp4 -i "$v" -filter_complex "movie=intro.mp4, scale=1424:1080 [v1] ; amovie=intro.mp4 [a1] ; movie=$v, scale=1424:1080 [v2] ; amovie=$v [a2] ; [v1] [v2] concat [outv] ; [a1] [a2] concat=v=0:a=1 [outa]" -map "[outv]" -map "[outa]" "$b-intro.mp4"
end
5. Fixing chapter metadata
The episodes had some chapter metadata dividing up parts of the episode, with the first one covering just the episode intros, which cutting out that part of the video removed. I decided to fix that with the versions with the restored intro, even though obviously I am never actually going to skip it in practise. The first step of this was outputting the metadata to a text file.
for v in *-intro.mp4
set b (basename "$v" "-intro.mp4")
ffmpeg -i "$v" -f ffmetadata "$b.txt"
end
I then manually adjusted the metadata entry to restore the Chapter 01
entry, putting it above the existing chapters in the file. Most of them had their Chapter 01
entry wiped out so I just added it in above the Chapter 02
entry, though some of them still had a Chapter 01
lasting just a few milliseconds so for those I just modified the END
time for it. The new intro was 1′7.61″ which meant a 67,610ms timestamp. I also changed the START
entry for every Chapter 02
to 67610 to match.
[CHAPTER]
TIMEBASE=1/1000
START=0
END=67610
title=Chapter 01
Once they were all updated I applied the modified chapter metadata back to the files
for v in *-intro.mp4
set b (basename "$v" "-intro.mp4")
ffmpeg -i "$v" -i "$b.txt" -map_chapters 1 -codec copy "$b.mp4"
end
6. Done!
Then I deleted all the intermediary files and dropped the processed files into my Jellyfin server along with the episodes that didn’t need fixing.