Jump to content

using ffmpeg to chop off the end of a video without seeking through the whole damn thing

babadoctor
Go to solution Solved by igormp,
On 12/29/2019 at 10:44 PM, babadoctor said:

so I have been using the following command to get the last 10 minutes of a very very long livestream


ffmpeg -i "livestream.mp4" -ss 03:00:00 -t 00:10:00 -codec "copy" "output.mp4"

this takes forever if the video is longer than 12 hours.

 

is there really no way to just kind of lob off the end of the video with ffmpeg? why does it need to seek through the entire video to find the end of the video?????

 

it's really stupid and there has to be a better way.

 

This is especially bad when I need to do it over the internet, as it requires downloading the ENTIRE 12 hour video when I can clearly seek to the end of it with my player.

 

Any suggestions?

Rookie mistake, I've done that myself since it's really confusing haha

 

You did -ss after the input file, which means that it'll try to seek the output file instead of the input. You can read more about it here.

 

An example of what you want to do is:

ffmpeg -ss 24 -i "http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_normal.mp4" -to 10 -c:v copy -c:a copy test.mp4

Which seeks the big buck bunny video to second 24 and tries to download 10 seconds of it into the test.mp4 file while coping the media without doing any transcode.

Notice that the actual output duration won't be 10 seconds due to frame splitting. I hack to get around that that I had to do at work was to use ffprobe to check the amount of frames, and then seek through frames instead of seconds.

so I have been using the following command to get the last 10 minutes of a very very long livestream

ffmpeg -i "livestream.mp4" -ss 03:00:00 -t 00:10:00 -codec "copy" "output.mp4"

this takes forever if the video is longer than 12 hours.

 

is there really no way to just kind of lob off the end of the video with ffmpeg? why does it need to seek through the entire video to find the end of the video?????

 

it's really stupid and there has to be a better way.

 

This is especially bad when I need to do it over the internet, as it requires downloading the ENTIRE 12 hour video when I can clearly seek to the end of it with my player.

 

Any suggestions?

OFF TOPIC: I suggest every poll from now on to have "**CK EA" option instead of "Other"

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, babadoctor said:

so I have been using the following command to get the last 10 minutes of a very very long livestream


ffmpeg -i "livestream.mp4" -ss 03:00:00 -t 00:10:00 -codec "copy" "output.mp4"

this takes forever if the video is longer than 12 hours.

 

is there really no way to just kind of lob off the end of the video with ffmpeg? why does it need to seek through the entire video to find the end of the video?????

 

it's really stupid and there has to be a better way.

 

This is especially bad when I need to do it over the internet, as it requires downloading the ENTIRE 12 hour video when I can clearly seek to the end of it with my player.

 

Any suggestions?

Why aren't you just using handbrake? Can trim it in there.

I edit my posts a lot, Twitter is @LordStreetguru just don't ask PC questions there mostly...
 

Spoiler

 

What is your budget/country for your new PC?

 

what monitor resolution/refresh rate?

 

What games or other software do you need to run?

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

10 minutes ago, Streetguru said:

Why aren't you just using handbrake? Can trim it in there.

because i don't want to re encode the video

because i don't want to download the entire livestream so I can seek to the end and clip it.

 

handbreak requires a local file, no?

OFF TOPIC: I suggest every poll from now on to have "**CK EA" option instead of "Other"

Link to comment
Share on other sites

Link to post
Share on other sites

Does the server support resume, or jumping at some position in the stream?

If it doesn't, then ffmpeg would have no choice but to download the whole stream, and the live server may throttle you to real time speed (ex lets you buffer 1-2 minutes, then slows down connection to ~ 1x speed and keeps it there)

 

I'd suggest searching for some application that dumps streams with option to dump from a particular time.

Then just work with the local file, extracting the chunk you want from a slightly bigger chunk.

Link to comment
Share on other sites

Link to post
Share on other sites

5 minutes ago, mariushm said:

Does the server support resume, or jumping at some position in the stream?

If it doesn't, then ffmpeg would have no choice but to download the whole stream, and the live server may throttle you to real time speed (ex lets you buffer 1-2 minutes, then slows down connection to ~ 1x speed and keeps it there)

 

I'd suggest searching for some application that dumps streams with option to dump from a particular time.

Then just work with the local file, extracting the chunk you want from a slightly bigger chunk.

Yes, the server does in fact support resume. I use a node js program called http-server, and it has allowed me to seek through to the end with mpv player.

 

(the videos on the video server were also seekable with mpv)

 

Can you specify what you mean by "dumping streams"?

OFF TOPIC: I suggest every poll from now on to have "**CK EA" option instead of "Other"

Link to comment
Share on other sites

Link to post
Share on other sites

On 12/29/2019 at 10:44 PM, babadoctor said:

so I have been using the following command to get the last 10 minutes of a very very long livestream


ffmpeg -i "livestream.mp4" -ss 03:00:00 -t 00:10:00 -codec "copy" "output.mp4"

this takes forever if the video is longer than 12 hours.

 

is there really no way to just kind of lob off the end of the video with ffmpeg? why does it need to seek through the entire video to find the end of the video?????

 

it's really stupid and there has to be a better way.

 

This is especially bad when I need to do it over the internet, as it requires downloading the ENTIRE 12 hour video when I can clearly seek to the end of it with my player.

 

Any suggestions?

Rookie mistake, I've done that myself since it's really confusing haha

 

You did -ss after the input file, which means that it'll try to seek the output file instead of the input. You can read more about it here.

 

An example of what you want to do is:

ffmpeg -ss 24 -i "http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_normal.mp4" -to 10 -c:v copy -c:a copy test.mp4

Which seeks the big buck bunny video to second 24 and tries to download 10 seconds of it into the test.mp4 file while coping the media without doing any transcode.

Notice that the actual output duration won't be 10 seconds due to frame splitting. I hack to get around that that I had to do at work was to use ffprobe to check the amount of frames, and then seek through frames instead of seconds.

FX6300 @ 4.2GHz | Gigabyte GA-78LMT-USB3 R2 | Hyper 212x | 3x 8GB + 1x 4GB @ 1600MHz | Gigabyte 2060 Super | Corsair CX650M | LG 43UK6520PSA
ASUS X550LN | i5 4210u | 12GB
Lenovo N23 Yoga

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, igormp said:

Rookie mistake, I've done that myself since it's really confusing haha

 

You did -ss after the input file, which means that it'll try to seek the output file instead of the input. You can read more about it here.

 

An example of what you want to do is:


ffmpeg -ss 24 -i "http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_normal.mp4" -to 10 -c:v copy -c:a copy test.mp4

Which seeks the big buck bunny video to second 24 and tries to download 10 seconds of it into the test.mp4 file while coping the media without doing any transcode.

Notice that the actual output duration won't be 10 seconds due to frame splitting. I hack to get around that that I had to do at work was to use ffprobe to check the amount of frames, and then seek through frames instead of seconds.

Really solving all of my problems today, huh

 

haha, thanks man

OFF TOPIC: I suggest every poll from now on to have "**CK EA" option instead of "Other"

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×