get_iplayer Download Olympics In Chunks Tutorial

MS jmstanfield at gmail.com
Fri Aug 10 08:14:22 EDT 2012


On 10/08/12 00:39, Matt Davis wrote:
> On Aug 8 12:25:26 EDT 2012 MS wrote:
>
>> Did you follow my tutorial instructions for using ffmpeg
>> accurately?
>
>> e.g.
>
>> ffmpeg -i DL_Chunk_01.mp4.flv -ss "00:00:00" -t "00:40:00" -vcodec
>> copy -acodec copy Output_1.mp4
>
>> Please note my use of -ss "00:00:00" above and in the tutorial for
>> re-muxing the first chunk even though that just specifies the start
>> of the video.
>
>> Also the ffmpeg parameter order is important and must be as shown
>> above and in the tutorial. I had failures when I specified the -ss
>> and -t parameters before the -i inputfile.mp4.flv parameter.
>
>> If neither of those fix your problem then you could try starting at
>> -ss "00:00:02" skipping the first 2 seconds and making absolutely
>> sure that your -t duration (DURATION NOT STOP TIME) is less than
>> the length of video you actually downloaded before the errors but
>> that's all I can think of.
>
> Thanks, yes, followed your ffmpeg commands to the letter. What I'm
> not 100% sure of is how to accurately determine the duration,
> especially when I start cutting bits from the start etc.
>

Well it's slightly tricky and you have to keep track of it as you 
progress through the chunks or you'll get totally confused.

For each chunk you know the start position which was used in the 
get_iplayer command, either the beginning 00:00:00 for the first chunk 
or the start time you've specified in seconds or in 01:30:00 timecode 
notation.

When a chunk download finishes either successfully or with errors there 
will be a line in the terminal which looks something like this:

1763972.684 kB / 13856.68 sec (99.9%)

The "13856.68 sec" specifies the time position in terms of the overall 
video length on the BBC site.

With the above, 13856.68 sec, it's the final chunk (hence the 99.9%). We 
can convert the seconds into a timecode, either manually with a 
calculator (if your maths is up to it) like below, or using the 'Time 
Calculator' linked below and in the tutorial.

13856 / 60 = 230.93 mins
230 mins = 3 hrs 50 mins
13856 mod 60 = 56 seconds
13856 secs = 03:50:56

Clearly the Time Calculator is a useful tool to use, paste in 13856 and 
it will show 03:50:56.

So now we have the end pos of the chunk in terms of the overall video 
length of the whole video on the BBC site.

The chunk example above was started with this command:

get_iplayer --pid p00w2r5c --start 9700 -o /location/ --force

So the start pos of the chunk was: 9700 = 2:41:40

So to calculate the duration of the chunk we just have to subtract the 
start pos from the end pos. In this case we can either use the seconds 
or the timecode, as we have both:

13856 - 9700 = 4156
4156 secs = 1:09:16

Or use the Time Difference Calculator linked below and in the tutorial:

03:50:56 - 2:41:40 = 1:09:16

So the duration of the chunk is 1:09:16.

So now we know the start and end position and the duration of the chunk:

Chunk: 2:41:40 -> 03:50:56 (Duration: 1:09:16)

Now with ffmpeg, if you've cut the first 5 seconds off the start by 
using -s 5 or -s "00:00:05" (same thing) then you need to add 5 seconds 
to the start position, and subtract 5 seconds from the duration:

Chunk: 2:41:45 -> 03:50:56 (Duration: 1:09:11)

Clearly if you play the file you created with ffmpeg (and cutting the 
first 5 secs) the player will report the file begins at 0 and ends at 
1:09:11 but you know from the above how and where that chunk fits in 
with the overall (all the other chunks you've got).

BTW if the example above was not the final chunk, and you had more 
chunks to do, then "03:50:56" would be the starting position of the next 
chunk except you'd want to start a bit before "03:50:56" so you've got a 
comfortable overlap.

As I wrote at the start of the tutorial: "It is not easy and it is time 
consuming..."

Time Calculator:
http://www.grun1.com/utils/timeCalc.html

Time Difference Calculator (to get the duration):
http://www.grun1.com/utils/timeDiff.cfm

Have a play with the 2 time calculators, using my examples above, you 
can enter times as either seconds or as a timecode, and you'll soon see 
how to use them.

HTH.



More information about the get_iplayer mailing list