I am wondering if there's a program for the following:
I have about 2400 video files of varying lengths (average of 45-50 minutes) and consisting of a mixture of MP4 and FLVs containers. I need to extract their audio and combine it with a static image. The image doesn't matter and it can be the same picture for all 2400 videos, but I need their original audio - bitrate, frequency untouched - in each converted file.
I don't mind if the software is free or paid. As long as it can batch perform the job above, I'll be very happy. Any suggestions will be welcomed. Thanks
+ Reply to Thread
Results 1 to 10 of 10
That could be be done with ffmpeg and a batch file. The batch file could process all files in a folder, all files in a base folder and its sub-folders (and the base can be the root so it could do all files on the drive), or just one file dragged and dropped on it.
The audio can be muxed with the ffmpeg command "-acodec copy". I don't know the commands to create a video from an image but that shouldn't be too hard to find. The hard part might be matching the video length to the audio length -- if that's necessary. Or maybe you could use the same 1 second video for every file. The batch file handles the file name parsing. There are many threads here showing such usage.
Oh, you might run into problems if a video has more than one audio track.
Here's some info:
The -shortest option will cause the output duration to match the duration of the shortest input stream.
As an experiment I tried muxing a one second video with a 60 second AC3 track. Some players played the entire audio track. Some played only the first second. So you probably want the audio and video durations to match.
Last edited by jagabo; 6th Sep 2015 at 22:59.
Adding to the excellent suggestion from Jagabo... The following are the sequences for extracting audio with copy:
And the sequence for creating a video with an image (notice 88 Seconds for Audio time):
Batch will take a little longer to set up because the filename, extensions (unknown codec before extracted from video) have to be obtained before the FFMpeg script can be written correctly. In my case it is an MP3 and it automatically fills it in except this portion is not batch in my program.
Last edited by Budman1; 7th Sep 2015 at 00:27. Reason: Stupid images went in reversed
This script works, I just tested it out. The image must be the same dimensions as the video however. Set your framerate. You just need to make a batch process out of it.
ffmpeg -r 10 -loop 1 -i img.jpg -i video.mp4 -c:v libx264 -pix_fmt yuv420p -crf 22 -c:a copy -shortest out.mkvGot my retirement plans all set. Looks like I only have to work another 5 years after I die........
I created a 5 hour long 23.976 fps video from a 320x180 image using x264 at the veryfast preset at CRF=25 with keyframes every 24 frame so it could be cut at 1 second intervals. It was 186 MB and only took about 2 minutes to render (you only need to create this file once unless you want a different image for each video). Then I used:
ffmpeg -i "C:\path to\videosource.mp4" -i "C:\path to\audiosource.mpg" -c copy -map 0:0 -map 1:1 -shortest out.mp4
Pulldown can be used to further reduce video bandwidth.
A similar 5 hour long all black video was only 14 MB.
Thanks for all your suggestions. I'm still learning the ropes of ffmpeg. Can you please give me the code if the folder contains the following files:
1.flv, 2.flv, 3.flv....20.flv and background.jpg
What would the code be like to make 20 video files with background.jpg with respective audio from each of the 20 flvs? So
Filename "1 new.flv" will consist of audio from 1.flv plus background.jpg, "2 new.flv" will consist of audio from 2.flv plus background.jpg and so on?
You can do it as a batch file, to process all the FLV's in a given folder. There are GUI's you can setup to batch process too. I think FFqueue can do this as a command preset, maybe tencoder can
If you wanted to do it that way, it would look something like this as a batch file. (If you want to do it from the commandline instead of batch file, change each instance of %% to %.) You have to change the paths and filename of the image.jpg. The "quality" is set to crf 20, you can change that as well as the speed/quality of the video (--preset superfast right now) . I arbitrarily set the frame rate to 15fps (-r 15), but you can set it to whatever you want for a still image source. If fine seeking is important in these files, you might want to adjust the default keyframe interval of 250 to something lower (in ffmpeg you can use -g . So -g 100 would set a max interval of 100)
for %%a in ("*.flv") do ffmpeg -i "%%a" -r 15 -i "PATH\to\Image\image.jpg" -map 0:1 -map 1:0 -c:v libx264 -preset:v superfast -crf 20 -c:a copy -shortest "OUTPUT\PATH\%%~na.flv" pause
But one of jagabo's points was to pre-render the image file into a video with longer length than the longest FLV. That way you don't have encode it again for every instance. If you have hundreds of video that would save hours, maybe even days if the videos are long. But at a --keyint of 24, there is about a second of accuracy where it might be off - that's the "negative" of doing it that way. By "off" I mean the video should have an "overhang" of up to about 1 second , which shouldn't be a big deal in most situations. If you wanted to do that it would look something like this (this assumes you made the image into a video as MKV). The default --keyint is 250, so it might be 10sec off so make sure you reduce the value when you make your pre-rendered video
for %%a in ("*.flv") do ffmpeg -i "%%a" -i "PATH\to\video\video.mkv" -map 0:1 -map 1:0 -c:v copy -c:a copy -shortest "OUTPUT\PATH\%%~na.flv" pause
The way the command is written, it only does FLV's in a given folder. If you wanted to you could modify it for MP4's for example
Last edited by poisondeathray; 8th Sep 2015 at 10:54.
Be careful with creating FLV files in the same folder with your source FLV files. "for %%a in ("*.flv") do..." will see the newly created files and process them in turn. You will be stuck in an endless recursion. Put the output in a different folder or use a different container (extension).
Last edited by jagabo; 8th Sep 2015 at 12:13.