Mencoder subtitle problem - mencoder

I want to include subtitle to a avi file with mencorder. Mencoder is starting to encode but subtitle does not appeaer in new file. Here is my mencoder code
/usr/local/bin/mencoder -oac copy -ovc copy -sub "mov.srt" -o "Domino_with_subs.avi" "mov.avi"

It's because you set the video codec to by copied... To be able to add subtitle mencoder needs to re-encode the video.
This will work
/usr/local/bin/mencoder -oac copy -ovc lavc -sub "mov.srt" -o "Domino_with_subs.avi" "mov.avi"

Related

ffmpeg merge audio of two videos

i have a couple of videos and i want to make them smaller to save some space... therefore i really would like to merge the audiotracks of file1 into file2
so that i can later on delete file1 because the picture content of both videos is the same...
Is there a way to accomplish that with ffmpeg? With this cmd i would have 2 video/audio tracks in one file so this is NOT what i want.
ffmpeg -i file1.mp4 -i file2.mp4 -c copy output.mp4
i only want the audio of file1 and the video and audio of file2 merge into one file...
Thanks
You need to use the map option:
ffmpeg -i file1.mp4 -i file2.mp4 -map 1 -map 0:a -c copy output.mp4
This selects all streams from the 2nd input and the audio streams from the first.
BTW, your command wouldn't have copied both audio and video tracks; only one audio and video from among both inputs. See https://ffmpeg.org/ffmpeg.html#Stream-selection

FFmpeg concat audio with video or gif looping

I'm looking for a solution in FFmpeg to merge audio (mp3) with a short video loop, or gif.
I've already been able to generate a video from an image by joining with audio, but the video stays static frame for the audio duration, the command to make this:
ffmpeg -loop 1 -i imagem.jpg -i audio.mp3 -vcodec h264 -tune stillimage -acodec aac -b:a 64k -pix_fmt yuv420p -shortest video.mp4
I need video that has the duration of the audio, but that uses a loop of another mp4 or a gif. To keep repeating for the duration of the audio.
To do this with a video (MP4 or other format) you should use the Concatenate demuxer.
First create a text file with a list of the paths of the videos you want to concatenate. In your case it will be a list of the same video file, like the following.
# mylist.txt
file /your/path/video.mp4
file /your/path/video.mp4
file /your/path/video.mp4
The paths can be absolute or relative.
Then you need to use the concat demuxer option.
ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4
This will generate an mp4 with your original video looping 3 times. If your original video is 4 seconds long, then the output will be 12 seconds long. I suggest that you create a video just a bit longer than your audio track and then use the -shortest option when creating your final video.
You can add the audio within this same command like you do in your post. So, all together will look like this:
ffmpeg -f concat -safe 0 -i mylist.txt -i audio.mp3 -c:v copy -c:a copy -shortest output.mp4
In my example I do a stream copy for my output (this will work just fine and will be very fast), but you can use the codecs you want for yours (like H264 and AAC like your post).
You can find more info in the concat demuxer documentation or better yet the concat wiki.
At the moment I don't know if there's a way to do this with a gif file.

Combining an image sequence with audio and make a video

I am trying to take a video extract the frames and the audio.Then i do some compression on the frames and then i want to combine the image frames with the audio to create the video.
1.Create frames from video based on fps (lossless)
ffmpeg -i big_buck_bunny_480p_surround-fix.avi -q:v 1 ./vidtest/out%d.jpg
The problem here is that the quality of the image is 94 based on graphicsmagick , how can i extract the frames at original quality.
2.Getting the audio
ffmpeg -i big_buck_bunny_480p_surround-fix.avi -vn -acodec copy big_buck_bunny_480p_surround-fix.ac3
3.How do i combine the audio with the image sequences
It seems like you already understand how to extract the audio stream from a video, so we'll skip that step.
Let's assume you have a video file named video.mp4 and an audio file named audio.mp3. You want to take stills from the video and create a slideshow with audio.mp3 as the audio track.
First we'll extract the stills. fps=1/10 means that frames will be extracted every tenth second. -ss 00:00:5 means that we'll begin five seconds from the start. The first bit of a video is often a fade-in containing mostly black, so it might be desirable to skip that.
ffmpeg -ss 00:00:5 -i video.mp4 -vf fps=1/10 image%03d.png
Next we'll count how many images that resulted in. This will be handy to know when we're specifying the frame rate of the slideshow.
imgcount=$(find . -maxdepth 1 -name "image*" | wc -l)
echo $imgcount
The duration of the audio track would also be nice to know. With MP3 and similar formats, especially when encoded with a variable bit rate, estimation of duration can be fraught. To get around this the audio file can be converted into a WAV file, f.ex, and then the duration estimated.
adur=$(ffprobe -v error -select_streams a:0 -show_entries stream=duration \
-of default=noprint_wrappers=1:nokey=1 audio.mp3)
echo $adur
Now we'll recombine the images into a slideshow. $imgcount/$adur specifies the display rate of the stills so the duration matches that of the audio file reasonably well. -r 25 specifies the actual frame-rate of the video. Not all formats and video players accept unusual frame-rates.
ffmpeg -framerate $imgcount/$adur -i image%03d.png -c:v libx264 -r 25 \
-pix_fmt yuv422p slideshow.mp4
This will mux the audio file and the slideshow file and trim to the duration of the shortest of the two. This works if the container format supports the codec of the audio file, if not either the audio file has to be re-converted, or another container format chosen. I find Matroska (.mkv) very useful. In the case of .avi and .ac3 or .mp4 and .mp3 there should be no problem.
ffmpeg -i slideshow.mp4 -i audio.mp3 -codec copy -shortest slideshow-sound.mp4

How can i add cover image on mp3 file using ffmpeg?

I'm trying to convert audio file to mp3 and I want to add cover image into mp3 file.
I tried this:
ffmpeg.exe -i "input audio file" -i image.png out.mp3
When conversion completes there is no cover image into mp3.
I tried and this which is from the official documentation of ffmpeg. The result is the same mp3 file without cover image.
ffmpeg -i input.mp3 -i cover.png -c copy -metadata:s:v title="Album cover"-metadata:s:v comment="Cover (Front)" out.mp3
Thank you in advance!

Reverse video generating with mencoder

I'm currently using mencoder to generate a video file output of many pngs
mencoder 'mf://*.png' -mf type=png:fps=2 -ovc lavc -lavcopts vcodec=wmv2 -oac copy -o out.mpg")
This works fine, but i actually need the time reversed version. Sure it would be possible to rename the files so they are in the right order but isn't there another way to start with the higher values and stop with the lower ones?
I might be late, bit for the record:
ls -r *.png >> filelist.txt; mencoder "mf://#filelist.txt" -ovc lavc -o aegeespirit2.avi

Resources