A few attempts have been made to remedy this situation, but, until recently, they have come to nothing.
In the mid-1990s, Innovative Media Solutions produced a range of Acorn readers for PC-format, educational CDs, such as Microsoft Dinosaurs and Dorling Kindersley's The Way Things Work. These readers included dedicated versions of ARMovie, which could convert the CD’s AVI files to Replay format on the fly.
Unfortunately, the work that IMS had done, did not result in the release of a souped-up version of Replay, which could play all Quicktime and AVI movies, despite the fact that RISC OS Ltd seem to have done some work in this area about five years ago.
But now, with the release of the open-source applications, Murnong and FFMpeg, by Chris Martin, things have started to take a turn for the better.
Although RISC OS still does not have a proper media player, which can play all the common video formats, we do now have the next best thing - an application that can capture a YouTube video stream as it arrives, and convert it to an MPEG file, which can be played using KinoAmp.
The first thing to do is to install the latest versions of Murnong, FFMpeg and Mpgtx, if you don't have them already.
Now load the !Murnong application, so that its icon appears on the icon bar.
Load your favourite web browser up, and navigate to an interesting YouTube video.
Select Save Web Page from the browser’s menu, but instead of dragging its file icon onto your hard drive, drag it onto the Murnong icon on the icon bar.
Murnong will respond by opening a Fetch Video dialogue box, so name the output file, and drag its icon to the disc or directory you wish to save it on.
Murnong will now calculate the path to the actual YouTube FLV video, contained in the page, and launch another application called Wget to actually retrieve it. (Incidentally, YouTube keep changing the way their system retrieves these videos, so Chris has already had to update Murnong a couple of times to keep pace with these changes.)
Once you have the FLV video saved as a Data file, you can drag it back onto the Murnong icon on the icon bar. This will open a simple conversion window, allowing you to convert just the audio or video content, or both, to an MPEG file and convert from 12 frames a second to 24, if required, to make the video playable in KinoAmp.
Although it is fairly easy to make playable versions of YouTube videos this way, there are two common problems with many of them.
One is that the videos have rarely been cut out neatly, so there is often distracting material before and after the bit you really want. This not only reduces its impact, it also wastes valuable hard drive space.
The other problem, is that material that has been transmitted on television, usually has ugly, black bars around the edges of every frame, and often has a ‘tear’ running along the bottom. This would not have been visible on your television set, but nearly always seems to be present on stuff that was originally recorded on a VHS tape recorder.
As long as you are quite happy with what YouTube gives you, there is no need to delve any deeper.
But if you wish to extract clean, high-impact clips from whatever you have downloaded, at some point you will need to get your hands dirty, and start to experiment with FFMpeg, the versatile, video-processing program that lies at the heart of Murnong.
This time, I am going to use the FFMpeg application to convert the downloaded FLV Data file, rather than just dragging it back onto the Murnong icon to do it.
There are two ways of using FFMpeg:
- You can load the application onto the icon bar, and drag the FLV file onto its icon, as you would with Murnong.
- you can use an Obey file, which supplies the input file name, along with any conversion options.
This opens a task window, which reports on the audio and video contents of the file, and also opens a dialogue box, which allows you to select the conversion options that you require.
Make sure that Quality is set to Same as Input, and Audio to Copy, then drag the output file icon onto your RAM disk, and click on Convert.
Also note the Cutting section at the bottom, and the Cropping section on the right - we will be looking at these again later.
Once the conversion has completed, select the data file on your RAM disc and set its file type to BF8, before playing it in KinoAmp.
Using Obey Files
Although just dragging the FLV file onto the program icon, and filling in the dialogue box, is the easiest way to use FFMpeg, there are two big problems with it:
- Because it is multi-tasking, when called from the application front end like this, it will also be slower than it would be, if it were called from an Obey file and run as a single task.
- If it is run multi-tasking, and you carry on doing something else while it does the conversion, there is a danger that you could trash your machine, if one of the other programs crashes while FFMpeg is writing to your hard drive.
If, however, you intend to convert a lot of video files, it would be better to learn how to do it using Obey files.
From now on, I will be explaining how to do this, but also showing which options need to be chosen on the front end, in case you are still allergic to using Obey files.
The YouTube movie I am going to use, is a collection of vintage adverts dating back to 1969, which can be downloaded from here.
To use an Obey file to do a straigtforward conversion to MPEG, as we have just done using the front end, load a text editor such as Zap.
The basic forms of the files that you will need, are provided as a zip file, and it is easier to amend these, than it is to create them from scratch.
But it IS worth knowing the quick way of entering file names, without having to worry about making mistakes in the file path.
We want to create an Obey file that looks roughly like this:
So enter the text above (or load ConvToMpeg from the zip file), but leave (or make) a blank space where the red bits go.
ffmpeg:ffmpeg -i 1969/flv -f mpeg -sameq -acodec copy RAM::RamDisc0.$.1969,BF8
Now, the easiest way to enter the path name for 1969/flv, is to find it on your hard drive, hold down the Shift key, then drag its file icon into the Zap window, with the cursor positioned just after the -i (the input file).
If the edit window fills up with rubbish, you know you have done something wrong !!!
Also, if the path name pushes the rest of the instruction onto a new line, delete the line break, otherwise the Obey file will not run properly.
Now drag a small file into the RAM disc, shift-drag its file icon into the Zap window at the end of the line, to put in the path, and change the file name to 1969.
Add ,BF8 (without leaving a space on either side of the comma) to the end of the line, to get FFMpeg to set the output file type to MPEG, rather than Data.
By now, your Obey file should look like this:
Save it as an Obey file, with the name ConvToMpeg, and run it to check that it works.
ffmpeg:ffmpeg -i ADFS::HardDisc4.$.1969/flv -f mpeg -sameq -acodec copy RAM::RamDisc0.$.1969,BF8
Extracting A Shorter Clip
Once we have the basic form of this Obey file, it is fairly easy to modify it to achieve other effects, such as extracting clips from longer sequences, changing the audio or video format within the MPEG container, or cleaning up the edges of the frames, if needs be.
The next job is to extract a short clip from the sequence, using the Findus Fish Fingers advert as an example, so make a copy of ConvToMpeg and name it ExtractClip (or use the one provided in the download).
Now play the file 1969 in KinoAmp.
As soon as you have reached the beginning of the section you want to extract, left-click in the player window to pause it, then middle click and select Film->Info from the menu.
Look up the time code value of the beginning of the clip, next to Playing Time.
Make a note of it, then close the dialogue box, and left-click in the player window again to resume play.
Left-click once more at the end of the required clip, and look up the Playing Time again, to find the time code value for the end of the clip.
Subtract the previous time code value, to calculate its duration.
Having obtained the rough -ss and -t values (start time and duration) for the clip, in this case 120.80 and 43.80, load ExtractClip into Zap, then edit it so that it looks something like this:
(Note: the -ss and -t arguments must come before the -i input file argument, otherwise FFMpeg will throw a tantrum.)
ffmpeg:ffmpeg -ss 120.80 -t 43.80 -i RAM::RamDisc0.$.1969 -f mpeg -sameq -acodec copy RAM::RamDisc0.$.FishFingers,BF8
In fact, probably because of the poor quality of the original recording, simply running ExtractClip like this, results in a movie in which the sound plays about a second behind the picture. Running ExtractAlf, from the download, will correct this problem, by extracting the audio and video content seperately, a second apart, to bring the two back into sync again.
Also, with other files, you will probably have to run the Obey file several times, with slightly different values of -ss and -t, to ‘walk in’ the beginning and end points of the clip, if you really want to get a neat result (or enter the Start Offset and Duration on the Convert screen, if you are using the application’s front end).
Cleaning Up The Edges
By this time, you should have an MPEG clip, which starts and stops in the right place, but still has thick black bars around the sides, and often also has a kind of ‘tear’ running along the bottom.
If you want to remove these borders and the ‘tear,’ there is a cropping facility within FFMpeg, which allows you to do just that.
Allow the movie to play in KinoAmp, until you reach a light-coloured frame, then middle click and select Film->Save Frame.
Now examine the resulting sprite file, bump up the Zoom to about 6 to 1, then select white as the painting colour, and draw a single pixel line across the four borders.
Count the pixels to measure the width of the borders, then copy ConvToMpeg again as CropBorders, and change it to look something like this:
(Alternatively enter these values in the Cropping section on the Convert screen).
ffmpeg:ffmpeg -i RAM::RamDisc0.$.FishFingers -f mpeg -sameq -acodec copy -cropleft 8 -croptop 0 -cropbottom 2 -cropright 8 RAM::RamDisc0.$.FishFingers2,BF8
Et voila! Once you have run this, you will have a much neater clip with nice, neat edges, whose picture and sound quality is as good as the YouTube original.
And once you have ConvToMpeg, ExtractClip and CropBorders, it is a simple enough job to use them again with different input files.
To make things easier, download the zip file, which contains a basic form of the three obey files, so you don't spend ages trying to get the syntax right.
Just remember to be careful when editing them!
Homework: Now use ExtractClip and CropBorders to extract the Cadbury’s Flake or Sunsilk Shampoo adverts from the same sequence.
Extracting Sound or Video Only
If you wish to play some of the music that you have downloaded in a CD player, you can extract just the sound component of it, and save it as a WAV file.
You can do this from the Convert screen, by selecting Wave as the output format, or with an Obey file like this:
You can also take advantage of the fact that the audio component of most YouTube videos seems to be encoded in MP3, to quickly extract an MP3-format copy of it.
ffmpeg:ffmpeg -i RAM::RamDisc0.$.1969/flv -f wav RAM::RamDisc0.$.SoundOnly,FB1
First drag the FLV file onto the FFMpeg icon on the iconbar, to get the program to check that the audio is encoded in MP3 format, then run an obey file like this:
Another neat trick you might want to do with some videos, is to remove an annoying sound track and save just the video component, using the -an, no sound, option.
ffmpeg:ffmpeg -i RAM::RamDisc0.$.1969/flv -f wav -acodec copy RAM::RamDisc0.$.MusicOnly,1AD
ffmpeg:ffmpeg -i RAM::RamDisc0.$.1969/flv -f mpeg -sameq -an RAM::RamDisc0.$.NoSound,BF8
Changing the Frame Rate
Another thing that you often have to do, especially with footage that comes from a digital camera, is to increase the frame rate so KinoAmp can play it.
Many of these videos end up being encoded on YouTube, as 15 frames-per-second FLV files, and FFMpeg will not allow a simple conversion on these, because such a slow speed is not permitted under the MPEG file specification.
To get around this, you have to encode the file at 24 frames per second, using the -r 24 argument, in front of the output file name:
A good place to practice this, is with Sophie Wilson’s ‘History of Acorn Computers’ talk, which starts here
ffmpeg:ffmpeg -i RAM::RamDisc0.$.Slower/flv -f mpeg -sameq -r 24 RAM::RamDisc0.$.Faster,BF8
Extracting a Clip from a DVD
If you look in the VIDEO_TS directory of a home-recorded DVD, you will see a collection of files named something like VTS_01_1/VOB, etc.
These VOB files are the recorded MPEG data created by your DVD recorder.
On a full disc, there would typically be five of these, each one over a gigabyte in size, representing about 25 minutes of recording time each, at Standard Quality. So a clip that occurs 40 minutes into the recording, is likely to be in the second VOB file.
The first thing to do, assuming you have enough hard drive space available, is to copy the VOB file, containing the clip you want to extract, onto your hard drive.
Once you have this, set the file type to BF8 for MPEG, and play it using KinoAmp.
As before, once you have reached the beginning of the section you want to extract, left-click in the player window, then middle-click and select Film->Info from the menu.
Look up the time code value of the beginning of the clip, next to Playing Time.
Make a note of it, then close the dialogue box, and left-click in the player window again to resume play.
Left-click once more at the end of the required clip, and look up the Playing Time, to find the time code value for the end of the clip.
Subtract the previous time code value, to calculate its duration.
Having obtained the rough -ss and -t values (start time and duration) for the clip, create and run an Obey file that looks something like this, but subtract a couple of seconds from the value of -ss and add four to -t, so that the resulting file will have a bit of space on either side of the reqired clip.
The -s 'cif' size arguement produces an output file that is a quarter of the size of the original - 360 pixels by 288, instead of 720 by 576.
ffmpeg:ffmpeg -ss 11.92 -t 130 -i ADFS::HardDisc4.$.VTS_01_1/VOB -f mpeg -sameq -s 'cif' ADFS::HardDisc4.$.MyClip,BF8
As an alternative, you can use -s '4cif' which produces a clip of the same dimensions as the original, but on a StrongARM RiscPC this would only play at about one frame a second.
Warning: Down-sizing from DVD quality to a quarter size is very processor intensive, and converting one minute of DVD video, on a StrongARM RiscPC, takes about 25 minutes. Do not convert any more than you have to, and if you are planning to extract a long sequence, it might be best to leave it running overnight.
We can now treat MyClip as if we have just downloaded it from YouTube.
Play it in KinoAmp, to establish the required values of -ss and -t more accurately, and then edit ExtractClip, to ‘walk in’ its beginning and end points, if you really want to get a neat result.
By now, you will probably have realised that you can use the time settings of ExtractClip, and the remove border settings of CropBorders in one Obey file, ProcessClip, which will look something like:
and will cut the required processing time in half!
ffmpeg:ffmpeg -ss 1.24 -t 124.60 -i ADFS::HardDisc4.$.MyClip -f mpeg -sameq -acodec copy -cropleft 6 -croptop 22 -cropbottom 26 -cropright 6 ADFS::HardDisc4.$.MyClip2,BF8
Please note: DVD+Rs have to be finalised in your DVD recorder, before CDFS will read them properly and allow you to get at the individual VOB files.
Splicing Film Sections together using Mpgtx
Another useful utility Chris Martin has ported to RISC OS, is the film splicer Mpgtx, which allows you to join segments of film together into one video.
The process of splicing is actually very simple, as long as the segments you want to join have been encoded with identical audio and video settings, and there is no unwanted padding before, or after, any of the required segments.
If that is the case, you can simply convert each of the segments seperately, then join them together using an Obey file something like this:
If the audio and video settings do not match, however, or it is necessary to remove unwanted material before, or after, the different segments, then the job does become more difficult.
ADFS::HardDisc4.mpgtx -j ADFS::HardDisc4.Seg1 ADFS::HardDisc4.Seg2 ADFS::HardDisc4.Seg3 -o ADFS::HardDisc4.Joined
To explain how we might process different segments to get around these problems, we can take a missing episode of Doctor Who as an example (and make a detour into the history of British television along the way).
Over the years, the BBC has ‘lost’ more than a hundred early, black-and-white episodes of Doctor Who!
After transmission, the original recordings were transferred from (then very expensive) videotape onto cheaper, celluloid film. The film copies were then gradually thrown out, because the BBC didn’t think anybody would ever want to see them again.
They only stopped this practice of ‘junking’ old, black-and-white episodes of classic series around 1978, when the emergence of the home video recorder created a whole new market for vintage British television.
The first of these missing episodes, is the first installment of the Marco Polo story, The Roof of the World, broadcast only once in 1964.
Luckily, a few early Doctor Who fans were in the habit of recording the show onto audio tape, and there was an enterprising photographer called John Cura, who made a living by photographing his television screen, as programmes were being broadcast, and selling the resulting photos to interested TV producers and actors.
Without John Cura, we would have almost no visual record of many early TV programmes, for not only were many ‘junked’ to save space, but many others, like the early episodes of The Avengers, were broadcast live from a studio, and were never actually recorded in the first place.
Now, forty years later, a small band of enterprising fans are slowly marrying up the sound recordings of these early, missing Doctor Who episodes with the ‘Cura telesnaps,’ to produce the best representation of these programmes we are ever likely to have . . . at least until somebody takes a DVD recorder back to the 1960s in a home-made TARDIS!
These reconstructions are slowly turning up on YouTube, but because of the maximum time limits that they impose on videos, they will usually have been chopped into segments less than ten minutes long. Consequently, a 25-minute programme will have had to have been split into three parts, to get it onto YouTube in the first place.
It is, therefore, a good test of Mpgtx and FFMpeg, to see if we can use them to stitch some of these segments back together, and restore The Roof of the World to its former glory!
The first thing to do is to download the three sections of the episode, one, two and three, and save them as Marco1, Marco2 and Marco3/flv.
Although we could simply join the three segments together, we won’t get a very good result like that.
Some of the sections have an advert for BBC Audio at the end, and even once that has been removed, the start of the next segment does not line up precisely with the end of the previous one. So some ‘trimming’ is required to get the three segments to fit together neatly.
But there is a more serious problem, which soon becomes apparent if you drag the three FLV files onto the FFMpeg icon, and see what the program makes of them.
The audio settings on the first file are 56 Kb/s, mono, on the second, 64 Kb/s, mono and on the third 48 Kb/s, stereo. Also the first two files are 320 by 240 pixels in size, while the third is 352 by 264!
The audio paremeters are different in each file, and the last one has a larger frame size than the first two.
If we want to produce a joined MPEG file that is actually playable, we will first have to use FFMpeg to process the three files, so that the audio and video parameters are identical.
The first thing to do is copy Marco1/flv into your RAM disc and run an Obey file something like this:
The -t arguement cuts off the advert for BBC Audio at the end, and the -ab 64k adjusts the bit rate of the first segment, so that it matches that of the second.
ffmpeg:ffmpeg -t 425.44 -i RAM::RamDisc0.$.marco1/flv -f mpeg -sameq -ab 64k -cropleft 2 -cropright 2 -cropbottom 2 RAM::RamDisc0.$.Marco1,BF8
Now shift-drag Marco1/mpg onto your hard drive, copy Marco2/flv on to RAM disc, and run this Obey file:
Shift-drag Marco2/mpg onto your hard drive, and copy Marco3/flv on to RAM disc.
ffmpeg:ffmpeg -ss 6.4 -t 559.00 -i RAM::RamDisc0.$.marco2/flv -f mpeg -sameq -cropleft 2 -cropright 2 -cropbottom 2 RAM::RamDisc0.$.Marco2,BF8
We need to cut about 3 seconds from the beginning of this segment, but if we try to do this while converting straight to MPEG, we get a ‘buffer underflow’ error, so we have to shuffle sideways and process this FLV in two stages.
To do this, we have to run the scariest Obey file of them all:
This cuts out the unwanted three seconds, adjust the audio encoding to one channel, 64 Kb/s, like the other two, and saves the movie as an AVI file.
ffmpeg:ffmpeg -ss 3.12 -i RAM::RamDisc0.$.marco3/flv -f avi -sameq -ac 1 -ab 64k -cropleft 18 -cropright 18 -cropbottom 14 -croptop 12 -vcodec mpeg1video RAM::RamDisc0.$.Marco3/AVI,FB2
(Incidentally, it is a little known feature of KinoAmp that it will also play some AVIs, if the video format within the AVI ‘wrapper’ is CinePak or MPEG. You can actually double-click on this temporary file and play it!)
Now we just have to convert from AVI to MPEG:
Unfortunately, there are still serious problems with this third and final segment.
ffmpeg:ffmpeg -i RAM::RamDisc0.$.Marco3/AVI -f mpeg -sameq -acodec copy RAM::RamDisc0.$.Marco3,BF8
Not only is there some corruption to the downloaded video, which leads to pixellation and picture breakup, as well as glitches on the sound, but YouTube has also encoded it at a slightly larger frame size, forcing us to crop the edges more severely, in order to get the three segments to join together properly.
The corruption may be due to the panning effect, that the video’s creator has applied to the map, at the beginning of the segment, and it suggests that not all of the effects that can be created with video-editing software, will encode properly into YouTube’s FLV format.
Having experimented with this, I have found that it is possible to join the first and second segments together successfully, using this obey file:
But if we join the third segment, the sound starts to slip out of sync with the picture, when KinoAmp starts to play it. Once again, however, there is a way around it.
ADFS::HardDisc4.mpgtx -j ADFS::HardDisc4.Marco1 ADFS::HardDisc4.Marco2 -o ADFS::HardDisc4.Marco12,BF8
Shift-drag Marco12 and Marco3 into a directory called MarcoPolo.
Middle-click on the KinoAmp icon, on the iconbar, select Playlist, then drag the MarcoPolo directory to its input area and save the play list as PlayMarco.
You can now drag PlayMarco onto the KinoAmp icon, to play the whole episode.
Because of the bad coding of the third segment, this reconstructed episode is not perfect, but it is still pretty impressive.
Luckily, most splicing operations are not nearly as complicated as this, but it should have given you a pretty good idea of what to do, if you encounter problems.
And now, several hours after you started, sit back and enjoy The Roof of the World!
Tips & Tricks
- If you do not like Obey files, and would rather use the program’s dialogue box to specify the settings, do not carry on using the machine until it has completed the conversion.
It is not worth risking locking your machine up, while FFMpeg is writing to the hard drive !!!!
- Use your RAM disc as much as possible, for input and output, to avoid wear and tear on your hard drive.
- The most difficult part of the operation is getting the right values for -ss and -t for the required clip, in the first place.
If you want to get a really neat cut of your desired clip, run ExtractClip a few times with -t set to 5 seconds and slightly different values of -ss, while you ‘walk in’ the start point of the clip.
- If you see the dreaded ‘buffer underflow’ error in the program’s progress window, soon after starting the conversion, cancel it by hitting the Q key.
The resulting file will be unplayable, so there is no point in wasting time letting it finish. These ‘buffer underflows’ always seem to occur when using the -ss arguement, and seem to be caused by many FLV files having corrupted time codes.
You can usually get around this problem by converting the whole of the FLV file to AVI first, and then using ExtractClip on the AVI version, rather than the FLV one.
- If you produce an MPEG file that either will not play in KinoAmp, or alternatively plays for a couple of seconds and then freezes your machine, use Alt-Break to regain control of it, rather than the On/Off switch.
FFMpeg and Mpgtx to RISC OS, and for his help researching this article!