i am trying to join two flv files using -concat option in ffmpeg-1.1 . I have created a list named mylist.txt and placed two flv files into it, but the problem i am facing is that the output of first file in mylist.txt streams perfect but video breaks into pieces when it comes to the second file. Looks like i am using the wrong options with -concat, please guide me for suitable commands with -concat option. Following are the commands and configurations i am using for transcoding .flv files:-
mylist.txt
file '/root/1.flv'
file '/root/2.flv'
ffmpeg command :-
ffmpeg -re -f concat -i /root/mylist.txt -acodec copy -vcodec copy output.flv
Following link is the output of ffmpeg command :-
http://pastebin.com/P3uaUDEd
Unless the 2 files were encoded the same (and even if they were it could still be a problem) you would need to transcode the audio and video so that things like time stamps, bitrates, resolutions and other codec internals are correct in both streams. Change you acodec copy and vcodec copy to the codecs of your choice (x264 and mp3/aac are good choices).
Related
I have a folder that contains n video files of mp4 format: 00001.mp4, 00002.mp4, etc...
They are all the same resolution, fps, and dimensions.
What I need is a way to concat them together into one large mp4 file, but to have a specific effect between every two subsequent videos.
For example a flash fade.
Here are some examples: https://biteable.com/blog/video-transitions-effects-examples/
I have access to ffmpeg and looking for some sample commands.
Thanks,
This tutorial here will provide you with a starting point: link
What you will need to do is use:
ffmpeg -i slide.mp4 -y -vf fade=in:0:30 slide_fade_in.mp4
and:
ffmpeg -i slide_fade_in.mp4 -y -vf fade=out:120:30 slide_fade_in_out.mp4
Then combine the files with the effects. In the tutorial, they have setup the script for the combinations.
So...probably a very basic question for those of you familiar with FFMPEG (I'm really not). I know that you can combine multiple videos into one using FFMPEG, but what about if each video has its own srt file, saved separately in a 'subs' folder and NOT included in the video itself?
Is it possible for FFMPEG to also combine the srt files into a single one (and recalculate the timestamps), and then merge this into the final, combined video? If so, what would the command be?
For example, I have video1.mp4 and video2.mp4. They have corresponding sub1.srt and sub2.srt. When video1.mp4 and video2.mp4 are merged, the timestamps for sub2.srt will, of course, be out of sync now and need to be corrected by adding the duration of video1.mp4 to the individual timestamps (i.e., if video1 is 30 seconds long, and the first subtitle in sub2.srt appears at the 2-second mark, then after the combination, it should now appear at the (30+2)=32-second mark, and so on.
If it helps, all the files are mp4, and have the same dimensions (720p).
While there might be a (complicated) way to concatenate the srt files first, the easiest way is to combine pairs of video and text first, and then concatenate the resulting container files.
Copy everything from video1.mp4 and add subtitles from sub1.srt
# Assuming English for subtitle language
ffmpeg -i video1.mp4 -i sub1.srt -c copy -c:s mov_text -metadata:s:s:0 language=en -metadata:s:s:0 title=English 1.mp4
-c copy will copy everything that might be in video1.mp4, and -c:s mov_text will format the text stream from sub1.srt into subtitles for mp4 (mov_text). The result will be written to 1.mp4.
Repeat the same command for all the other video-subtitles pairs.
Create a text file (f.e. chapters.txt) with the resulting file names
file 1.mp4
file 2.mp4
file 3.mp4
…
Concatenate the resulting container files listed in the text file
ffmpeg -f concat -safe 0 -i chapters.txt -c copy everything.mp4
See ffmpeg's concatenate demuxer
There are other ffmpeg commands that can also deal with different dimensions, mentioned in the docs.
For whatever reason I had to explicitly copy the video, audio, and subtitle streams individually on step 4, otherwise I ended up with silent videos. So my step 4 looked like this:
ffmpeg -f concat -safe 0 -i chapter.txt -c:v copy -c:a copy -c:s copy everything.mp4
I'm trying to find a command line to copy part of videos and export them to a different folder.
The problem i need to solve is each file may have different extensions, .mxf, .dv, .avi etc some came from a internal url server that gives download links like /server/download?id=1000 and that will download an mp4, or a mxf so i have no idea the extension.. the name is not important..
i want to know if it's possible or there's an existing command line where the -y file.extension is not needed.
For example
ffmpeg.exe -i "/server/download?id=1000" -vcodec copy -acodec copy -y "folder/"
An i get a filename.avi or filename.mxf inside that "folder/"
.mxf is a container format, so just pulling it in like ffmpeg -i http://xx -vcodec copy -acodec copy OUTPUT.mp4 might work regardless of the input (if it starts as an .mxf then ffmpeg will basically re-container it into an mp4 container). (it will "re-container" the same elemental video/audio streams, which will remain unmodified, I assume that was your initial intent). If you really want to keep the containers also the same, you might be able to run ffmpeg -i http:///xx first, which might tell you the container type, then turn around and run it like ffmpeg -i http://xx -vcodec copy -acodec copy output.ext
I have an array of audio and video clips, where each audio clip has a 1:1 correlation with it's video clip. The encoding of each video and each audio clip are the same. How can I concat all of the audio clips, and all the video clips, then merge them together to output a video. As of now I only figured out how to merge 1 audio clip with 1 video clip:
$ ffmpeg -i video_1.webm -i audio_1.wav -acodec copy -vcodec copy output.mkv
Update
I just came across mkvmerge would this possibly be a better option?
If all the files are encoded with the same codecs then it's easy to do. First merge the audio and video files as you have already done so each pair of files is contained in one mkv. Then you can concatenate them with the concat demuxer like this:
ffmpeg -f concat -i <(printf "file '%s'\n" ./file1.mkv ./file2.mkv ./file3.mkv) -c copy merged.mkv
or:
ffmpeg -f concat -i <(printf "file '%s'\n" ./*.mkv) -c copy merged.mkv
You could also list one file per line in a text file called mergelist.txt (or whatever you want to call it), i.e.:
file './file1.mkv'
file './file2.mkv'
file './file3.mkv'
Then use that as the input, a la:
ffmpeg -f concat -i mergelist.txt -c copy merged.mkv
This is by far the easiest and fastest way to do what you want since it won't re-encode the files, just line them up one after another.
You can find your answer here in this old question:
Concatenate two mp4 files using ffmpeg
This answer is not restricted to MP4. But it will depend on the file format you wanna concatenate!
Once you have your new VIDEO file and AUDIO file, to merge them together:
ffmpeg -i AUDIO -i VIDEO -acodec copy -vcodec copy OUTPUT
I am trying to use ffmpeg (under linux) to add a small title to a video. So, I use:
ffmpeg -i hk.avi -r 30000/1001 -metadata title="SOF" hk_titled.avi
The addition of title seems to work, but, the problem is the output file is about a 1/3rd of the file size of the input file and I was wondering why this is? Is this at the expense of quality of the video? I am unsure.. How do I preserve the same quality/size as the input file?
The main point I am unable to figure out is the use of -r option. Going through the ffmpeg docs, it seems to suggest that -r is frames per second (The input video is 23.9fps). At the moment, (30000/1001) works out to 29 fps, but I was unsure if I should be using this value.
Thanks for your time.
The default settings for ffmpeg do not always provide a good quality output when you encode, but this depends on your output format and the available encoders. With your output ffmpeg will use the default of -b 200k or -b:v 200k.
However, you can tell ffmpeg to simply copy the input streams without re-encoding and this is recommended if you just want to add or edit metadata. These examples do the same thing but use different syntax depending on your ffmpeg version:
ffmpeg -i hk.avi -vcodec copy -acodec copy -metadata title="SOF" hk_titled.avi
ffmpeg -i hk.avi -c copy -metadata title="SOF" hk_titled.avi