Opened 4 years ago

Last modified 4 years ago

#8682 new enhancement

Feature: optionally write new headers while copying streams

Reported by: TiredEyes Owned by:
Priority: wish Component: undetermined
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
This would be useful for fixing files with broken headers, but correct data.

The idea is that ffmpeg analyzes the type of the stream, then wites new headers for this format as if it would transcode the stream fom another format to this format, but short-circuit the transcoding and instead use the original data, throwing away the original headers.

Maybe the command should be named copy-data, corresponding to the existing copy.

Usage example:

ffmpeg -i input.mpg -c:v copy -c:a copy-data output.mpg

Change History (6)

comment:1 by Carl Eugen Hoyos, 4 years ago

Please provide a sample input file: What you request works fine for many cases, FFmpeg will not be able to fix isom files with missing moov atom.

comment:2 by TiredEyes, 4 years ago

I have prepared an example video for demonstrating the issue, but it's very big: 522 MB.
The reason is it needs a certain length in order to show the problem. I've also tried to cut out a shorter version, but you can not reproduce issue with that.

Description of the issue:
When you play it straight from start to end, all players I've tested (VLC, mpv) work fine. Problems begin when you try to skip or singlestep backward. E.g. in mpv, you can singlestep backward using the , key, but only a few steps, then you get this error:

[ffmpeg/audio] mp2: Header missing
Error decoding audio.

and you can not step backward further. The same message pops up when you skip backwoards using the cursor left or down keys. Both situations do not happen always. In my example, you need to go forward several minutes, then skip backward a few times. And the singlestepping problem did not occur at all this video.

When I transcode the audio to pcm_dvd using
ffmpeg -i test_recording_BROKEN.mpg -c:v copy -c:a pcm_dvd test_recording_TRANSCODED.mpg
then mpv can play the video and singlestep or skip forward and backward as much as I want. But this has 2 downsides: the file gets bigger and I would like to avoid transcoding.

If there is a way how I can upload this big file please let me know. Otherwise, this is how it was produced:
Recorded from TV using the VDR (Video Disk Recorder) software in SD. VDR writes it to disk as mpeg2 transport stream .ts. Then I demultiplexed it using ProjectX, because it can select a range to demultiplex in a convenient way. Finally multiplexed into .mpg using
mplex -f 3 -o test_recording_BROKEN.mpg test_recording.m2v test_recording.m2a
If you have the same toolchain available, you could produce a test video on your own. My test video was recorded from german TV station "Das Erste" a.k.a. ARD. The frequentness of the issue seems to be different depending on the TV station it was recorded from, and generally more frequent in older recordings.

comment:3 by Carl Eugen Hoyos, 4 years ago

Please upload your sample input file to a file hoster of your choice and post the download link here or use https://streams.videolan.org/upload/ and post the file name here.

comment:4 by TiredEyes, 4 years ago

Sorry for the delay ... I had to interrupt my video projects for a "real life" topic.

It also took me a it to choose a file hoster, as I've never used one of them before. I wanted one without account but with either auto-expiry or the possibility to delete it after a while.

So I went for "Firefox Send". Only downside is: For non-registered users, the upload expires after 24h or 1 download. Here is the link:

https://send.firefox.com/download/ebab1320c3673c8b/#XGMThyWUxtvyT28nr7xDvg

Please let me know if you could download the file.

I managed to create a smaller example. The effect can be demonstrated best if you open the video in mpv and then move the position slider (appears at the bottom when you hver the mouse) back and forth using the mouse.

comment:6 by TiredEyes, 4 years ago

Done.

Note: See TracTickets for help on using tickets.