Skip to content

Error generating FFmpeg command: Expecting ',' delimiter: line 1 column 432 (char 431) #20

@lucemia

Description

@lucemia

while parsing
ffmpeg -i input.mov -i resources/nfa-logo.png -filter_complex "[0:v]scale=flags=lanczos+accurate_rnd:h=720:w=-1[s0];[s0]lut3d=file=resources/rip_lut_pushup.cube[s1];[1]scale=height=720:width=-1[s2];[s1][s2]overlay=eof_action=repeat:x=(W/2-w/2):y=0[s3];[s3]drawtext=borderw=2:fontcolor=white:fontfile=resources/fonts/arial.ttf:fontsize=30:r=25/1:timecode=00\:00\:00\:00:x=(W-tw)/2:y=text_h[s4];[s4][0:a]concat=a=1:n=1:v=1[s5]" -map [s5] -f mp4 -ac 2 -b:a 64k -bf 2 -c:a aac -c:v h264_nvenc -color_primaries bt709 -color_trc bt709 -colorspace bt709 -g 250 -map_metadata -1 -movflags +faststart+write_colr -pix_fmt yuv420p -preset slow -profile:v high -qp 28 -rc constqp -refs 4 -shortest -spatial-aq 1 -strict_gop 1 -timecode 00:00:00:00 output.mp4 -hide_banner -loglevel error

import json
def __run_code():
    
    from ffmpeg.common.serialize import loads
    from ffmpeg.compile.compile_python import compile
    from ffmpeg.dag.nodes import GlobalStream
    
    # Load the JSON string
    json_str = '''{\"node\":{\"kwargs\":{},\"inputs\":[{\"node\":{\"kwargs\":{\"f\":\"mp4\",\"ac\":\"2\",\"b:a\":\"64k\",\"c:a\":\"aac\",\"c:v\":\"h264_nvenc\",\"map_metadata\":true,\"pix_fmt\":\"yuv420p\",\"profile:v\":\"high\",\"shortest\":true,\"timecode\":\"00:00:00:00\"},\"inputs\":[{\"node\":{\"kwargs\":{\"n\":\"1\",\"v\":\"1\",\"a\":\"1\"},\"inputs\":[{\"node\":{\"kwargs\":{\"fontfile\":\"resources/fonts/arial.ttf\",\"fontcolor\":\"white\",\"fontsize\":\"30\",\"x\":\"(W-tw)/2\",\"y\":\"text_h\",\"borderw\":\"2\",\"timecode\":\"00\\\\\",\"r\":\"25/1\"},\"inputs\":[{\"node\":{\"kwargs\":{\"x\":\"(W/2-w/2)\",\"y\":\"0\",\"eof_action\":\"repeat\"},\"inputs\":[{\"node\":{\"kwargs\":{\"file\":\"resources/rip_lut_pushup.cube\"},\"inputs\":[{\"node\":{\"kwargs\":{\"w\":\"-1\",\"h\":\"720\",\"flags\":\"lanczos+accurate_rnd\"},\"inputs\":[{\"node\":{\"kwargs\":{},\"inputs\":[],\"filename\":\"input.mov\",\"__class__\":\"InputNode\"},\"index\":null,\"__class__\":\"AVStream\"}],\"name\":\"scale\",\"input_typings\":[{\"value\":\"video\",\"__class__\":\"StreamType\"}],\"output_typings\":[{\"value\":\"video\",\"__class__\":\"StreamType\"}],\"__class__\":\"FilterNode\"},\"index\":0,\"__class__\":\"VideoStream\"}],\"name\":\"lut3d\",\"input_typings\":[{\"value\":\"video\",\"__class__\":\"StreamType\"}],\"output_typings\":[{\"value\":\"video\",\"__class__\":\"StreamType\"}],\"__class__\":\"FilterNode\"},\"index\":0,\"__class__\":\"VideoStream\"},{\"node\":{\"kwargs\":{\"height\":\"720\",\"width\":\"-1\"},\"inputs\":[{\"node\":{\"kwargs\":{},\"inputs\":[],\"filename\":\"resources/nfa-logo.png\",\"__class__\":\"InputNode\"},\"index\":null,\"__class__\":\"AVStream\"}],\"name\":\"scale\",\"input_typings\":[{\"value\":\"video\",\"__class__\":\"StreamType\"}],\"output_typings\":[{\"value\":\"video\",\"__class__\":\"StreamType\"}],\"__class__\":\"FilterNode\"},\"index\":0,\"__class__\":\"VideoStream\"}],\"name\":\"overlay\",\"input_typings\":[{\"value\":\"video\",\"__class__\":\"StreamType\"},{\"value\":\"video\",\"__class__\":\"StreamType\"}],\"output_typings\":[{\"value\":\"video\",\"__class__\":\"StreamType\"}],\"__class__\":\"FilterNode\"},\"index\":0,\"__class__\":\"VideoStream\"}],\"name\":\"drawtext\",\"input_typings\":[{\"value\":\"video\",\"__class__\":\"StreamType\"}],\"output_typings\":[{\"value\":\"video\",\"__class__\":\"StreamType\"}],\"__class__\":\"FilterNode\"},\"index\":0,\"__class__\":\"VideoStream\"},{\"node\":{\"kwargs\":{},\"inputs\":[],\"filename\":\"input.mov\",\"__class__\":\"InputNode\"},\"index\":null,\"__class__\":\"AVStream\"}],\"name\":\"concat\",\"input_typings\":[{\"value\":\"video\",\"__class__\":\"StreamType\"},{\"value\":\"audio\",\"__class__\":\"StreamType\"}],\"output_typings\":[{\"value\":\"video\",\"__class__\":\"StreamType\"},{\"value\":\"audio\",\"__class__\":\"StreamType\"}],\"__class__\":\"FilterNode\"},\"index\":0,\"__class__\":\"VideoStream\"}],\"filename\":\"output.mp4\",\"__class__\":\"OutputNode\"},\"index\":null,\"__class__\":\"OutputStream\"}],\"__class__\":\"GlobalNode\"},\"index\":null,\"__class__\":\"GlobalStream\"}'''
    
    try:
      # Load the stream from JSON
      stream = loads(json_str)
      
      # Return both the Python code and the FFmpeg command
      return {
          'result': stream.compile_line(),
          'error': None
      }
    except Exception as e:
      print(f\"ERROR: {str(e)}\")
      return {
          'result': f\"# Error: {str(e)}\",
          'error': str(e)
      }
    

__run_code_result = json.dumps(__run_code())

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions