Remux/encode/convert MPG into MP4

.mp4mpegvideo conversion

I understand that it is impossible to edit metadata of MPG files (i.e. createdate), so I am looking for another way to "upgrade" my MPGs into a newer file format (preferred are formats that work both on Windows and iOS).

What should I do to achieve this goal? Remux/encode/convert my MPG videos into MP4 or MOV and what settings should be used in remuxing/encoding/converting the files? Which action would produce the best result; as close as possible to the original MPG videos?

Here is the mediainfo specification of one of my MPG files:

Complete name : E:\Users\Owner\Desktop\test\MOV03521.MPG
Format : MPEG-PS
File size : 25.1 MiB
Duration : 20s 124ms
Overall bit rate mode : Variable
Overall bit rate : 10.5 Mbps

ID : 224 (0xE0)
Format : MPEG Video
Format version : Version 1
Format settings, BVOP : No
Format settings, Matrix : Default
Format settings, GOP : N=1
Duration : 20s 100ms
Bit rate mode : Variable
Bit rate : 10.2 Mbps
Width : 640 pixels
Height : 480 pixels
Display aspect ratio : 4:3
Frame rate : 30.000 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Compression mode : Lossy
Bits/(Pixel*Frame) : 1.105
Time code of first frame : 00:00:00:00
Time code source : Group of pictures header
GOP, Open/Closed : Closed
Stream size : 24.4 MiB (97%)

ID : 192 (0xC0)
Format : MPEG Audio
Format version : Version 1
Format profile : Layer 2
Duration : 20s 124ms
Bit rate mode : Constant
Bit rate : 64.0 Kbps
Channel(s) : 1 channel
Sampling rate : 32.0 KHz
Compression mode : Lossy
Stream size : 157 KiB (1%) 

Best Answer

Creation date (like many other metadata fields) is a property you can set for MP4/MOV and MKV containers (as well as several others), but not for MPEG Program Streams or Transport Streams. In fact, there's no standard for video metadata like there's EXIF for photos. And when they designed MPEG containers they probably just didn't think about this application (yet).

You have to be aware of the fact that MPEG-1 is very old—they started developing it when I was born—and you would probably be better off converting the videos to a more recent and compression-efficient codec like H.264. Your 10 MBit/s MPEG-1 video will probably end up looking just as good at 1 MBit/s H.264, or even less than that.

So if the real issue is that the videos need to show up in the correct order in a file manager of some sort, and you cannot change the file manager or use a metadata platform, you need to re-mux or re-encode the videos.

Re-muxing will not touch the video/audio bitstream, thus keeping the file size and quality intact. With ffmpeg, you could try the following:

ffmpeg -i input.mpeg -c copy output.mkv

This may work or may not. It didn't when I tried, but in theory Matroska supports MPEG-1 video. Matroska is not natively supported on Windows or iOS though.

So, you can re-encode the video and audio to H.264/AAC in an MP4 container:

ffmpeg -i input.mpeg -c:v libx264 -preset slow -crf 18 -c:a aac -strict experimental -b:a 128k output.mp4

Here, the CRF option sets the quality. 18 means very good. 23 is the default. Lower means better, so if you want to retain quality, you might even want to go below 18. A CRF of ±6 results in about half/double the file size. The H.264 encoding guide is very helpful. Note that your resulting file may be smaller than the input file but will still look just as good. That's because the codec is much more efficient. I recommend you vary the CRF until you find the value where you cannot perceive a difference anymore between the original and the re-encoded one.

H.264/AAC in MP4 is supported on (newer) Windows and iOS. Older Windows versions (that includes Windows 7 IIRC) will not play it unless a codec pack is installed. For iOS compatibility on older devices, you may have to set -profile:v baseline as an option.

After converting to MKV or MP4, setting metadata such as creation date will be possible.