convert mp4 to mpeg

The problem ended up being hikvision using a non-standard header demux format in the mp4 files to declare video and audio formats

In reality the video stream is H.265 with a 4:2:0 8 bit BT709 colour space, and a mono AAC LC 16.0 kHz audio track

This is probably intentional to make 99% of people just use their software

The data in the stream iteself is perfectly normal - just the headers are silly.

The fix is to use VLC to run through demux combinations until it finds out what the stream really is, then remux the raw data as a file with normal headers (in this case just an MPEG-TS file because I cant be bothered otherwise), then to feed the .ts files to ffmpeg to encode it as an AVC file with and AAC audio track in an mp4 container. This makes it so any video editing software can use it again easily
 
As for anyone else facing similar issues and just wants a script to make it usable:

Im going to assume you're on a windows machine

First download and update VLC to latest (https://www.videolan.org/vlc/download-windows.html)

Then either build from git or download a recent compile of ffmpeg (here for windows compile non avx512 https://www.gyan.dev/ffmpeg/builds/ffmpeg-git-full.7z)

Make a folder where you will work. Make a text file called "reheaderthenencodeAVCAAC.txt". Make another folder inside here called "Workingspace"

Extract/build ffmpeg and place ffmpeg.exe into this folder

Open the text file reheaderthenencodeAVCAAC and paste this inside

Code:
FOR /R "PATHTOWORKINGSPACE" %%A IN ("*.mp4") DO "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" -I dummy --no-repeat --no-loop -vv "%%A" --sout="#std{access=file,mux=ts,dst=%%~A%ni%.ts}" vlc://quit

FOR /R "PATHTOWORKINGSPACE" %%A IN ("*.ts") DO ffmpeg -i "%%A" -c:v libx264 -crf 23 -preset medium -c:a aac -q:a 330 "%%~dpnACONVERTEDAVCAAC.mp4"
Replace PATHTOWORKINGSPACE with the actual location of the Workingspace folder (eg. C:\Users\ryan\Desktop\twitch\ffmpeg-2020-10-07-git-a086b73e1f-full_build\ffmpeg-2020-10-07-git-a086b73e1f-full_build\bin\convert). The path must have quotation marks either side. (I.e it should look like FOR /R " C:\Users\ryan\Desktop\twitch\ffmpeg-2020-10-07-git-a086b73e1f-full_build\ffmpeg-2020-10-07-git-a086b73e1f-full_build\bin\convert" %%A IN ....)

Save the text file as reheaderthenencodeAVCAAC.bat

Place all the mp4 dashcam files you want to reencode to work for you inside of Workingspace, then run the batch file, and it should automagically reencode everything for you in one click
 
As for anyone else facing similar issues and just wants a script to make it usable:

Im going to assume you're on a windows machine

First download and update VLC to latest (https://www.videolan.org/vlc/download-windows.html)

Then either build from git or download a recent compile of ffmpeg (here for windows compile non avx512 https://www.gyan.dev/ffmpeg/builds/ffmpeg-git-full.7z)

Make a folder where you will work. Make a text file called "reheaderthenencodeAVCAAC.txt". Make another folder inside here called "Workingspace"

Extract/build ffmpeg and place ffmpeg.exe into this folder

Open the text file reheaderthenencodeAVCAAC and paste this inside

Code:
FOR /R "PATHTOWORKINGSPACE" %%A IN ("*.mp4") DO "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" -I dummy --no-repeat --no-loop -vv "%%A" --sout="#std{access=file,mux=ts,dst=%%~A%ni%.ts}" vlc://quit

FOR /R "PATHTOWORKINGSPACE" %%A IN ("*.ts") DO ffmpeg -i "%%A" -c:v libx264 -crf 23 -preset medium -c:a aac -q:a 330 "%%~dpnACONVERTEDAVCAAC.mp4"
Replace PATHTOWORKINGSPACE with the actual location of the Workingspace folder (eg. C:\Users\ryan\Desktop\twitch\ffmpeg-2020-10-07-git-a086b73e1f-full_build\ffmpeg-2020-10-07-git-a086b73e1f-full_build\bin\convert). The path must have quotation marks either side. (I.e it should look like FOR /R " C:\Users\ryan\Desktop\twitch\ffmpeg-2020-10-07-git-a086b73e1f-full_build\ffmpeg-2020-10-07-git-a086b73e1f-full_build\bin\convert" %%A IN ....)

Save the text file as reheaderthenencodeAVCAAC.bat

Place all the mp4 dashcam files you want to reencode to work for you inside of Workingspace, then run the batch file, and it should automagically reencode everything for you in one click
Thank you so much for your time and help today bud, truly appreciated
 
Surprised no one said that mp4 and mpeg are just a wrapper or container, the codec is the problem
 
I agree with saor and some of the members. There are tons of online converters that you can use for simple stuff like this. The one I use and I can recommend is this converter called Converter365. If you can find free online converter that suits you better, go for it! :)
 
I agree with saor and some of the members. There are tons of online converters that you can use for simple stuff like this. The one I use and I can recommend is this converter called Converter365. If you can find free online converter that suits you better, go for it! :)
Wow. Necro much?
 
Resurrected a dead thread. Anyway, if you read the entire thread you'll notice the OP tried many converters which failed. Took some effort to resolve.
Thank you for informing me. I just tried to help mate. Cheers! :D
 
Top
Sign up to the MyBroadband newsletter
X