Output Container containes blank frames. #1760
Unanswered
Nagur-Basha1
asked this question in
1. Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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, such as mp4v, avc1, libx264, libaom-avi, etc., and added various parameters, but the issue persists.
I also tried python versions 3.8 and 3.12, and av versions 10.0.0 and 14.1.0
Additionally, I encountered another issue: the video_stream object is non-serializable.
Environment
Python Version: 3.8.19 and 3.12.7
Ubuntu Version:
Distributor ID: Ubuntu
Description: Ubuntu 24.04.1 LTS
Release: 24.04
Codename: noble
PyAV Version: 10.0.0 and 14.1.0 (Installed the pyav with pip)
Code Snippet
import av
input_ = av.open("highway.mp4")
output = av.open("test_output.mp4", "w")
in_stream = input_.streams.video[0]
codec_name = "mpeg4"
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!
Beta Was this translation helpful? Give feedback.
All reactions