How to keep original video file header in FFmpeg

1

1

I'm trying to use FFMpeg to do some processing on my input video files which is then given to an emulator software (a packetization software) for further processing. The emulator is basically a packetization software. But no matter what it is, the original video file which works is attached. The creator of the file said he used bento4 tool for creation of the file. What is different from that tool from FFmpeg?

The problem is that the emulator can read the original video file, but when I simply use the command ffmpeg -i input.video -c copy output.mp4, while it should essentially copy all configurations, the emulator can not read and process the new file.

Here is a copy of the original .mp4 file which works fine in the emulator.

I used mediainfo tool to compare the details of the two files and noticed while all video codec related configs are the same, there are some differences in the header sizes which probably are causing the problems. Is there any ways to force FFmpeg to keep headers information (aside from codecs)? Or maybe there are other problems? In any case, the output video is not being totally the same.

UPDATE: I'm still struggling with the issue. I looked into the emulator code, and it parses the MOOV and fragment headers for information. Using the MP4 explorer software, I notice in my generated .mp4 file, for all moof.traf.trun, sample duration is 0, but in the Track Fragment Header box, it sets the default_sample_duration to 512. While in the working file, there is no default_sample_duration, and each individual sample has a duration of size 512. I guess this might be the problem. Now any ways to make it like original?

enter image description here

Ariana

Posted 2017-07-17T15:32:55.877

Reputation: 137

Question was closed 2017-07-30T07:25:40.843

What the heck do you mean by “emulator?” – JakeGould – 2017-07-17T15:57:01.427

The emulator is basically a packetization software. But no matter what it is, the original video file which works is attached. – Ariana – 2017-07-17T16:19:00.083

I'm not sure if this can be solved … at least not without having access to that “emulator” software and debugging it. Do you get any log output as to what's wrong? Does it say why it cannot process the file? Can you check with a developer? – slhck – 2017-07-17T17:33:35.813

Not a specific error. It looks NULL to it: loading binary file\ pthread_join(thread[1], NULL); – Ariana – 2017-07-17T17:39:44.753

2Hm, this question comes down to guesswork then. It's ultimately a bug/problem in proprietary software, which we cannot (easily) solve without a lot of back and forward. – slhck – 2017-07-17T18:38:03.677

UPDATE: The creator of the file said he used bento4 tool for creation of the file. What is different from that tool from FFMPEG? – Ariana – 2017-07-17T18:47:18.377

Answers

2

If by header, you mean the MOOV box/atom, then ffmpeg will always construct a new box. It cannot copy boxes or their contents over. What your command does is tell FFmpeg to demux all streams from the original file and remux them into a new container.

Can you be specific in what your emulator looks for?

Gyan

Posted 2017-07-17T15:32:55.877

Reputation: 21 016

The emulator is basically a packetization software. But no matter what it is, the original video file which works is attached. – Ariana – 2017-07-17T16:20:01.813

2Your attached file has MOOV upfront, which ffmpeg does not do, by default. Try ffmpeg -i input.video -c copy -movflags +faststart output.mp4 – Gyan – 2017-07-17T16:33:02.983

@Mulvya I would recommend to adjust your answer to add those details. – JakeGould – 2017-07-17T17:16:20.220

Once we know if that's the issue. The header aspect is a guess by the OP. – Gyan – 2017-07-17T17:28:39.503

@Mulvya that didn't work. – Ariana – 2017-07-17T17:37:32.193

1ok, mp4box indicates your source is fragmented mp4. So, try ffmpeg -i input.video -c copy -movflags +dash output.mp4 – Gyan – 2017-07-17T18:00:42.260

1@Mulvya Yes it is for streaming purposes. That throws a segmentation fault! segmentation fault (core dumped) Looks like we are getting close! – Ariana – 2017-07-17T18:44:30.347

UPDATE: The creator of the file said he used bento4 tool for creation of the file. What is different from that tool from FFMPEG? – Ariana – 2017-07-17T18:47:23.763

It's a weird software you're using that crashes upon getting an unrecognized file. Can you share any details? Alternatively, try ffmpeg -i input.video -c copy -movflags +dash+global_sidx -brand isom output.mp4 but this is guesswork. – Gyan – 2017-07-17T19:03:24.780

@Ariana When you do ffmpeg -i edv_g24.mp4 -c copy -movflags +faststart -brand isom edv_g24_2.mp4, the resulting file is not that different from the original – this is using mp4info from bento4. The only difference there is the major brand list and track flags. But if that crashes your software, you have to fix that obviously. I'm sure a developer can investigate that segfault based on the converted file.

– slhck – 2017-07-17T19:54:38.347

No chance. The null error again. Thanks anyways. I should talk to the developers probably – Ariana – 2017-07-17T20:00:09.920