Fix ffprobe output

This commit is contained in:
Nick Mowen 2023-02-25 16:10:10 -07:00
parent e2baca387a
commit 298207dc66
2 changed files with 56 additions and 19 deletions

View File

@ -1296,12 +1296,12 @@ def ffprobe():
output.append( output.append(
{ {
"return_code": ffprobe.returncode, "return_code": ffprobe.returncode,
"stderr": json.loads(ffprobe.stderr.decode("unicode_escape").strip()) "stderr": ffprobe.stderr.decode("unicode_escape").strip()
if ffprobe.stderr.decode() if ffprobe.returncode != 0
else {}, else "",
"stdout": json.loads(ffprobe.stdout.decode("unicode_escape").strip()) "stdout": json.loads(ffprobe.stdout.decode("unicode_escape").strip())
if ffprobe.stdout.decode() if ffprobe.returncode == 0
else {}, else "",
} }
) )

View File

@ -49,14 +49,14 @@ export default function System() {
}); });
if (response.status === 200) { if (response.status === 200) {
setState({ ...state, showFfprobe: true, ffprobe: JSON.stringify(response.data, null, 2) }); setState({ ...state, showFfprobe: true, ffprobe: response.data });
} else { } else {
setState({ ...state, showFfprobe: true, ffprobe: 'There was an error getting the ffprobe output.' }); setState({ ...state, showFfprobe: true, ffprobe: 'There was an error getting the ffprobe output.' });
} }
}; };
const onCopyFfprobe = async () => { const onCopyFfprobe = async () => {
copy(JSON.stringify(state.ffprobe, jsonCleaner, 2)); copy(JSON.stringify(JSON.stringify(state.ffprobe), jsonCleaner, 2));
setState({ ...state, ffprobe: '', showFfprobe: false }); setState({ ...state, ffprobe: '', showFfprobe: false });
}; };
@ -79,7 +79,7 @@ export default function System() {
}; };
const onCopyVainfo = async () => { const onCopyVainfo = async () => {
copy(JSON.stringify(state.vainfo, jsonCleaner, 2)); copy(JSON.stringify(JSON.stringify(state.vainfo), jsonCleaner, 2));
setState({ ...state, vainfo: '', showVainfo: false }); setState({ ...state, vainfo: '', showVainfo: false });
}; };
@ -111,9 +111,52 @@ export default function System() {
{state.showFfprobe && ( {state.showFfprobe && (
<Dialog> <Dialog>
<div className="p-4"> <div className="p-4 mb-2 max-h-96 whitespace-pre-line overflow-scroll">
<Heading size="lg">Ffprobe Output</Heading> <Heading size="lg">Ffprobe Output</Heading>
{state.ffprobe != '' ? <p className="mb-2">{state.ffprobe}</p> : <ActivityIndicator />} {state.ffprobe != '' ? (
<div>
{state.ffprobe.map((stream, idx) => (
<div key={idx} className="mb-2 max-h-96 whitespace-pre-line">
<div>Stream {idx}:</div>
<div className="px-2">Return Code: {stream.return_code}</div>
<br />
{stream.return_code == 0 ? (
<div>
{stream.stdout.streams.map((codec, idx) => (
<div className="px-2" key={idx}>
{codec.width ? (
<div>
<div>Video:</div>
<br />
<div>Codec: {codec.codec_long_name}</div>
<div>
Resolution: {codec.width}x{codec.height}
</div>
<div>FPS: {codec.avg_frame_rate == '0/0' ? 'Unknown' : codec.avg_frame_rate}</div>
<br />
</div>
) : (
<div>
<div>Audio:</div>
<br />
<div>Codec: {codec.codec_long_name}</div>
<br />
</div>
)}
</div>
))}
</div>
) : (
<div className="px-2">
<div>Error: {stream.stderr}</div>
</div>
)}
</div>
))}
</div>
) : (
<ActivityIndicator />
)}
</div> </div>
<div className="p-2 flex justify-start flex-row-reverse space-x-2"> <div className="p-2 flex justify-start flex-row-reverse space-x-2">
<Button className="ml-2" onClick={() => onCopyFfprobe()} type="text"> <Button className="ml-2" onClick={() => onCopyFfprobe()} type="text">
@ -136,17 +179,11 @@ export default function System() {
<Heading size="lg">Vainfo Output</Heading> <Heading size="lg">Vainfo Output</Heading>
{state.vainfo != '' ? ( {state.vainfo != '' ? (
<div className="mb-2 max-h-96 whitespace-pre-line"> <div className="mb-2 max-h-96 whitespace-pre-line">
<div className="">Return Code:</div> <div className="">Return Code: {state.vainfo.return_code}</div>
<br /> <br />
<div>{state.vainfo.return_code}</div> <div className="">Process {state.vainfo.return_code == 0 ? 'Output' : 'Error'}:</div>
<br /> <br />
<div className="">Process Error:</div> <div>{state.vainfo.return_code == 0 ? state.vainfo.stdout : state.vainfo.stderr}</div>
<br />
<div>{state.vainfo.stderr}</div>
<br />
<div className="">Process Output:</div>
<br />
{state.vainfo.stdout}
</div> </div>
) : ( ) : (
<ActivityIndicator /> <ActivityIndicator />