2

I've already read the other articles about concatenating but couldn't find any that discuss specifying the output bitrate.

I have 2 MP4 videos.

What I want to do is speed up the first video to 110% speed (without changing audio pitch) and then concatenate it with the second video (which will remain at normal speed), and I want the resulting video to have a bitrate of 2.5 Mbps (since that's what Wistia told me should be the minimum for my upload).

Currently, my first attempt results in a video where the 2nd part is all mangled and shows bright green, etc. My second attempt (of Step 4) results in a video that has a total bitrate of only 1645kbps.

Step 1:

In Adobe Premiere Pro CC 2017, I've exported 2 videos, each using these settings:

Frame Rate: 30
Field Order: Progressive
Aspect: Square Pixels (1.0)
Profile: Main
Bitrate Encoding: CBR
Target Bitrate [Mbps]: 2.5
Audio Format: AAC
Audio Codec: AAC
Sample Rate: 48000 Hz
Bitrate [kbps]: 320

Step 2.

ffmpeg -i video1.mp4 -filter_complex "setpts=PTS/1.1;atempo=1.1" -c:v libx264 -x264-params "nal-hrd=cbr" -b:v 2.5M -minrate 2.5M -maxrate 2.5M -bufsize 5M video1_faster.mp4

Step 3. Create a text file of this content:

file 'video1_faster.mp4'
file 'video2.mp4'

Step 4 (first attempt).

ffmpeg -f concat -safe 0 -i ffmpeg_concat_list.txt -c copy final.mp4

Step 4 (second attempt) (with re-encoding).

ffmpeg -i video1_faster.mp4 -i video2.mp4 -filter_complex "[0:v] [0:a] [1:v] [1:a] concat=n=2:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" -b:v 2.5M -minrate 2.5M -maxrate 2.5M -bufsize 5M final.mp4

What am I doing wrong? Thanks.

3
  • The two files separate are OK? What version of ffmpeg?
    – rogerdpack
    Commented Aug 7, 2018 at 14:18
  • @rogerdpack Yes. version N-82889-g54931fd Copyright (c) 2000-2016 the FFmpeg developers built with gcc 5.4.0 (GCC)
    – Ryan
    Commented Aug 7, 2018 at 15:44
  • 1
    couple years old, git master "may" work better who knows...
    – rogerdpack
    Commented Aug 7, 2018 at 16:28

2 Answers 2

2

Step 4 (first attempt) will work if you re-encode the 2nd video like the first (without the filters).

What's happening is that besides the timescale difference between CC's output and ffmpeg's (which will only result in timing errors), x264 is producing a High profile stream with a different parameter set than CC's encoder. Re-encode the 2nd video with ffmpeg and your files should be matching. Alternatively, you can speed up in CC and export the 1st video.

2
  • Wow, this simple idea somehow eluded me. Thanks. Even though I strongly prefer to avoid re-encoding whenever possible, I might be willing in this scenario since I haven't found a better solution. P.S. In my experience, FFmpeg does a better job than Adobe Premiere Pro CC 2017 at speeding up a video while preserving audio pitch. Premiere's sounded pretty bad, surprisingly.
    – Ryan
    Commented Jul 27, 2018 at 18:21
  • 1
    Export the audio separately and filter+encode+mux it with CC speeded video. No need to re-encode video then.
    – Gyan
    Commented Jul 27, 2018 at 18:23
0

This seemed to work (roughly*):

ffmpeg -i video1_faster.mp4 -i video2.mp4 -filter_complex "[0:v] [0:a] [1:v] [1:a]  concat=n=2:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" -c:v libx264 -x264-params "nal-hrd=cbr" -b:v 2.5M -minrate 2.5M -maxrate 2.5M -bufsize 5M final.mp4

Notice how I'd been missing the -c:v libx264 -x264-params "nal-hrd=cbr" part in "Step 4 (second attempt)" in my question above.

*It decreased the bitrate of the audio to 103kbps even though the audio bitrates of the 2 input files were 317kbps and 127kbps. So my next project will be to try to figure out how to improve Step 2 to preserve the audio bitrate of the original file and then improve Step 4 to preserve the audio bitrates again.

I'd definitely prefer to accept someone else's (better) answer.

2
  • I wouldn't pay much attention to Wistia's or most other site's bitrate guidelines. They are issued for a mass audience and are meant to be safe floors since most consumer and even pro video editors don't have encoders that do VBR well. Not the case for x264/5 and ffmpeg/fdk AAC. If it looks and sounds good, you're fine.
    – Gyan
    Commented Jul 27, 2018 at 18:42
  • @Gyan That's probably generally true. In this case, it wasn't a guideline to the public but from an email discussion between me and the Wistia support team since my video wasn't performing well on different devices, and their instruction was to re-upload the video at at least 2500kbps.
    – Ryan
    Commented Jul 27, 2018 at 19:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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