<p>The concat demuxer amalgamates all its inputs and presents them as a single input. It takes the properties of the first input as representing the properties of the amalgam. Since the 1st input has a rotation angle, that gets carried over.</p>
<p><code>noautorotate</code> only takes effect during encoding, not with <code>-c copy</code>.</p>
<p>Easiest way forward, at present, is to re-encode all inputs without <code>noautorotate</code> and then concat.
Next is to re-encode only the first input. But then you have to match the encoding of the other inputs (bitrate doesn't matter).</p>
<p>Ultimately, during recording next time, make sure all videos are taken with the phone in identical orientation (not flipped in one recording).</p>

CC BY-SA 4.0
2022-11-01T09:13:00.673Z
Thanks. `ffmpeg -i input.mp4 -c:a copy re-encoded.mp4` on each of the files solved the matter.
John Smith
CC BY-SA 4.0
2022-11-01T04:54:44.157Z
2022-11-01T04:54:44.157Z
Gyan
<p>My text file <code>list_of_fragments</code> contains the list of video files to be concatenated.
I assumed they have the same streams (shot from the same smartphone, with the same settings)</p>
<pre><code>file barbell-home.mp4
file before.mp4
file before-otherview.mp4
file rotated.tr.mp4
file squatting-rack.mp4
</code></pre>
<p>I attempted to concatenate them all with: <code>ffmpeg -loglevel warning -hide_banner -f concat -safe 0 -i list_of_fragments -c copy conc-output.mp4</code>
Sadly, the video corresponding to the files <code>before.mp4</code>, <code>before-otherview.mp4</code>, <code>rotated.tr.mp4</code>, <code>squatting-rack.mp4</code> was flipped upside down, i.e. rotated 180 degrees (the part corresponding to <code>barbell-home.mp4</code> was not rotated).
<code>ffprobe</code> returns (for the sake of brevity I've not included audio streams):</p>
<pre><code>Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'barbell-home.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2022-10-30T15:11:45.000000Z
    com.android.version: 11
  Duration: 00:00:02.05, start: 0.000000, bitrate: 21155 kb/s
  Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 20059 kb/s, SAR 1:1 DAR 16:9, 29.92 fps, 29.92 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      rotate          : 180
      creation_time   : 2022-10-30T15:11:45.000000Z
      handler_name    : VideoHandle
      vendor_id       : [0][0][0][0]
    Side data:
      displaymatrix: rotation of -180.00 degrees
</code></pre>
<pre><code>Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'before.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2022-10-26T11:50:04.000000Z
    com.android.version: 11
  Duration: 00:00:04.22, start: 0.000000, bitrate: 21335 kb/s
  Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 20384 kb/s, SAR 1:1 DAR 16:9, 29.94 fps, 29.92 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      creation_time   : 2022-10-26T11:50:04.000000Z
      handler_name    : VideoHandle
      vendor_id       : [0][0][0][0]
</code></pre>
<pre><code>Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'before-otherview.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2022-10-26T11:50:15.000000Z
    com.android.version: 11
  Duration: 00:00:02.47, start: 0.000000, bitrate: 21370 kb/s
  Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 20377 kb/s, SAR 1:1 DAR 16:9, 29.94 fps, 29.92 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      creation_time   : 2022-10-26T11:50:15.000000Z
      handler_name    : VideoHandle
      vendor_id       : [0][0][0][0]
</code></pre>
<pre><code>Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'rotated.tr.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.76.100
  Duration: 00:00:04.85, start: 0.000000, bitrate: 25889 kb/s
  Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 25605 kb/s, 29.92 fps, 29.92 tbr, 11488 tbn, 59.83 tbc (default)
    Metadata:
      handler_name    : VideoHandle
      vendor_id       : [0][0][0][0]
</code></pre>
<pre><code>Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'squatting-rack.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.76.100
  Duration: 00:00:01.77, start: 0.021000, bitrate: 19986 kb/s
  Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 20105 kb/s, SAR 1:1 DAR 16:9, 29.94 fps, 29.92 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      handler_name    : VideoHandle
      vendor_id       : [0][0][0][0]

</code></pre>
<p>After taking a closer look at <code>ffprobe</code>'s output I realized:</p>
<ol>
<li>The files differ in their bitrate.</li>
<li>Only the first file does <code>rotate : 180</code> in the metadata of its video stream.</li>
</ol>
<p>My questions:</p>
<ol>
<li>Why does only <code>barbell-home.mp4</code> have <code>rotate : 180</code> in the metadata of its video stream and what is the significance of it when concatenating with <code>ffmpeg</code>?</li>
<li><a href="https://superuser.com/a/1535778/1221334">Adding</a> <code>-noautorotate</code> to the command, <code>ffmpeg -loglevel warning -hide_banner -f concat -safe 0 -noautorotate -i list_of_fragments -c copy conc-output.mp4</code>, does not change the output? Why so?</li>
<li>Should I add <code>rotate : 180</code> to the rest of the files or should I remove <code>rotate : 180</code>
from <code>barbell-home.mp4</code> before proceeding to concatenate them all? If so, how might I accomplish this?</li>
<li>How might I concatenate the files in question without flipping the video upside-down?</li>
</ol>

<ffmpeg><metadata><ffprobe><concatenation>
Why does ffmpeg flip upside-down the video when concatenating with -f concat?
John Smith
# Why does ffmpeg flip upside-down the video when concatenating with -f concat?

(Asked by: username_0 on 2022-10-31)

My text file list_of_fragments contains the list of video files to be concatenated.
I assumed they have the same streams (shot from the same smartphone, with the same settings)
file barbell-home.mp4
file before.mp4
file before-otherview.mp4
file rotated.tr.mp4
file squatting-rack.mp4

I attempted to concatenate them all with: ffmpeg -loglevel warning -hide_banner -f concat -safe 0 -i list_of_fragments -c copy conc-output.mp4
Sadly, the video corresponding to the files before.mp4, before-otherview.mp4, rotated.tr.mp4, squatting-rack.mp4 was flipped upside down, i.e. rotated 180 degrees (the part corresponding to barbell-home.mp4 was not rotated).
ffprobe returns (for the sake of brevity I've not included audio streams):
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'barbell-home.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2022-10-30T15:11:45.000000Z
    com.android.version: 11
  Duration: 00:00:02.05, start: 0.000000, bitrate: 21155 kb/s
  Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 20059 kb/s, SAR 1:1 DAR 16:9, 29.92 fps, 29.92 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      rotate          : 180
      creation_time   : 2022-10-30T15:11:45.000000Z
      handler_name    : VideoHandle
      vendor_id       : [0][0][0][0]
    Side data:
      displaymatrix: rotation of -180.00 degrees

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'before.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2022-10-26T11:50:04.000000Z
    com.android.version: 11
  Duration: 00:00:04.22, start: 0.000000, bitrate: 21335 kb/s
  Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 20384 kb/s, SAR 1:1 DAR 16:9, 29.94 fps, 29.92 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      creation_time   : 2022-10-26T11:50:04.000000Z
      handler_name    : VideoHandle
      vendor_id       : [0][0][0][0]

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'before-otherview.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2022-10-26T11:50:15.000000Z
    com.android.version: 11
  Duration: 00:00:02.47, start: 0.000000, bitrate: 21370 kb/s
  Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 20377 kb/s, SAR 1:1 DAR 16:9, 29.94 fps, 29.92 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      creation_time   : 2022-10-26T11:50:15.000000Z
      handler_name    : VideoHandle
      vendor_id       : [0][0][0][0]

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'rotated.tr.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.76.100
  Duration: 00:00:04.85, start: 0.000000, bitrate: 25889 kb/s
  Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 25605 kb/s, 29.92 fps, 29.92 tbr, 11488 tbn, 59.83 tbc (default)
    Metadata:
      handler_name    : VideoHandle
      vendor_id       : [0][0][0][0]

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'squatting-rack.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.76.100
  Duration: 00:00:01.77, start: 0.021000, bitrate: 19986 kb/s
  Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 20105 kb/s, SAR 1:1 DAR 16:9, 29.94 fps, 29.92 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      handler_name    : VideoHandle
      vendor_id       : [0][0][0][0]


After taking a closer look at ffprobe's output I realized:

The files differ in their bitrate.
Only the first file does rotate : 180 in the metadata of its video stream.

My questions:

Why does only barbell-home.mp4 have rotate : 180 in the metadata of its video stream and what is the significance of it when concatenating with ffmpeg?
Adding -noautorotate to the command, ffmpeg -loglevel warning -hide_banner -f concat -safe 0 -noautorotate -i list_of_fragments -c copy conc-output.mp4, does not change the output? Why so?
Should I add rotate : 180 to the rest of the files or should I remove rotate : 180
from barbell-home.mp4 before proceeding to concatenate them all? If so, how might I accomplish this?
How might I concatenate the files in question without flipping the video upside-down?

**Tags:** ffmpeg, metadata, ffprobe, concatenation


---

## 1 answers

### Answer by username_1 on 2022-11-01. Score: 3 | Accepted answer

The concat demuxer amalgamates all its inputs and presents them as a single input. It takes the properties of the first input as representing the properties of the amalgam. Since the 1st input has a rotation angle, that gets carried over.

`noautorotate` only takes effect during encoding, not with `-c copy`.

Easiest way forward, at present, is to re-encode all inputs without `noautorotate` and then concat.
Next is to re-encode only the first input. But then you have to match the encoding of the other inputs (bitrate doesn't matter).

Ultimately, during recording next time, make sure all videos are taken with the phone in identical orientation (not flipped in one recording).

> **Comments:**
> **username_0**: Thanks. `ffmpeg -i input.mp4 -c:a copy re-encoded.mp4` on each of the files solved the matter.  

---

