[FFmpeg-user] Difference between FFmpeg Formats/Containers MP4 and H264

Kieran O Leary kieran.o.leary at gmail.com
Sat May 14 22:11:29 EEST 2022


Hi

On Sat, May 14, 2022 at 7:02 PM Roger <rogerx.oss at gmail.com> wrote:

>
> What are the differences when specifying the format/contain as MP4 or
> H264?


MP4 can contain a variety of streams, including h264. If you specify h264,
you just have a raw h264 video stream, that's it.

>
> Are there any differences, when additionally specifying the video and
> audio
> codecs?
>
> $ ffmpeg-formats |grep mp4
>  D  mov,mp4,m4a,3gp,3g2,mj2 QuickTime / MOV
>   E mp4             MP4 (MPEG-4 Part 14)
>
> MPEG-4 Part 14
> https://en.wikipedia.org/wiki/MPEG-4_Part_14
> Laste published release: January 2020; 2 years ago
>
> $ ffmpeg-formats |grep h264
>  DE h264            raw H.264 video
>
> Advanced Video Coding
> https://en.wikipedia.org/wiki/Advanced_Video_Coding
> Last published version: 22 August 2021
>
>
> So what are the differences between the following?
>

Have you actually tested these out?


>
> $ ffmpeg -i video-in.ts -f mp4 -vcodec libx264 -preset ultrafast
> -profile:v main -acodec aac video-out.mp4
>

 Assuming your input has audio streams, this will just encode your input to
h264 video with aac audio in an mp4 container.

>
> $ ffmpeg -i video-in.ts -f h264 -vcodec libx264 -preset ultrafast
> -profile:v main -acodec aac video-out.mp4
>

This will take your input which may or may not have audio, and turn it into
a raw h264 stream, which you have then confusingly named the output with a
.mp4 extension, but something like .h264 might make a bit more sense, as
I've seen raw h264 streams appear like this.

I am not an expert on raw h264 streams, so I might be very wrong about all
this, but I tested with the following:

ffmpeg -f lavfi -i sine -f lavfi -i testsrc -f mp4 -vcodec libx264 -pix_fmt
yuv420p -preset ultrafast -profile:v main  -acodec aac -t 4 mp4.mp4

and

 ffmpeg -f lavfi -i sine -f lavfi -i testsrc -f h264 -vcodec libx264
-pix_fmt yuv420p -preset ultrafast -profile:v main  -acodec aac -t 4
h264.mp4


The former had the audio stream, the latter did not.


Best,


Kieran O'Leary

National Library of Ireland


>
>
> Roger
>
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
>


More information about the ffmpeg-user mailing list