1

I want to combine the following two commands into one command, if possible.

  1. Audio from audio.mp4 on top of the video from video.mp4, output to temp.mp4

    ffmpeg -i video.mp4 -i audio.mp4 -map 0:v:0 -map 1:a:0 -shortest -s hd1080 -r 24 temp.mp4

  2. Hardcode subtitles from subtitles.ass into temp.mp4, and output to final.mp4

    ffmpeg -i temp.mp4 -vf "ass=subtitles.ass" final.mp4

So, is there a way to hardcode the subtitles while I am also remapping the streams from the two video sources? Any attempts I have tried have just resulted in a video with no subtitles. Essentially, I want to avoid the double render.

I've figured out all my ffmpeg problems so far, but this one has me stumped.

Thanks!

System Info: Windows 7

ffmpeg info:

ffmpeg version N-54277-gff130d7 Copyright (c) 2000-2013 the FFmpeg developers built on Jun 30 2013 01:25:12 with gcc 4.7.3 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp eex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo- amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs -- enable-libxvid --enable-zlib libavutil 52. 37.101 / 52. 37.101 libavcodec 55. 17.100 / 55. 17.100 libavformat 55. 10.100 / 55. 10.100 libavdevice 55. 2.100 / 55. 2.100 libavfilter 3. 77.101 / 3. 77.101 libswscale 2. 3.100 / 2. 3.100 libswresample 0. 17.102 / 0. 17.102 libpostproc 52. 3.100 / 52. 3.100

  • What happens if you just add -vf "ass=subtitles.ass" to the first command? – terdon Sep 9 '13 at 23:24
  • This is close to working, as it actually does combine all the data. But the subtitles do not fit properly, they go off screen. The two commands result in clean fit subtitles. This may have to do with the subtitle.ass settings? Some order of operations conflict, since I'm also doing -s hd1080? Is there more I can do to retain the quality/fit? – charlieb Sep 9 '13 at 23:44
  • I have no idea, that's just how commands are generally combined. You might want to mention what operating system you are running and which version of ffmpeg. – terdon Sep 9 '13 at 23:49
  • Thanks. I've edited the original post to include this information. My theory right now is to mess with the .ass file, as there are video dimension settings etc. But I'm open to a command line solution as well. – charlieb Sep 9 '13 at 23:55
  • Okay, if I modify the .ass file to set the PlayResX and PlayResY to the dimensions of the original video, then it does properly fit the subtitles. But, I think because of the -s hd1080 upscaling, the subitles get stretched, and thus there is still quality loss, compared to the two command setup. So right now, it's between quality (1 command, .ass file matches sources) or speed (2 commands, .ass file matches upscaled version). – charlieb Sep 10 '13 at 0:05
0

ffmpeg -i video.mp4 -i audio.mp4 -map 0:v:0 -map 1:a:0 -shortest -s hd1080 -r 24 temp.mp4 && ffmpeg -i temp.mp4 -vf "ass=subtitles.ass" final.mp4

tried this? What I've done is literally put first CMD && second CMD this should execute the first command and IF that went off correctly, then execute the second. If the first fails it should give up and stop.

  • Using the && in the command line like that is cool to know, but this is still two commands. It's still rendering twice, rather than somehow rendering once. Ideally, I can run one command, render one time, and have quality subtitles. Thus saving me about half the time. And since I am doing bulk renderings, these time-savings will add up. Thanks, tho! – charlieb Sep 10 '13 at 0:13
  • ahhh I see the downside of the two commands in the rendering time. – PsychoData Sep 10 '13 at 19:27
  • if the second command use the output of the first command, this solution fails. Using a complete listener is far more better. – user1308990 Jan 29 at 15:43
0

I guess you need

ffmpeg -i video.mp4 -i audio.mp4 -vf "[0:v:0]ass=subtitles.ass[out]" -map out -map 1:a:0 -shortest -s hd1080 -r 24  final.mp4

[0:v:0]ass=subtitles.ass[out] will take the video you need and then redirect it to the stream named out and then we use map to map it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.