Concatenating grows file size

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Concatenating grows file size

Cecil Westerhof-3
I use the following Bash code to concatenate some video files:
    first=15
    last=20
    files=$(
        for i in $(seq ${first} ${last}) ; do
            printf "file ${PWD}/%05d.MTS\n" $i
        done
    )
    newFile=$(printf "%05d-%05d" ${first} ${last})
    ffmpeg -f concat -safe 0 -i <(echo "${files}") -c copy ${newFile}.mts

I would expect the resulting file to have the same size as the
original files, but the size grows. The input files are together
10.6 GB while the concatenated file is 10.9 GB. That is 3% extra. Is
this normal, or am I doing something wrong?

I am using version 4.1.4-1~deb10u1.

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Concatenating grows file size

Moritz Barsnick
On Wed, Nov 20, 2019 at 11:54:43 +0100, Cecil Westerhof wrote:
>     ffmpeg -f concat -safe 0 -i <(echo "${files}") -c copy ${newFile}.mts
>
> I would expect the resulting file to have the same size as the
> original files, but the size grows. The input files are together
> 10.6 GB while the concatenated file is 10.9 GB. That is 3% extra. Is
> this normal, or am I doing something wrong?

That is probably to be expected. What ffmpeg does is to remux your
streams. ffmpeg's MPEG-TS muxer may not be as efficient as the
original, and/or have other options, leading to a differing size.

Does the suffix .mts imply the M2TS format? If so, you may need to
specify "-mpegts_m2ts_mode 1" to achieve this, which will make the
muxer operate differently. You can also check out other available
options with "ffmpeg -h muxer=mpegts". But I suppose you should just
accept that the difference is expected, if that's okay for you.

Cheers,
Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Concatenating grows file size

Cecil Westerhof-3
Moritz Barsnick <[hidden email]> writes:

> On Wed, Nov 20, 2019 at 11:54:43 +0100, Cecil Westerhof wrote:
>>     ffmpeg -f concat -safe 0 -i <(echo "${files}") -c copy ${newFile}.mts
>>
>> I would expect the resulting file to have the same size as the
>> original files, but the size grows. The input files are together
>> 10.6 GB while the concatenated file is 10.9 GB. That is 3% extra. Is
>> this normal, or am I doing something wrong?
>
> That is probably to be expected. What ffmpeg does is to remux your
> streams. ffmpeg's MPEG-TS muxer may not be as efficient as the
> original, and/or have other options, leading to a differing size.

Because the '-c copy' I did not expect that, but I do not have to
worry then.

Also, in the past I had another camera which produce MP4 files and I
think there the sizes stayed the same, but I am not sure.


> Does the suffix .mts imply the M2TS format? If so, you may need to
> specify "-mpegts_m2ts_mode 1" to achieve this, which will make the
> muxer operate differently. You can also check out other available
> options with "ffmpeg -h muxer=mpegts". But I suppose you should just
> accept that the difference is expected, if that's okay for you.

Was just wondering if something went wrong. But that is not the case.
What I get is OK. Later I will look in the options you mentioned.

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".