-
Notifications
You must be signed in to change notification settings - Fork 417
Description
I am new to PyAV and trying to process an input container (highway.mp4, 15.1MB). I have attached the codec information extracted from VLC as an image.
My goal is to extract packets from the input and directly mux them into an output container (test_output.mp4) with a custom configuration (codec, FPS, height, width, etc.), without using the template argument in add_stream. However, the output video is generated with blank frames while retaining the same size and duration as the input.
I have tried different codecs and added various parameters, but the issue persists.
Additionally, I encountered another issue: the video_stream object is non-serializable.
Environment
Python Version: 3.8.19
Ubuntu Version:
Distributor ID: Ubuntu
Description: Ubuntu 24.04.1 LTS
Release: 24.04
Codename: noble
PyAV Version: 10.0.0
Code Snippet
import av
input_ = av.open("highway.mp4")
output = av.open("test_output.mp4", "w")
in_stream = input_.streams.video[0]
if 0:
out_stream = output.add_stream(template=in_stream)
else:
# codec_name = in_stream.codec.name
codec_name = "mpeg4"
# codec_name = "libaom-av1"
# codec_name = "mp4v"
# codec_name = "avc1"
# codec_name = "libx264"
out_stream = output.add_stream(codec_name, in_stream.average_rate)
out_stream.width = in_stream.codec_context.width
out_stream.height = in_stream.codec_context.height
out_stream.pix_fmt = in_stream.codec_context.pix_fmt
for packet in input_.demux(in_stream):
if packet.dts is None:
continue
packet.stream = out_stream
output.mux(packet)
input_.close()
output.close()
Expected Behavior
The output video should contain valid frames, not blank ones.
The video_stream object should be serializable.
Actual Behavior
The output video has blank frames with the same size and duration as the input.
The video_stream object is non-serializable.
Steps Taken to Troubleshoot
Tried multiple codecs (mpeg4, libaom-av1, mp4v, avc1, libx264).
Tested different parameter configurations.
No success in resolving the blank frame issue.
Request for Help
What could be causing the blank frames in the output?
How can I serialize the video_stream object?
Any suggestions or corrections to my approach?
Thanks in advance for your help!
