9

I am trying to change speed of the video that does not contain audio stream via below command

String[]{"ffmpeg", "-y", "-i", orginalFile, "-threads", "5", "-preset", "ultrafast", "-strict", "experimental", "-filter_complex", "[0:v]setpts=0.50*PTS[v];[0:a]atempo=2.0[a]", "-map", "[v]", "-map", "[a]", "-b", "2097k", "-ab", "48000", "-ac", "2", "-ar", "22050", "-vcodec", "mpeg4", destinationFile};

Command fails stating that video does not have audio stream. So, do I need to check whether audio stream is present in the video or is there something I can do in this scenario?

Lalit Sharma
  • 1,142
  • 1
  • 15
  • 32

3 Answers3

3

You need to check the video before running the command (using ffmpeg -i ) You will get the information in the vk.log. Parse it, and see if you have audio. Then run the correct command.

Eli
  • 707
  • 8
  • 16
2

Option -map a only accept video with audio stream, There are some video have not audio. you need use -map 0. Solution for two case is you use ?:

 -map [a?]

The ? teels ffmpeg to only map the stream if it exists.

mdtuyen
  • 4,470
  • 5
  • 28
  • 50
  • Thanks @phongvan It does not work here is what I tried: String[]{"ffmpeg", "-y", "-i", orginalFile, "-threads", "5", "-preset", "ultrafast", "-strict", "experimental", "-filter_complex", "[0:v]setpts=0.50*PTS[v];[0:a]atempo=2.0[a]", "-map", "[v]", "-map", "[a?]", "-b", "2097k", "-ab", "48000", "-ac", "2", "-ar", "22050", "-vcodec", "mpeg4", destinationFile}; – Lalit Sharma Jul 06 '16 at 08:39
  • Could you try: String[]{"ffmpeg", "-y", "-i", orginalFile, "-threads", "5", "-preset", "ultrafast", "-strict", "experimental", "-filter_complex", "[0:v]setpts=0.50*PTS[v];[0:a]atempo=2.0[a]", "-map", "[v]", "-map", "0:a?", "-b", "2097k", "-ab", "48000", "-ac", "2", "-ar", "22050", "-vcodec", "mpeg4", destinationFile}; ? – mdtuyen Jul 06 '16 at 09:01
  • that won't work. try ` String[]{"-ss", lastTime, "-i", selectedVideoPath, "-t", now, "-filter:v", "setpts=0.5*PTS","-strict", "-2", videoPath};` – Abhishek T. Jul 26 '16 at 04:34
2

If you use stream-specific filterchains, you use should be able to process all files - with or without audio.

Use

String[]{"ffmpeg", "-y", "-i", originalFile, "-threads", "5",
         "-map", "0:v", "-map", "0:a?",
         "-vf setpts=0.50*PTS", "-vcodec", "mpeg4", "-preset", "ultrafast", "-b:v", "2097k",
         "-af atempo=2.0", "-b:a", "48000", "-ac", "2", "-ar", "22050",
         "-strict", "experimental", destinationFile}
Gyan
  • 85,394
  • 9
  • 169
  • 201