Using ffmpeg to extract snippets of video

Using applications, configuring, problems
Post Reply
Message
Author
rmcellig
Posts: 965
Joined: Sat 19 Nov 2011, 15:18
Location: Ottawa Ontario Canada
Contact:

Using ffmpeg to extract snippets of video

#1 Post by rmcellig »

After trying Avidemux with mixed results, I am now deciding to try a command line alternative. This is totally new to me. Here is a brief summary of my workflow.

Locate and mark the beginning and end of a piece of video.
save the snippet

That's it. Can someone let me know what tools I need to accomplish this? I have been using mpeg streamclip on the Mac side and now I want to see if I can use ffmpeg to quickly automate the way I extract snippets of video in puppy Linux 5.2.8.

User avatar
GustavoYz
Posts: 883
Joined: Wed 07 Jul 2010, 05:11
Location: .ar

#2 Post by GustavoYz »

Not sure if got the question, you mean extract just a part of a video? If so, I'd try something like this (example):

Code: Select all

ffmpeg -i input.wmv -ss 60s -t 60s -acodec copy -vcodec copy output.wmv
Which takes 60 seconds (-t), from the second nº60 (-ss), using the same codec settings for output file.

rmcellig
Posts: 965
Joined: Sat 19 Nov 2011, 15:18
Location: Ottawa Ontario Canada
Contact:

#3 Post by rmcellig »

Thanks for the reply. To be more specific, I need to extract snippets of video and save them to a new file. So for example in MPEG Stream clip on my Mac I put a marker at the beginning (00:2.34), and the ending (00:5:20). Once I do this, I save this to a new file and that's it.

Can I set the beginning and ending times above in ffmpeg, or do I always have to manually calculate the difference? If I am not making sense, please let me know. Being new to this I am just trying to wrap my head around how ffmpeg works. Once I understand it, I can more or less automate the process.

And finally, if I can nail down how to do this in Puppy Linux using ffmpeg and it works to my liking, it's good buy after over 25 years to using my Mac. For me, this would be a great milestone to celebrate!! :) :)

User avatar
GustavoYz
Posts: 883
Joined: Wed 07 Jul 2010, 05:11
Location: .ar

#4 Post by GustavoYz »

I read the man page and did a quick google search about it, as I don't know any about ending points options, and found a big hole: seems that ffmpeg just doesn't have any. Guess that so far everybody calculated those...
Now I'm wondering, those marker positions are kept in the file's metadata or just belogs to the app? Could you try this?

Code: Select all

ffmpeg -i yourfile.ext

User avatar
Semme
Posts: 8399
Joined: Sun 07 Aug 2011, 20:07
Location: World_Hub

#5 Post by Semme »

Gustavo- this page is for YOU!

User avatar
GustavoYz
Posts: 883
Joined: Wed 07 Jul 2010, 05:11
Location: .ar

#6 Post by GustavoYz »

Thanks, nice page also, but that's exactly what I was saying here before.
You can set offset starting time, then duration time, but you can't mark a begginning position in the "time line" and a final one: you can just mark the beginning and specify a duration. Thus, you can't do what rmcellig's request needs just with ffmpeg.

rmcellig
Posts: 965
Joined: Sat 19 Nov 2011, 15:18
Location: Ottawa Ontario Canada
Contact:

#7 Post by rmcellig »

Exactly. If there was a way to set the beginning and end points, that would make a ton of sense. What I have to do now is calculate the duration which to me doesn't make much sense. A start and end point seems more obvious. I'm going to probably look at something else. While I appreciate the power of ffmpeg, it doesn't seem to meet my needs which is unfortunate. I did download the Avidemux 2.6.1 debs and installed them (in an ubuntu distro but after all that, I can't find where to launch Avidemux.

So, for me, I haven't been very lucky trying to achieve something that I think is pretty basic, in Linux yet. This is the only thing that is holding me back from going 100% Linux. Maybe there is another command line tool or simple video editor for Linux that I am unaware of?

User avatar
GustavoYz
Posts: 883
Joined: Wed 07 Jul 2010, 05:11
Location: .ar

#8 Post by GustavoYz »

Well, ffmpeg is a great command line tool and a terrific piece of software, but is way more common use durations than final positions, makes a lot of sense to me...
But anyway, if wont consider calculating, you should just try with some -others- video editors, as I don't think that the command line has more to offer than ffmpeg in any video-related issue (which is just my opinion).
I'd take a look at Open Shot and Cinelerra, there is a sfs with KdenLive somewhere too; just some options that came to my mind quickly.

Good luck.

rmcellig
Posts: 965
Joined: Sat 19 Nov 2011, 15:18
Location: Ottawa Ontario Canada
Contact:

#9 Post by rmcellig »

Thanks! I'll have to check out Openshot to see if you can mark the beginning and ending of a clip and then save it. If it can do this, I will be fine.

Post Reply