2

I'm thinking of extracting the "best" parts of my home video files. Why? Because my videos has a lot uninteresting footage that I don't need wasting disk space.

I thought I'd use -ss and -t to specify the part I want, and -codec copy. Example:

ffmpeg -i iphone4sFullVideo.mov -ss 00:00:10 -t 10 -codec copy iphone4sGoodPart.mp4

I have of course tested this and know this creates a new file with a length of 10 seconds that plays in vlc.

With doing this I think I am getting no loss in quality, and being able to use the mp4-video in a GUI video editor (like Adobe Premiere Elements) later. I was planning to do this with my video files from different phones and camcorders. I got .mts, .mov and .mp4.

My question is kind of advice seeking. Is what I'm thinking of stupid? Will my files be ok after copying a part to an mp4 container?

jostyposty
  • 66
  • 1
  • 7
  • 1
    it's wise to seek advice before it goes wrong, I just hope you'll be so lucky as to get advice on that matter. not many people understand ffmpeg, @slhck does but I doubt many others do here. I certainly don't! Your -ss and -t are in the right place for accuracy. If you put them before the -i you'd have less accuracy but a quicker execution. He mentions that here http://blog.superuser.com/2012/02/24/ffmpeg-the-ultimate-video-and-audio-manipulation-tool/ personally I avoid ffmpeg and use xilinix (payware) but it works nicely and has amazing support and is very usable for me! – barlop Oct 08 '13 at 20:19
  • 1
    It's pretty unclear what you're asking, did you want to clarify it a bit more? I say this as `Is this a wise thing to do? Any suggestions?` is all sort of opinion based, also there are 2 f's in ffmpeg – 50-3 Oct 08 '13 at 20:20
  • @50-3 He put two fs in ffmpeg in his title and the tag so obviously he made a brief typo in his command but that's irrelevant. It's a great question 'cos you can run into issues,which u should know if you've ever been to hell and back using ffmpeg.U could try to combine an mp3 and get the wrong duration reported.U could use the wrong codec n not get good support in applications that run the file later.And just see my comment,pointing that he got -ss and -t RIGHT,but it's easy to put it before and lose accuracy, so sure there are things to get right in using it that one might not know about. – barlop Oct 08 '13 at 20:23
  • Exactly what do you mean "Is it wise"? Why do you think it isn't? What happens when you try it? You can backup the video file and then try things you know. ;) – Ƭᴇcʜιᴇ007 Oct 08 '13 at 20:24
  • @techie007 well as an example, he is going from .MOV to .MP4 are his codecs likely to be wrong in his MP4, with the method he is using? – barlop Oct 08 '13 at 20:24
  • 1
    Still a lack of research effort shown (IMO), and not really an actual problem presented. My thinking: Try it, did it work? Yes: done, No: post question explaining what the problem is, what was tried already, and what the results were. His command line was also presented as an "example" not the actual command/arguments he wants to use. But whatever. ;) – Ƭᴇcʜιᴇ007 Oct 08 '13 at 20:27
  • @barlop Yes I know the hell of FFMPEG, I asked for more information as it's very broad at the moment and the more detailed he makes a question the more precise we can be with our answer, I pointed out the typo as I can't change 1 char in a post, Also Thanks for the link most FFMPEG docs are about as easy to read as the app is to use – 50-3 Oct 08 '13 at 20:28
  • It's probably better to just use a GUI video editing program. You certainly *can* do this with ffmpeg (and I have), but this is one of those areas where GUI > CLI. – evilsoup Oct 08 '13 at 20:31
  • @evilsoup nah it's the program not whether it's GUI/CLI. As a techie, I find the avidemux CLI as fine as the avidemux GUI. The flexibility of ffmpeg makes it hellish unless one knows a hell of a lot about video and audio. Don't blame the CLI. – barlop Oct 08 '13 at 20:37
  • I tried to clarify now. @barlop thanks for the link. Sorry by the typo, by the way. – jostyposty Oct 08 '13 at 21:04
  • apparently it's perhaps not such a good idea see this from the documentation for -codec copy "Since there is no decoding or encoding, it is very fast and there is no quality loss. However, it might not work in some cases because of many factors. Applying filters is obviously also impossible, since filters work on uncompressed data." – barlop Oct 08 '13 at 21:06
  • and my initial comment should read xilisoft – barlop Oct 08 '13 at 21:31
  • The complete ffmpeg console output resulting from your command is missing. – llogan Oct 09 '13 at 01:22

1 Answers1

1

I was hoping somebody with more expertise than I, could reply, but sadly I may be your best option at the moment!

Checking an old note, no the command you've done is not wise. Because the codecs are different for different container formats.

Use mediainfo to check the container and video and audio codec in the output file. You want (of) these for mp4.

