Set name of matroska attachment using ffmpeg - ffmpeg

So when attaching files to a matroska container they get a name, normally their original name. However when you are running windows and you supply the full path to the file you want to attach, ffmpeg sets that full path as name of the attachment. How can I rename that attachment, preferably in the same command as the attachment process?

Ok, months later I know the solution: Use
-metadata:s:t filename="cover.jpg"
Replace cover.jpg with your desired filename to be stored in the matroska file. If you run more complex stuff with multiple attachments the stream specifier (:s:t) might be different for you, see -map+metadata ffmpeg documentation

Related

Find all video files in directory with FLAC audio codec

Is it possible to search a directory and output a text file listing every video file that has FLAC audio?
My television doesn't support FLAC so when I run into one I have been converting them with a FFMPEG script but it would be nice to be able to find them all in advance instead of waiting until I hit the problem while trying to play the files. I'm hoping there is a way that doesn't involve just opening every file in Mediainfo and checking manually.
Maybe there is a way to just output all of the Mediainfo information for a directory and then I can just find all FLAC occurrences in a csv sheet?
You can open all files in MediaInfo then export to CSV then open the CSV in a spreadsheet processor, or for a smaller output you can customize the output with the command line version of MediaInfo (see the download section on the MediaInfo website and download the CLI version) and a template file template.txt containing:
General;%CompleteName%,
Audio;%Format%
Audio_Middle;,
File_End;\n
and this command line:
mediainfo --Output=file://template.txt --ParseSpeed=0 YourDir > List.txt
List.txt will contain a CSV file with complete file name in first column, then audio format per track (2nd column has 1st audio format, 3rd column has 2nd audio format...)
--Output=file://template.txt selects the template file.
--ParseSpeed=0 reduces the parsing speed (no need of the extra info from a longer parsing).
YourDir is to be replaced by the directory name you want to scan.
> List.txt sends the output to a file.

How to write exif tags when creating MP4 file with ffmpeg

I see lots of questions asking about how to add EXIF tags to MP4 another other media files with ffmpeg. I am not interested in doing this. I currently have an exiftool command that I am running after the fact, but this takes some time because it has to rewrite the entire file.
What I would like to do instead is to add the tags to the MP4 file while I am originally creating it so that I only have to write the file once.
I found this page on creating metadata, but it does not list any of the metadata I want to set. In am trying to set all the timestamp tags, making sure they are properly set to UTC when applicable as is the case with some of the track/media timestamps.
Update: I see this question has attracted a downvote and a vote to close due to claims about it being off-topic as it allegedly is not about programming. I am using ffmpeg in a bash script which does some automation, so I'm not sure why this claim is being made. There are certainly other similar questions (just look at a few with the ffmpeg tag).
Are you looking for this?
ffmpeg -y -i in.mp4 -metadata creation_time="2015-10-21 07:28:00" -map 0 -c copy out.mp4
Use -metadata creation_time="$(date +'%F %T')" to record the time when your command is launched.

How to get FFmpeg to make an exact copy of a video?

I was playing around with FFmpeg, trying to embed a tag into an mp4 file and remove it later and get back to the original file, when I noticed that the files seemed to be different. Trying to isolate the issue, I tried to do a simple passthrough copy like so:
ffmpeg -i file1.mp4 -codec copy file2.mp4
The md5 sums of both files are different. Am I missing any options/flags to make an exact replica of file1?

Getting exact time-stamp appended to the file from ffmpeg process

I am trying to capture frames using ffmpeg from a stream of video , which i am saving locally to my folder,
I need to know the exact time-stamp at which the frame is being captured
what i have tried so far is :
ffmpeg -i rtsp://ipaddress/axis-media/media.amp?camera=1 -an -vf showinfo %10d.jpg 2> res.txt
which i got from the source :
get-each-frame-time-stamp
this works fine too, the res.txt contains the time-elapsed of each frame since ffmpeg started(if my understanding is not wrong) ,
What i need is to get this time appended to the image files names which are being created or some other ways so that time-stamp information could be stored within the image.
any kind of help would be really appreciated .

Is there an ffmpeg flag to not ask for overwrite but add a number at the end?

I have a script that converts ~8000 files to mp3. I have some files that have a sielar name, where just the extension is diffrent, and they would create all the same .mp3 file with my script at the moment.
So I just want ffmpeg to add something like (x) at the end of the name befor the extension and not ask me every few files.
Thank you!
The flag for overwrite without asking y/n is ( -y ), just include -y in your command.
(-y overwrites files of same name without asking).
Look at ffmpeg docs: https://ffmpeg.org/ffmpeg.html.
To find this flag just search for "overwrite" key word in the docs.
Example to extract an image from video and save it without asking y/n.
ffmpeg -i <video_file_here> -y -ss 00:00:00 -vframes 1 image.jpg)
Now to save file name with a new number each time you can make a bat file with a loop counter variable and increase the number and issue the command with the new number each time.
for a reference on how to do this, you can check one of my questions here. incrementing a counter variable inside a FORLOOP
FFmpeg does not have the functionality you describe.
You need to implement it in your script instead.
Or (on the FFmpeg command line) explicitly specify such output file name that is guaranteed not to exist.
For example, if all your input files are in the same directory, then for an input file named fname.ext use output file named fname.ext.mp3 and place it in a new directory.

Resources