Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

FFMpegTranscodeProcess how to place metadata at the beginning of mp4 video file

Peter_Puzanovs
Community Advisor
Community Advisor

Have an issue with mp4 videos not playing correctly on site.

Following investigation, it was found that video's are not playing smoothly with player when metadata is at the end of the video file.

To play smoothly(without delays at the start) metadata needs to be at the start of the video file.

How to let FFMpegTranscodeProcess(or any other CQ5.6.1 workflow step) know that I would like to put metadata at the start of the video file?

Thanks,

Peter

1 Accepted Solution
smacdonald2008
Correct answer by
Level 10
Level 10
Are you using custom work flow ? 

View solution in original post

2 Replies
smacdonald2008
Correct answer by
Level 10
Level 10
Are you using custom work flow ? 

View solution in original post

Peter_Puzanovs
Community Advisor
Community Advisor

Hi Scott,

Thank you for your answer, indeed it was a custom workflow step that encoded mp4 container in a wrong way:

The issue was with the way how video was encoded into mp4 format.

 

The video description is placed at the end of the file. Instead video description(metadata) needs to be in front of the video file.

 

Detailed report:

Following tools have been used MP4Box and ffmpeg.

 

First, file has been tested in MP4Box to see where metadata is:

C:\Program Files\GPAC>MP4Box.exe -info -v inputfile.mp4

[iso file] Current top box start before parsing 0

[iso file] Read Box type ftyp size 24 start 0

[iso file] Current top box start before parsing 24

[iso file] Read Box type mdat size 66128133 start 24

[iso file] Current top box start before parsing 66128157

[iso file] Read Box type mdat size 7615147 start 66128157

[iso file] Current top box start before parsing 73743304

[iso file] Read Box type moov size 160899 start 73743304

 

 

As you can see, first is data which is mdat(data) and only then description which is moov(description-metadata). This can prevent video player from real time streaming.

 

Following this, ffmpeg step has been used to move moov to the start of the file:

ffmpeg -i inputfile.mp4 -movflags +faststart outputfile.mp4

 

This has swapped mdat with moov.

 

Now, MP4Box gave following output:

MP4Box.exe -info -v outputfile.mp4

[iso file] Current top box start before parsing 0

[iso file] Read Box type ftyp size 32 start 0

[iso file] Current top box start before parsing 32

[iso file] Read Box type moov size 525687 start 32

[iso file] Read Box type mvhd size 108 start 40

[iso file] Read Box type trak size 268605 start 148

[iso file] Read Box type tkhd size 92 start 156

[iso file] Read Box type edts size 36 start 248

[iso file] Read Box type elst size 28 start 256

[iso file] Read Box type mdia size 268469 start 284

 

As you can see one of the first data blocks contains moov description.

 

Following video encoding change with ffmpeg tool, video is playing in real time.

 

Thanks,

Peter