I have been trying to hardsub a video via cmd for a long time now. Still i could not find a proper way of doing it. I tried HandbrakeCLI, ffmpeg and mencoder but still could not find a way to do it. I got so closer to hardsubbing with HandbrakeCLI but there were some codeset problems and it wasn't really a hardsub at the end. I really need to find a way to hardsub .avi/.mp4 files via CMD. If you know any ways to do it please help me out! Thanks.
Try this:
mencoder -sub sub.srt -utf8 -font 'Arial Unicode MS' in.mp4 -o out.mp4 -of lavf -oac copy -fafmttag 0x706D -ovc x264 -x264encopts profile=baseline:bitrate=300k
After this I have to pass it through ffmpeg:
ffmpeg -i out.mp4 -acodec copy -vcodec copy final.mp4
as there is some issue with mp4 generated by mencoder, it does not play on some android phones.
Related
I have seen a few discussions on this but none of them give the answer I was hoping for. I am trying to convert flac to alac while preserving all of the tags and the embedded cover image. I know we can manually set a cover image by passing a separate image file to ffmpeg.... but how do I use the one embedded in the flac file? dbpoweramp does this automatically, but I would rather use ffmpeg so that I can automate my workflow with a bash script.
ffmpeg -i input.flac -c:v copy -c:a alac output.m4a
Fixed by adding a source that has a newer version...
sudo add-apt-repository ppa:jonathonf/ffmpeg-4
...And using #logan command...
ffmpeg -i input.flac -c:v copy -c:a alac output.m4a
Thanks
I was unable to get the jonathon ppa to work on my rig so you can use "-vcodec copy "
"$FILE" -vcodec copy -acodec alac "$NEW_FILE" to copy the image over to the new file.
However, I do see that file names with "()" sometimes don't convert. I don't get an error in my script it just moves on. without the copy. Would be nice if anyone know how to fix that.
I am using ffmpeg to switch container from mkv to mp4 via this command:
ffmpeg -i filename.mkv -vcodec copy 1.mp4
this is the simplest command that I found when converting from mkv container to mp4 without re-encoding. The output stated otherwise (if I am not mistaken)
This is a small screen shot of the the output:
Where it said Stream Mapping, #0:0 (264 (native)) -> 264 (libx264)). Does this mean that it's re-encoding from x264 to libx264? What Did I do wrong?
Any help is appreciated...
problem solved, specify the audio codec solve my problem...
ffmpeg -i filename.mkv -vcodec copy -acodec copy 1.mp4
Remuxing containers, e.g. MKV or AVI to MP4, with FFmpeg will only keep a single – it tries to choose the best one available – audio and video stream from the input file in the output file. This can be avoided by providing -map 0.
Matroska files frequently contain subtitles in a format not supported in MOV/MPEG containers by FFmpeg, esp. SRT/Subrip or ASS/SSA. They can either simply be dropped with -sn or be converted to a native format like mov_text. (You could also burn hard subtitles into a video stream with filters.)
Sometimes, adding missing information by using heuristics might help. This is activated with -find_stream_info, but I am not sure whether this should be used by default.
I shall assume that built configuration is not important to know (-hide_banner) and only serious problems should be logged to the console (-loglevel warning, alternatively: quiet | panic | fatal | error | warning | info (default) | verbose | debug | trace).
Therefore, a rather universal conversion command looks like this:
$ ffmpeg -find_stream_info -i input.mkv \
-map 0 -codec copy -codec:s mov_text output.mp4 \
-hide_banner -loglevel warning; \
rm input.mkv
For batch processing multiple files on a Windows box within cmd and overwriting existing files (-y), use for:
FOR /r %F IN (*.mkv) DO (#ffmpeg \
-find_stream_info -i "%F" \
-map 0 -codec copy -codec:s mov_text "%~pnF.mp4" \
-hide_banner -loglevel warning -y)
ffmpeg.exe -i input_file_name.mkv output_file_name.mp4
It converts to mp4 but it making a bigger size. :)
For those who use Windows and want to convert a directory of MKV files, throw this batch file in the same directory and execute it:
#ECHO OFF
FOR %%F IN (*.mkv) DO (
ffmpeg -i %%~nF.mkv -acodec copy -vcodec copy %%~nF.mp4
)
Some context in case anyone else is facing the same:
I'd previously recorded my desktop using OBS; the mkv file wasn't accepted by Sony Vegas. I ran the above batch which called ffmpeg on each of the captures and the resultant MP4s were accepted by Sony Vegas.
From the shell, when I specify a sequence of images via %d in the input filename, FFMPEG insists "No such file or directory", despite evidence to the contrary. Looking online, I haven't managed to find any references to generating video from a sequence of images using FFMPEG where %d is not used, yet it seems to fail here.
My images should be identified by FFMPEG from img%06d.gif. Issuing ls img[0-9][0-9][0-9][0-9][0-9][0-9].gif succeeds in the very same directory I issue the FFMPEG command.
The command I use is:
ffmpeg -i img%06d.gif -c:v libx264 -r 30 -pix_fmt yuv720p test.mp4
What could possibly be going wrong???
The following definitely works:
ffmpeg -i images%06d.png -c:v libx264 -r 30 test.mp4 -y
However it doesn't work with GIF pictures.
You can losslessly convert your pictures to PNG and run the above command line.
I have this ffmpeg one-liner that's been good for generating video files for my Nexus One:
ffmpeg -i infile.mkv -acodec aac -s 572x238 -vcodec libx264 -vpre ipod640 -ab 128k -b 512k -f mp4 -strict experimental outfile.mp4
But it does this ignorant of the subtitles in infile.mkv -- usually not a problem, unless I'm dealing with a non-english movie. In cases like this, I'd like to use the Japanese audio track, and the English subtitles.
The funny bit is that I can use mplayer to play it using -alang and -slang, but don't know how to use mencoder to make Nexus One friendly videos. I can use ffmpeg to generate Nexus One friendly videos, but can't figure out how to get it to use a specific subtitle track.
If someone can solve one of these for me, I'll be a happy camper.
Well after a lot of googling and trial & error, here is what worked for me:
mencoder infile.mkv -o outfile.mp4 -vf dsize=512:352:2,scale=-8:-8,harddup -oac faac -faacopts mpeg=4:object=2:raw:br=128 -of lavf -lavfopts format=mp4 -ovc x264 -sws 9 -x264encopts nocabac:level_idc=30:bframes=0:bitrate=264:threads=auto:global_header:threads=auto:subq=5:frameref=6:partitions=all:trellis=1:chroma_me:me=umh
It's not using ffmpeg, but it appears to be working.
Hi i have command to merge video files
but i want to join an image to a video file.
What i am doing:
1) convert image to mp4 using ffmpeg
2) joining this converted video to my selected video using mencoder
but it prommpts an error:
cannot mix video only files with audio-video files try -nosound.
i also added -nosound but with this the resultant file does not contains any audio.
what to do?
ffmpeg command:
-y -i Garden.jpg -s 640x480 converted.mp4
this converted .mp4 file is created properly but with no audio
mencoder command:
-oac mp3lame -ovc lavc -noodml -o output.mp4 converted.mp4 selected.mp4
Please help..
If you target is Windows, converting the result to msmpeg4v2 (avi) or mpeg1video (mpg) or asf (wmv) would probably work best.
Note, ASF files often have .wmv or .wma extensions in Windows. It should also be mentioned that Microsoft claims a patent on the ASF format, and may sue or threaten users who create ASF files with non-Microsoft software. It is strongly advised to avoid ASF where possible.
Read this for full list.
Here is a free command line tool which can join MPEG 1 files:
http://mpgtx.sourceforge.net/#Download
(Windows exe available). Did not try it on my own, however.
EDIT: another alternative may be to utilize VirtualDub. You have to write your merge command to a script and pass the script name per command line:
http://www.virtualdub.org/blog/pivot/entry.php?id=20
However, you have to get yourself through the syntax of the scripting language
http://www.virtualdub.org/docs/vdscript.txt
(I did not try this by myself programmatically, have only used virtual dub via GUI interface to concat video files, which worked really well.)
FFmpeg can accomplish this easily with the following command:
ffmpeg -i vid-1.mp4 -i vid-2.mp4 -ar 44100 -ab 64k -ac 1 -c:a libmp3lame -filter_complex '[0:0] [0:1] [1:0] [1:1] concat=n=2:v=1:a=1 [v] [a]' -map '[v]' -map '[a]' output.mp4