Opened 7 months ago

Closed 7 months ago

#10623 closed defect (invalid)

Metadata is written at the end of the process, making piped output miss metadata

Reported by: vortex Owned by:
Priority: normal Component: ffmpeg
Version: git-master Keywords: pipe matroska
Cc: vortex Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

I use ffmpeg to modify (convert, copy or remove) some subtitles on mkv files. The data is piped through stdin and stdout using this command:

% ffmpeg -i pipe:0 -map 0:a -c:a copy -map 0:v -c:v copy -map 0:s? -c:s:0 subrip -c:s:1 copy -hide_banner -loglevel warning -stats -f matroska pipe:1

The result I get from stdout is missing metadata.

So I tried to let ffmpeg write the output to a file and I was reading the file asynchronously while it was still be written.

% ffmpeg -i pipe:0 -map 0:a -c:a copy -map 0:v -c:v copy -map 0:s? -c:s:0 subrip -c:s:1 copy -hide_banner -loglevel warning -stats -f matroska out.mkv

I notified the metadata in the asynchronously read file was still missing, but the final output file had the metadata. I binary compared them and they were mostly identical, but differed from address 0x300D to 0x700C (I guess this is part the metadata).

So it looks like ffmpeg writes the metadata at the end of processing which does not work well with pipes.

I also tried to build ffmpeg from master branch (commit 5ddabd49d) and use it, but the problem persisted.

Is this a bug or are my ffmpeg commandline args not optimal?

Change History (2)

comment:1 by mkver, 7 months ago

The Matroska muxer writes updated metadata (namely proper durations which is probably the missing metadata you mention) as well as the index ("Cues" in Matroska-speak) at the end if the output is seekable. The reason for this restriction is that in order for the metadata to be updated as well as in order for Cues to be usable, one needs to be able to overwrite some bytes at the beginning of the file. So I don't really see what could be done better here.

comment:2 by mkver, 7 months ago

Keywords: -map removed
Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.