advertisement


ffmpeg linux video question

Jim Audiomisc

pfm Member
I've got an assortment of old video files that someone has given to me. Some play OK with VLC. Others have the problem that if I try to move to or start to a time during the video the sound either goes AWOL or is for a *different* time, so wildly out of synch.

The problem seems due to the files lacking timestamps. Question is, how can I use ffmpeg to add them while not making any change to the video and audio streams themselves? - i.e. no transcoding that may lower the quality?

Looked on the web and found info on generating an on-screen 'clock' from timestamps. But nowt that tells me how to do this.

Videos are UK SD so presumably 25 fps
 
You don't specify what format these files are in but I wouldn't worry about transcoding too much, and always work with a copy of the originals. Probably the easiest thing to do is to demux the video and remux it with timestamps. That ought to preserve the quality. Some talk about it here: https://superuser.com/questions/1159056/ffmpeg-recreate-timestamps-without-reencoding
You could probably pipe the demux and remux commands together.

ffmpeg is immensely powerful and can do pretty much everything. Which is why I see tools like Adobe Media Encoder used instead, because their presets just work for people. If you had to batch process files though, it's definitely worth learning all the options.

For anyone wanting a primer on GOPs:
https://aws.amazon.com/blogs/media/part-1-back-to-basics-gops-explained/

Personally, if you have a decent Linux distro and chunky graphics card I'd download DaVinci Resolve and re-export the media. You get a lot of tools for free, too.

P.S I'm finding VLC a shadow of its former self. Even the latest version on Mac seems to randomly hang when streaming audio from, say, BBC. It used to just work, now I'm hearing about editors and 3D guys using potplayer instead.
 
Do you want to use ffmpeg so you can batch process the files from the command line?

Otherwise could you import the files to a video editor then render them? I'm pretty sure kdenlive generates a script for the render process which can be run from the command line.

https://docs.kdenlive.org/en/exporting.html#exporting

I'll look at the url. If I can sort out doing this using ffmpeg I can do what is usual for me.

I write a simple ROXFiler app that can then accept files via drag-and-drop and then process them. (ROXFiler mimics the behaviour of RISC OS and gives you a taskbar the ROXApps can have an icon on. You then just dnd items to the icon and Bob's yer uncle. Makes repetitive tasks easy. Particularly when you may also want to do other things to the resulting set of output files.
 
You don't specify what format these files are in but I wouldn't worry about transcoding too much, and always work with a copy of the originals. Probably the easiest thing to do is to demux the video and remux it with timestamps. That ought to preserve the quality. Some talk about it here: https://superuser.com/questions/1159056/ffmpeg-recreate-timestamps-without-reencoding
You could probably pipe the demux and remux commands together.

ffmpeg is immensely powerful and can do pretty much everything.

(snip for revity)

Ta. I'll check out some of that. I am looking for being able to process batches.

I did use ffprobe to check the stream details, etc, but offhand I've forgotten them at present (writing this on my RISC OS machine, not linux.)

The files are old ones from ancient 'home viideo recorders' of some kind. An assortment of sources I suspect, all just labelled '.AVI'. All are SD UK framerate, but not ure which may be from Digital TV, or ye olde Analoge PAL, or what!

Some are OK, others only work as they are if you let them play from start to finish with no attempt to jump to some other part. I'm sure ffmpeg can add sequential timestamps, but not yet seen the magic incantation and recognised it.

Part of the problem is that the video is already pretty low quality. So I want to avoid any transcoding that would make it even worse to look at!
 
I'm still trying this. However as yet I've tried a few of the apparent 'magic incantations' on the above page, but no coconut thus far. So must still be omitting some vital arrangement in the call. At present just trying in a terminal. Problem is that I don't really uderstand this or the comments on the page. So am reduced to "try various arrangements and see if any salute!" :-/ I'll keep going back and having another nibble.
 
If it plays in VLC then there are some rudimentary conversion tools in it. However it's always been a bit ropey and I've just tried a couple of conversions, and the output files got truncated to various degrees. Not great.

If the video is from an old capture card it could be any format and pixel aspect. I'm guessing they're all the same format.
I'd be tempted to download Handbrake for linux and use that to find some acceptable settings. It also has a CLI although I've not used it.
https://handbrake.fr/docs/en/1.5.0/cli/command-line-reference.html - I have a feeling that it uses a lot of ffmpeg options.
Old video formats *may* be Video CD compatible, e.g. quarter resolution, as VHS wasn't that high quality a source anyway; use 4:2:0 colour sampling, run at 25fps progressive, etc.

If it's not going back to DVD or videotape then don't forget to account for the pixel aspect ratio, if the source transcoder hasn't done already. e.g. 4:3 PAL at 720x576 needs to be expanded to 768x576 for square pixel displays like PCs.
 


advertisement


Back
Top