shaka-project / shaka-packager

A media packaging and development framework for VOD and Live DASH and HLS applications, supporting Common Encryption for Widevine and other DRM Systems.
https://shaka-project.github.io/shaka-packager/
Other
1.95k stars 504 forks source link

Fail to package a webm file (Error writing segment header) #1421

Open mathix420 opened 1 month ago

mathix420 commented 1 month ago

System info

Operating System: 6.1.102-108.177.amzn2023.x86_64 Shaka Packager Version: v3.2.0-53b8668-release

Issue and steps to reproduce the problem

Packager Command:

packager in=preprocessing.webm,stream=video,output=out.webm --temp_dir tmp --mpd_output dash.mpd

Extra steps to reproduce the problem?

# step 1
mkdir tmp

# step 2
ffmpeg -i input.webm -vf "scale=in_color_matrix=bt709:out_color_matrix=bt709" \
    -color_primaries bt709 -color_trc bt709 -colorspace bt709 \
    -c:v libvpx-vp9 -b:v 2M -pix_fmt yuv420p preprocessing.webm

What is the expected result?

Not failing.

What happens instead?

I0817 14:02:59.463221   33514 demuxer.cc:94] Demuxer::Run() on file 'preprocessing.webm'.
I0817 14:02:59.463291   33514 demuxer.cc:160] Initialize Demuxer for file 'preprocessing.webm'.
W0817 14:02:59.488550   33514 vp_codec_configuration_record.cc:46] VPx video full range flag is inconsistent, 1 vs 0
W0817 14:02:59.488595   33514 vp_codec_configuration_record.cc:46] VPx color primaries is inconsistent, 12 vs 1
E0817 14:02:59.510545   33513 packager_main.cc:628] Packaging Error: 5 (FILE_FAILURE): Error writing segment header.

<Please attach the input files or email to shaka-packager-issues@google.com.>

ffprobe results:

preprocessing.webm

Input #0, matroska,webm, from 'preprocessing.webm':
  Metadata:
    ENCODER         : Lavf61.5.101
  Duration: 00:09:04.43, start: 0.000000, bitrate: 573 kb/s
  Stream #0:0(eng): Video: vp9 (Profile 0), yuv420p(tv, bt709/smpte432/bt709, progressive), 853x480, SAR 1:1 DAR 853:480, 30 fps, 30 tbr, 1k tbn
      Metadata:
        HANDLER_NAME    : Core Media Video
        VENDOR_ID       : FFMP
        ENCODER         : Lavc61.11.100 libvpx-vp9
        DURATION        : 00:09:04.433000000

input.webm

Input #0, matroska,webm, from 'input.webm':
  Metadata:
    ENCODER         : Lavf60.16.100
  Duration: 00:09:04.43, start: 0.000000, bitrate: 620 kb/s
  Stream #0:0(eng): Video: vp9 (Profile 0), yuv420p(tv, bt709/smpte432/bt709, progressive), 853x480, SAR 1:1 DAR 853:480, 30 fps, 30 tbr, 1k tbn
      Metadata:
        HANDLER_NAME    : Core Media Video
        VENDOR_ID       : FFMP
        ENCODER         : Lavc60.31.102 libvpx-vp9
        DURATION        : 00:09:04.431000000
$ ffprobe -v error -select_streams v:0 -show_entries stream=color_range,color_space,color_primaries,color_transfer -of default=noprint_wrappers=1:nokey=1 preprocessing.webm

tv
bt709
bt709
smpte432
mathix420 commented 4 weeks ago

Okay, I think I found a solution to my issue. It seems that smpte432 is not supported by ffmpeg as colorspace filter. https://trac.ffmpeg.org/ticket/6132#no1

I was suspecting smpte432 to be an issue because of the warning message, but failed to convert colors with the command from step 2 and didn't noticed at first.

With this command I managed to do it:

ffmpeg -i input.webm -t 10 -vf "scale=854:480,colorspace=all=bt709:iall=bt709:range=pc" -c:v libvpx-vp9 -pix_fmt yuv420p output1.webm

I don't know if this should be handled by shaka packager so I leave this issue open to let you decide.