MPEG4 
   Video codecs   x264, xvid, libavcodec, divx
   Audio codecs  aac,mp3

apparently x264 is a good one for video.

-vcodec libx264

these should be useful for acodec

-acodec libmp3lame   or  -acodec libfaac

ffmpeg documentation says- Regarding -codec copy, (and no doubt this applies to -acodec copy or -c:a copy, or -vcodec copy or -c:v copy)

"Since there is no decoding or encoding, it is very fast and there is no quality loss. However, it might not work in some cases because of many factors. Applying filters is obviously also impossible, since filters work on uncompressed data."

So you need to specify the correct video and audio codecs.

you can check them with mediainfo.exe from mediaarena.net very easy for a techie to use e.g. C:\>mediainfo a.mp4

barlop
  • 23,380
  • 43
  • 145
  • 225
  • Why do you say, "so you need to specify the correct video and audio codecs"? I see no reason to re-encode instead of using [stream copy](http://ffmpeg.org/ffmpeg.html#Stream-copy) if the resulting file works satisfactorily in the OP's editing software. – llogan Oct 09 '13 at 01:24
  • 1
    Thanks, I'll take your advice and look further into encoding with a specified codec. I have used exiftool, but I'll look into mediainfo as well. – jostyposty Oct 09 '13 at 16:35
  • 1
    @LordNeckbeard while it was ok for my iPhone video, I'm not sure it will work for all my videos. I was sort of hoping for a simple solution to "fit them all", but it is now obvious I need to research this way more. – jostyposty Oct 09 '13 at 16:36
  • @LordNeckbeard if it's completely wrongly done and his video editor(by luck) happens to be flexible enough to play it that's not as good as it being completely rightly done,and his video editor plays it and most other editors/players play it no problem. Better to get it right and thus more portable, than wrong and a fluke that it works with the software he happens to use. And better to get it right, than to carelessly or intentionally get it wrong and then test to see if it happens to work. Besides practical reasons like if he wants to send the video to somebody or open it in something else. – barlop Oct 09 '13 at 17:45
  • @jostyposty I think it will "fit them all" for that extension of the output file, once you get the -acodec (aka c:a aka -codec:a) and -vcodec (aka -codec:v aka -c:v) right, then it's right. So try ffmpeg -i iphone4sFullVideo.mov -ss 00:00:10 -t 10 -acodec libmp3lame -vcodec libx264 iphone4sGoodPart.mp4 – barlop Oct 09 '13 at 18:20
  • @jostyposty give that example command a try, and see if it is at least or as more reliable than the one you had e.g. did the one you had work in one player and not another? and did the one I gave work in both. or does the one I gave fail in a player. See if there's any difference there and report back – barlop Oct 09 '13 at 21:20
  • 1
    @barlop My command had some problems regarding IDR, as I understood. The screen was black until next IDR frame was reached, or something. I fixed that with moving the seek (-ss) part before -i, but still got the problem on the end of the video. With your command the video played without problems. One thing I have to investigate more, is sizes. My command: 25 MB, your command 8 MB. Am I loosing quality? – jostyposty Oct 10 '13 at 10:40
  • @jostyposty does my command with work the -ss and -t after the -i blah.mov? (it's better after as you get more accuracy). I don't know for sure if quality is lost, maybe quality is often lost when converting, but the decrease in size would be down to compression.. mpg is huge for example.. compared to mp4. you could try -vcodec mpeg1video -acodec mp2 blah.mpg It'll be huge but not better quality than the mp4. I guess you could perhaps view in VLC media player and zoom in and assess quality that way. – barlop Oct 10 '13 at 18:08
  • 1
    @barlop It works after -i yes. So that is great. Both are video h264, yuv420p, but the difference in bit rate is 21203 kb/s versus 6663 kb/s. Quite big, is it not? I'am thinking of looking further into two pass encoding as well. Encoding time is not an issue, so I thought I'd try to get the best quality I can. Thanks for the guiding. I have some reading to do. – jostyposty Oct 10 '13 at 18:39
  • let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/11005/discussion-between-barlop-and-jostyposty) – barlop Oct 10 '13 at 18:42
  • 1
    @barlop this is kind of embarrassing, but I don't have enough reputation to be in the chat jet. Kind of new here at superuser. – jostyposty Oct 10 '13 at 20:11
  • what I wrote in reply re bitrate and quality, was "I don't know but funnily enough I noticed that when I had a video and did ffmpeg -i a.mp4 -c:a copy -c:v copy a2.mp4 the file size wasa bit different, the bitrate differed. that's no change in format or codecs. seems perhaps just the bitrate changed, and didn't get copied. maybe there's a way to copy the bitrate. otherwise setting it manually but I don't know if that helps re quality." – barlop Oct 11 '13 at 00:25